konokenj.cdk-api-mcp-server 0.31.0__py3-none-any.whl → 0.57.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. cdk_api_mcp_server/__about__.py +1 -1
  2. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-amplify-alpha/README.md +12 -0
  3. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-bedrock-agentcore-alpha/README.md +1979 -0
  4. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-bedrock-alpha/README.md +946 -0
  5. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-eks-v2-alpha/README.md +160 -75
  6. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-elasticache-alpha/README.md +421 -0
  7. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-glue-alpha/README.md +39 -9
  8. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-imagebuilder-alpha/README.md +656 -0
  9. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-iot-alpha/README.md +1 -1
  10. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-lambda-go-alpha/README.md +102 -4
  11. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-lambda-python-alpha/README.md +6 -6
  12. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-msk-alpha/README.md +38 -8
  13. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-s3tables-alpha/README.md +82 -2
  14. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-sagemaker-alpha/README.md +32 -0
  15. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/mixins-preview/README.md +182 -0
  16. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/README.md/README.md +367 -17
  17. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigateway/README.md +34 -0
  18. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigateway/integ.api-with-authorizer-and-proxy.ts +1 -1
  19. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigateway/integ.lambda-api.ts +1 -1
  20. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigateway/integ.lambda-permission-consolidation.ts +55 -0
  21. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigateway/integ.spec-restapi.ts +1 -0
  22. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/README.md +224 -60
  23. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.api-dualstack.ts +3 -4
  24. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.api.ts +5 -3
  25. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.stage.ts +10 -7
  26. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.usage-plan.ts +80 -0
  27. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-authorizers/integ.iam.ts +34 -38
  28. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-authorizers/integ.lambda.ts +2 -2
  29. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-authorizers/integ.user-pool.ts +1 -1
  30. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/README.md +35 -0
  31. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/integ.add-subroute-integration.ts +7 -4
  32. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/integ.http-proxy.ts +1 -1
  33. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/integ.lambda-connect-disconnect-trigger.ts +2 -2
  34. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/integ.lambda-permission-consolidation.ts +45 -0
  35. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/integ.lambda-proxy.ts +1 -1
  36. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/integ.lambda.ts +4 -4
  37. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/integ.sqs.ts +58 -71
  38. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-appsync/integ.graphql-lambda-permission.ts +1 -1
  39. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-appsync/integ.js-resolver.ts +1 -1
  40. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-autoscaling/README.md +1 -1
  41. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-autoscaling/integ.asg-lt.ts +7 -0
  42. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-batch/README.md +49 -1
  43. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-batch/integ.ecs-exec-batch-job.ts +148 -0
  44. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-batch/integ.managed-compute-environment-default-instance-class.ts +20 -0
  45. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-certificatemanager/README.md +11 -0
  46. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudformation/integ.core-custom-resources-node-18.ts +1 -1
  47. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudformation/integ.core-custom-resources-service-timeout.ts +1 -1
  48. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront/README.md +292 -1
  49. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront-origins/README.md +83 -0
  50. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront-origins/integ.function-url-origin-ip-address-type.ts +84 -0
  51. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront-origins/integ.http-origin.ts +5 -2
  52. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront-origins/integ.origin-response-completion-timeout.ts +50 -0
  53. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudtrail/integ.cloudtrail-data-events-only.ts +1 -1
  54. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudwatch/README.md +104 -12
  55. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudwatch/integ.alarm-and-dashboard.ts +12 -0
  56. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudwatch/integ.anomaly-detection-alarm.ts +44 -2
  57. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudwatch/integ.dashboard-with-graphwidget-with-labels-visible.ts +92 -0
  58. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudwatch/integ.dashboard-with-metric-id-and-visible.ts +70 -0
  59. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudwatch/integ.search-expression.ts +51 -0
  60. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codebuild/README.md +143 -3
  61. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codebuild/integ.project-docker-server.ts +44 -0
  62. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codebuild/integ.project-fleet-attribute-based-compute.ts +59 -7
  63. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codebuild/integ.project-fleet-custom-instance-type.ts +130 -0
  64. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codebuild/integ.project-fleet-overflow-behavior.ts +61 -0
  65. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codebuild/integ.project-s3-cache.ts +71 -0
  66. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codebuild/integ.project-windows-image.ts +1 -2
  67. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codepipeline-actions/integ.pipeline-elastic-beanstalk-deploy.ts +26 -17
  68. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cognito/README.md +13 -2
  69. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cognito/integ.user-pool-client-explicit-props.ts +1 -0
  70. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-docdb/README.md +24 -0
  71. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-docdb/integ.cluster-serverless.ts +34 -0
  72. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/README.md +225 -15
  73. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/TABLE_V1_API.md +45 -2
  74. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.dynamodb-v2.cci.ts +49 -0
  75. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.dynamodb.add-to-resource-policy.ts +97 -0
  76. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.dynamodb.cci.ts +27 -0
  77. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.dynamodb.compound.ts +32 -0
  78. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.dynamodb.contirubtor-insights-for-gsi.ts +6 -2
  79. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.dynamodb.policy.ts +21 -1
  80. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.table-v2-global.ts +9 -3
  81. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.table-v2-mrsc.ts +31 -0
  82. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-dynamodb/integ.table-v2.compound.ts +43 -0
  83. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/README.md +28 -1
  84. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/integ.client-vpn-endpoint-disconnect-on-session-timeout.ts +65 -0
  85. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/integ.vpc-endpoint.lit.ts +6 -0
  86. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ec2/integ.vpc-flow-logs.ts +4 -0
  87. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecr/README.md +41 -2
  88. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecr/integ.tag-mutability-exclusion.ts +30 -0
  89. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecr-assets/README.md +4 -0
  90. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecr-assets/integ.assets-docker.ts +6 -0
  91. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/README.md +189 -1
  92. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.availability-zone-rebalancing.ts +14 -4
  93. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.blue-green-deployment-strategy.ts +147 -0
  94. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.cluster-windows-server-ami.ts +5 -6
  95. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.ebs-volume-initialization-rate.ts +80 -0
  96. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.enable-execute-command.ts +35 -29
  97. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.exec-command.ts +16 -22
  98. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.lb-awsvpc-nw.ts +26 -16
  99. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.managedinstances-capacity-provider.ts +114 -0
  100. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.managedinstances-no-default-capacity-provider.ts +107 -0
  101. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.placement-strategies.ts +32 -8
  102. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.pseudo-terminal.ts +18 -8
  103. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs-patterns/README.md +2 -0
  104. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs-patterns/integ.alb-fargate-service-public-private-switch.ts +45 -0
  105. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs-patterns/integ.alb-fargate-service-smart-defaults.ts +143 -0
  106. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-eks/README.md +103 -83
  107. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-eks/integ.eks-al2023-nodegroup.ts +1 -1
  108. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-eks/integ.eks-cluster-removal-policy.ts +31 -0
  109. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-eks/integ.fargate-cluster.ts +1 -1
  110. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-elasticloadbalancingv2/README.md +55 -4
  111. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-elasticloadbalancingv2/integ.alb-lambda-multi-value-headers.ts +1 -1
  112. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-elasticloadbalancingv2/integ.alb-target-group-attributes.ts +45 -0
  113. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-elasticloadbalancingv2/integ.alb.oidc.ts +1 -1
  114. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-elasticloadbalancingv2/integ.nlb-target-group-attributes.ts +45 -0
  115. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-elasticloadbalancingv2/integ.nlb.security-group.ts +70 -0
  116. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-elasticloadbalancingv2-actions/integ.cognito.ts +1 -1
  117. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-events/README.md +41 -2
  118. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-events/integ.api-destination.ts +42 -0
  119. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-events/integ.archive-customer-managed-key.ts +23 -0
  120. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-events/integ.eventbus.ts +13 -3
  121. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-events-targets/README.md +93 -4
  122. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-events-targets/integ.firehose-delivery-stream.ts +51 -0
  123. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-iam/integ.custom-permissions-boundary-aspect.ts +50 -0
  124. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-iam/integ.managed-policy.ts +9 -0
  125. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-iam/integ.policy.ts +9 -0
  126. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesis/README.md +42 -0
  127. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesis/integ.stream-shard-level-monitoring.ts +47 -0
  128. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesisfirehose/README.md +159 -3
  129. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesisfirehose/integ.cloudwatch-logs-processors.ts +45 -0
  130. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesisfirehose/integ.record-format-conversion-schema.ts +154 -0
  131. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesisfirehose/integ.record-format-conversion.ts +178 -0
  132. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-kinesisfirehose/integ.s3-bucket.lit.ts +1 -0
  133. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/README.md +41 -2
  134. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.binary-payload.ts +1 -1
  135. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.lambda-policy-with-token-resolution.ts +46 -0
  136. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.logging-config.ts +8 -8
  137. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.multi-tenancy.ts +24 -0
  138. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.params-and-secrets.ts +1 -1
  139. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.runtime-management.ts +1 -1
  140. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.runtime.fromasset.ts +19 -4
  141. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/integ.runtime.inlinecode.ts +11 -4
  142. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda-nodejs/README.md +3 -3
  143. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda-nodejs/integ.dependencies-bun-lock.ts +50 -0
  144. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda-nodejs/integ.dependencies-pnpm.ts +1 -1
  145. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda-nodejs/integ.function-exclude-smithy-models.ts +2 -2
  146. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda-nodejs/integ.nodejs.build.images.ts +1 -1
  147. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/README.md +69 -1
  148. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/integ.loggroup-transformer.ts +37 -0
  149. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/integ.metricfilter-apply-on-transformed-logs.ts +29 -0
  150. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/integ.save-logs-insights-query-definition.ts +7 -2
  151. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/integ.subscriptionfilter.ts +1 -1
  152. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/integ.transformer.ts +27 -0
  153. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-opensearchservice/integ.opensearch.ebs.ts +1 -1
  154. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-opensearchservice/integ.opensearch.min.ts +1 -0
  155. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/README.md +72 -2
  156. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.cluster-cloudwatch-logs-exports.ts +56 -0
  157. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.cluster-data-api-to-imported-cluster.ts +1 -1
  158. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.cluster-data-api.ts +1 -1
  159. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.cluster-lookup.ts +100 -0
  160. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.cluster.ts +1 -1
  161. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.instance-database-insights.ts +43 -0
  162. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.instance-lookup.ts +77 -0
  163. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-rds/integ.proxy-endpoint.ts +36 -0
  164. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-route53/README.md +68 -31
  165. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-route53/integ.delete-existing-record-set.ts +0 -1
  166. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-route53/integ.private-hosted-zone-from-attributes.ts +41 -0
  167. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-route53/integ.route53.ts +51 -1
  168. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-route53/integ.zone-delegation-iam-stack.ts +66 -0
  169. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-route53-targets/integ.cloudfront-alias-target.ts +16 -1
  170. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-route53-targets/integ.elastic-beanstalk-hostedzoneid.ts +1 -1
  171. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3/integ.bucket.notifications-scoped-permissions.ts +71 -0
  172. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-assets/integ.assets.bundling.docker-opts.ts +4 -1
  173. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/README.md +83 -4
  174. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-big-response.ts +17 -6
  175. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cloudfront.ts +20 -18
  176. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cross-nested-stack-source.ts +64 -0
  177. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cross-stack-source.ts +53 -0
  178. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cross-stack-ssm-source.ts +97 -0
  179. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-data.ts +99 -59
  180. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-deployed-bucket.ts +10 -4
  181. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-large-file.ts +23 -12
  182. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-loggroup.ts +7 -2
  183. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-security-groups-efs.ts +77 -0
  184. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-security-groups-empty.ts +69 -0
  185. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-security-groups-multiple.ts +89 -0
  186. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-security-groups-single.ts +77 -0
  187. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-signcontent.ts +11 -7
  188. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-substitution-with-destination-key.ts +15 -8
  189. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-substitution-with-role.ts +29 -14
  190. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-substitution.ts +16 -8
  191. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-basic.ts +65 -0
  192. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-config.ts +66 -0
  193. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-custom-subnets.ts +66 -0
  194. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-efs.ts +66 -0
  195. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-security-groups.ts +72 -0
  196. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-vpc-subnet-selection.ts +70 -0
  197. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment.ts +47 -69
  198. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-notifications/integ.bucket-notifications.ts +80 -42
  199. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-secretsmanager/integ.secret.dynamic-reference-key.ts +38 -0
  200. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-signer/integ.signing-profile.ts +5 -0
  201. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-sns/README.md +2 -0
  202. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-sns-subscriptions/integ.sns-sqs-subscription-filter.ts +75 -0
  203. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-sns-subscriptions/integ.sns-sqs.ts +21 -40
  204. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions/integ.distributed-map-parallel.ts +82 -0
  205. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions/integ.distributed-map-redrive.ts +130 -0
  206. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions/integ.map-with-catch.ts +1 -0
  207. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions/integ.sm-jsonpath-with-distributed-map-jsonata.ts +105 -0
  208. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/README.md +75 -5
  209. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.call-aws-service-cross-region-lambda.ts +1 -1
  210. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.emr-create-cluster-with-ebs.ts +126 -0
  211. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.evaluate-expression-arm64.ts +27 -0
  212. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.evaluate-expression-default.ts +25 -0
  213. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.evaluate-expression-mixed-arch.ts +35 -0
  214. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.evaluate-expression-nodejs22.ts +27 -0
  215. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.evaluate-expression-x86.ts +27 -0
  216. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.invoke-json-path.ts +102 -0
  217. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/README.md +84 -1
  218. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/integ.canary-browser-type.ts +35 -0
  219. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/integ.canary-resources-to-replicate-tags.ts +36 -0
  220. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/integ.canary-retry.ts +32 -0
  221. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/integ.canary-runtime-validation.ts +43 -0
  222. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-synthetics/integ.canary.ts +2 -0
  223. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/cloudformation-include/integ.novalue-nonstring.ts +25 -0
  224. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/core/README.md +2 -1870
  225. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/custom-resources/README.md +59 -0
  226. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/custom-resources/integ.aws-custom-resource.ts +1 -1
  227. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/custom-resources/integ.custom-resource-config-lambda-node-runtime.ts +1 -1
  228. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/custom-resources/integ.external-id.ts +80 -0
  229. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/custom-resources/integ.invoke-function-payload.ts +1 -1
  230. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/cx-api/FEATURE_FLAGS.md +152 -10
  231. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/cx-api/README.md +55 -1
  232. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/interfaces/README.md +33 -0
  233. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/pipelines/README.md +4 -0
  234. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/pipelines/integ.newpipeline-reduce-stagerole-scope.ts +4 -1
  235. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/pipelines/integ.pipeline-with-customsynthesizer.ts +105 -0
  236. {konokenj_cdk_api_mcp_server-0.31.0.dist-info → konokenj_cdk_api_mcp_server-0.57.0.dist-info}/METADATA +2 -2
  237. {konokenj_cdk_api_mcp_server-0.31.0.dist-info → konokenj_cdk_api_mcp_server-0.57.0.dist-info}/RECORD +240 -151
  238. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-events-targets/integ.kinesis-firehose-stream.ts +0 -33
  239. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-logs/integ.expose-metric-with-dimensions.ts +0 -47
  240. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-signcontent.d.ts +0 -1
  241. {konokenj_cdk_api_mcp_server-0.31.0.dist-info → konokenj_cdk_api_mcp_server-0.57.0.dist-info}/WHEEL +0 -0
  242. {konokenj_cdk_api_mcp_server-0.31.0.dist-info → konokenj_cdk_api_mcp_server-0.57.0.dist-info}/entry_points.txt +0 -0
  243. {konokenj_cdk_api_mcp_server-0.31.0.dist-info → konokenj_cdk_api_mcp_server-0.57.0.dist-info}/licenses/LICENSE.txt +0 -0
@@ -1,1871 +1,3 @@
1
- # AWS Cloud Development Kit Library
1
+ # AWS CDK Core
2
2
 
3
- The AWS CDK construct library provides APIs to define your CDK application and add
4
- CDK constructs to the application.
5
-
6
- ## Usage
7
-
8
- ### Upgrade from CDK 1.x
9
-
10
- When upgrading from CDK 1.x, remove all dependencies to individual CDK packages
11
- from your dependencies file and follow the rest of the sections.
12
-
13
- ### Installation
14
-
15
- To use this package, you need to declare this package and the `constructs` package as
16
- dependencies.
17
-
18
- According to the kind of project you are developing:
19
-
20
- For projects that are CDK libraries in NPM, declare them both under the `devDependencies` **and** `peerDependencies` sections.
21
- To make sure your library is compatible with the widest range of CDK versions: pick the minimum `aws-cdk-lib` version
22
- that your library requires; declare a range dependency with a caret on that version in peerDependencies, and declare a
23
- point version dependency on that version in devDependencies.
24
-
25
- For example, let's say the minimum version your library needs is `2.38.0`. Your `package.json` should look like this:
26
-
27
- ```javascript
28
- {
29
- "peerDependencies": {
30
- "aws-cdk-lib": "^2.38.0",
31
- "constructs": "^10.0.0"
32
- },
33
- "devDependencies": {
34
- /* Install the oldest version for testing so we don't accidentally use features from a newer version than we declare */
35
- "aws-cdk-lib": "2.38.0"
36
- }
37
- }
38
- ```
39
-
40
- For CDK apps, declare them under the `dependencies` section. Use a caret so you always get the latest version:
41
-
42
- ```json
43
- {
44
- "dependencies": {
45
- "aws-cdk-lib": "^2.38.0",
46
- "constructs": "^10.0.0"
47
- }
48
- }
49
- ```
50
-
51
-
52
- ### Use in your code
53
-
54
- #### Classic import
55
-
56
- You can use a classic import to get access to each service namespaces:
57
-
58
- ```ts nofixture
59
- import { Stack, App, aws_s3 as s3 } from 'aws-cdk-lib';
60
-
61
- const app = new App();
62
- const stack = new Stack(app, 'TestStack');
63
-
64
- new s3.Bucket(stack, 'TestBucket');
65
- ```
66
-
67
- #### Barrel import
68
-
69
- Alternatively, you can use "barrel" imports:
70
-
71
- ```ts nofixture
72
- import { App, Stack } from 'aws-cdk-lib';
73
- import { Bucket } from 'aws-cdk-lib/aws-s3';
74
-
75
- const app = new App();
76
- const stack = new Stack(app, 'TestStack');
77
-
78
- new Bucket(stack, 'TestBucket');
79
- ```
80
-
81
- <!--BEGIN CORE DOCUMENTATION-->
82
-
83
- ## Stacks and Stages
84
-
85
- A `Stack` is the smallest physical unit of deployment, and maps directly onto
86
- a CloudFormation Stack. You define a Stack by defining a subclass of `Stack`
87
- -- let's call it `MyStack` -- and instantiating the constructs that make up
88
- your application in `MyStack`'s constructor. You then instantiate this stack
89
- one or more times to define different instances of your application. For example,
90
- you can instantiate it once using few and cheap EC2 instances for testing,
91
- and once again using more and bigger EC2 instances for production.
92
-
93
- When your application grows, you may decide that it makes more sense to split it
94
- out across multiple `Stack` classes. This can happen for a number of reasons:
95
-
96
- - You could be starting to reach the maximum number of resources allowed in a single
97
- stack (this is currently 500).
98
- - You could decide you want to separate out stateful resources and stateless resources
99
- into separate stacks, so that it becomes easy to tear down and recreate the stacks
100
- that don't have stateful resources.
101
- - There could be a single stack with resources (like a VPC) that are shared
102
- between multiple instances of other stacks containing your applications.
103
-
104
- As soon as your conceptual application starts to encompass multiple stacks,
105
- it is convenient to wrap them in another construct that represents your
106
- logical application. You can then treat that new unit the same way you used
107
- to be able to treat a single stack: by instantiating it multiple times
108
- for different instances of your application.
109
-
110
- You can define a custom subclass of `Stage`, holding one or more
111
- `Stack`s, to represent a single logical instance of your application.
112
-
113
- As a final note: `Stack`s are not a unit of reuse. They describe physical
114
- deployment layouts, and as such are best left to application builders to
115
- organize their deployments with. If you want to vend a reusable construct,
116
- define it as a subclasses of `Construct`: the consumers of your construct
117
- will decide where to place it in their own stacks.
118
-
119
- ## Stack Synthesizers
120
-
121
- Each Stack has a *synthesizer*, an object that determines how and where
122
- the Stack should be synthesized and deployed. The synthesizer controls
123
- aspects like:
124
-
125
- - How does the stack reference assets? (Either through CloudFormation
126
- parameters the CLI supplies, or because the Stack knows a predefined
127
- location where assets will be uploaded).
128
- - What roles are used to deploy the stack? These can be bootstrapped
129
- roles, roles created in some other way, or just the CLI's current
130
- credentials.
131
-
132
- The following synthesizers are available:
133
-
134
- - `DefaultStackSynthesizer`: recommended. Uses predefined asset locations and
135
- roles created by the modern bootstrap template. Access control is done by
136
- controlling who can assume the deploy role. This is the default stack
137
- synthesizer in CDKv2.
138
- - `LegacyStackSynthesizer`: Uses CloudFormation parameters to communicate
139
- asset locations, and the CLI's current permissions to deploy stacks. This
140
- is the default stack synthesizer in CDKv1.
141
- - `CliCredentialsStackSynthesizer`: Uses predefined asset locations, and the
142
- CLI's current permissions.
143
-
144
- Each of these synthesizers takes configuration arguments. To configure
145
- a stack with a synthesizer, pass it as one of its properties:
146
-
147
- ```ts
148
- new MyStack(app, 'MyStack', {
149
- synthesizer: new DefaultStackSynthesizer({
150
- fileAssetsBucketName: 'my-orgs-asset-bucket',
151
- }),
152
- });
153
- ```
154
-
155
- For more information on bootstrapping accounts and customizing synthesis,
156
- see [Bootstrapping in the CDK Developer Guide](https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html).
157
-
158
- ### STS Role Options
159
-
160
- You can configure STS options that instruct the CDK CLI on which configuration should it use when assuming
161
- the various roles that are involved in a deployment operation.
162
-
163
- > See https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping-env.html#bootstrapping-env-roles
164
-
165
- These options are available via the `DefaultStackSynthesizer` properties:
166
-
167
- ```ts
168
- class MyStack extends cdk.Stack {
169
- constructor(parent, id, props) {
170
- super(parent, id, {
171
- ...props,
172
- synthesizer: new DefaultStackSynthesizer({
173
- deployRoleExternalId: '',
174
- deployRoleAdditionalOptions: {
175
- // https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html#API_AssumeRole_RequestParameters
176
- },
177
- fileAssetPublishingExternalId: '',
178
- fileAssetPublishingRoleAdditionalOptions: {
179
- // https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html#API_AssumeRole_RequestParameters
180
- },
181
- imageAssetPublishingExternalId: '',
182
- imageAssetPublishingRoleAdditionalOptions: {
183
- // https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html#API_AssumeRole_RequestParameters
184
- },
185
- lookupRoleExternalId: '',
186
- lookupRoleAdditionalOptions: {
187
- // https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html#API_AssumeRole_RequestParameters
188
- },
189
- })
190
- });
191
- }
192
- }
193
- ```
194
-
195
- > Note that the `*additionalOptions` property does not allow passing `ExternalId` or `RoleArn`, as these options
196
- > have dedicated properties that configure them.
197
-
198
- #### Session Tags
199
-
200
- STS session tags are used to implement [Attribute-Based Access Control](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction_attribute-based-access-control.html) (ABAC).
201
-
202
- > See [IAM tutorial: Define permissions to access AWS resources based on tags](https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_attribute-based-access-control.html)
203
-
204
- You can pass session tags for each [role created during bootstrap](https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping-env.html#bootstrapping-env-roles) via the `*additionalOptions` property:
205
-
206
- ```ts
207
- class MyStack extends cdk.Stack {
208
- constructor(parent, id, props) {
209
- super(parent, id, {
210
- ...props,
211
- synthesizer: new DefaultStackSynthesizer({
212
- deployRoleAdditionalOptions: {
213
- Tags: [{ Key: 'Department', Value: 'Engineering' }]
214
- },
215
- fileAssetPublishingRoleAdditionalOptions: {
216
- Tags: [{ Key: 'Department', Value: 'Engineering' }]
217
- },
218
- imageAssetPublishingRoleAdditionalOptions: {
219
- Tags: [{ Key: 'Department', Value: 'Engineering' }]
220
- },
221
- lookupRoleAdditionalOptions: {
222
- Tags: [{ Key: 'Department', Value: 'Engineering' }]
223
- },
224
- })
225
- });
226
- }
227
- }
228
- ```
229
-
230
- This will cause the CDK CLI to include session tags when assuming each of these roles during deployment.
231
- Note that the trust policy of the role must contain permissions for the `sts:TagSession` action.
232
-
233
- > See https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_permissions-required
234
-
235
- - If you are using a custom bootstrap template, make sure the template includes these permissions.
236
- - If you are using the default bootstrap template from a CDK version lower than XXXX, you will need to rebootstrap your enviroment (once).
237
-
238
- ## Nested Stacks
239
-
240
- [Nested stacks](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-nested-stacks.html) are stacks created as part of other stacks. You create a nested stack within another stack by using the `NestedStack` construct.
241
-
242
- As your infrastructure grows, common patterns can emerge in which you declare the same components in multiple templates. You can separate out these common components and create dedicated templates for them. Then use the resource in your template to reference other templates, creating nested stacks.
243
-
244
- For example, assume that you have a load balancer configuration that you use for most of your stacks. Instead of copying and pasting the same configurations into your templates, you can create a dedicated template for the load balancer. Then, you just use the resource to reference that template from within other templates.
245
-
246
- The following example will define a single top-level stack that contains two nested stacks: each one with a single Amazon S3 bucket:
247
-
248
- ```ts
249
- class MyNestedStack extends cfn.NestedStack {
250
- constructor(scope: Construct, id: string, props?: cfn.NestedStackProps) {
251
- super(scope, id, props);
252
-
253
- new s3.Bucket(this, 'NestedBucket');
254
- }
255
- }
256
-
257
- class MyParentStack extends Stack {
258
- constructor(scope: Construct, id: string, props?: StackProps) {
259
- super(scope, id, props);
260
-
261
- new MyNestedStack(this, 'Nested1');
262
- new MyNestedStack(this, 'Nested2');
263
- }
264
- }
265
- ```
266
-
267
- Resources references across nested/parent boundaries (even with multiple levels of nesting) will be wired by the AWS CDK
268
- through CloudFormation parameters and outputs. When a resource from a parent stack is referenced by a nested stack,
269
- a CloudFormation parameter will automatically be added to the nested stack and assigned from the parent; when a resource
270
- from a nested stack is referenced by a parent stack, a CloudFormation output will be automatically be added to the
271
- nested stack and referenced using `Fn::GetAtt "Outputs.Xxx"` from the parent.
272
-
273
- Nested stacks also support the use of Docker image and file assets.
274
-
275
- ## Accessing resources in a different stack
276
-
277
- You can access resources in a different stack, as long as they are in the
278
- same account and AWS Region (see [next section](#accessing-resources-in-a-different-stack-and-region) for an exception).
279
- The following example defines the stack `stack1`,
280
- which defines an Amazon S3 bucket. Then it defines a second stack, `stack2`,
281
- which takes the bucket from stack1 as a constructor property.
282
-
283
- ```ts
284
- const prod = { account: '123456789012', region: 'us-east-1' };
285
-
286
- const stack1 = new StackThatProvidesABucket(app, 'Stack1' , { env: prod });
287
-
288
- // stack2 will take a property { bucket: IBucket }
289
- const stack2 = new StackThatExpectsABucket(app, 'Stack2', {
290
- bucket: stack1.bucket,
291
- env: prod
292
- });
293
- ```
294
-
295
- If the AWS CDK determines that the resource is in the same account and
296
- Region, but in a different stack, it automatically synthesizes AWS
297
- CloudFormation
298
- [Exports](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-exports.html)
299
- in the producing stack and an
300
- [Fn::ImportValue](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html)
301
- in the consuming stack to transfer that information from one stack to the
302
- other.
303
-
304
- ## Accessing resources in a different stack and region
305
-
306
- > **This feature is currently experimental**
307
-
308
- You can enable the Stack property `crossRegionReferences`
309
- in order to access resources in a different stack _and_ region. With this feature flag
310
- enabled it is possible to do something like creating a CloudFront distribution in `us-east-2` and
311
- an ACM certificate in `us-east-1`.
312
-
313
- ```ts
314
- const stack1 = new Stack(app, 'Stack1', {
315
- env: {
316
- region: 'us-east-1',
317
- },
318
- crossRegionReferences: true,
319
- });
320
- const cert = new acm.Certificate(stack1, 'Cert', {
321
- domainName: '*.example.com',
322
- validation: acm.CertificateValidation.fromDns(route53.PublicHostedZone.fromHostedZoneId(stack1, 'Zone', 'Z0329774B51CGXTDQV3X')),
323
- });
324
-
325
- const stack2 = new Stack(app, 'Stack2', {
326
- env: {
327
- region: 'us-east-2',
328
- },
329
- crossRegionReferences: true,
330
- });
331
- new cloudfront.Distribution(stack2, 'Distribution', {
332
- defaultBehavior: {
333
- origin: new origins.HttpOrigin('example.com'),
334
- },
335
- domainNames: ['dev.example.com'],
336
- certificate: cert,
337
- });
338
- ```
339
-
340
- When the AWS CDK determines that the resource is in a different stack _and_ is in a different
341
- region, it will "export" the value by creating a custom resource in the producing stack which
342
- creates SSM Parameters in the consuming region for each exported value. The parameters will be
343
- created with the name '/cdk/exports/${consumingStackName}/${export-name}'.
344
- In order to "import" the exports into the consuming stack a [SSM Dynamic reference](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html#dynamic-references-ssm)
345
- is used to reference the SSM parameter which was created.
346
-
347
- In order to mimic strong references, a Custom Resource is also created in the consuming
348
- stack which marks the SSM parameters as being "imported". When a parameter has been successfully
349
- imported, the producing stack cannot update the value.
350
-
351
- See the [adr](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/core/adr/cross-region-stack-references.md)
352
- for more details on this feature.
353
-
354
- ### Removing automatic cross-stack references
355
-
356
- The automatic references created by CDK when you use resources across stacks
357
- are convenient, but may block your deployments if you want to remove the
358
- resources that are referenced in this way. You will see an error like:
359
-
360
- ```text
361
- Export Stack1:ExportsOutputFnGetAtt-****** cannot be deleted as it is in use by Stack1
362
- ```
363
-
364
- Let's say there is a Bucket in the `stack1`, and the `stack2` references its
365
- `bucket.bucketName`. You now want to remove the bucket and run into the error above.
366
-
367
- It's not safe to remove `stack1.bucket` while `stack2` is still using it, so
368
- unblocking yourself from this is a two-step process. This is how it works:
369
-
370
- DEPLOYMENT 1: break the relationship
371
-
372
- - Make sure `stack2` no longer references `bucket.bucketName` (maybe the consumer
373
- stack now uses its own bucket, or it writes to an AWS DynamoDB table, or maybe you just
374
- remove the Lambda Function altogether).
375
- - In the `stack1` class, call `this.exportValue(this.bucket.bucketName)`. This
376
- will make sure the CloudFormation Export continues to exist while the relationship
377
- between the two stacks is being broken.
378
- - Deploy (this will effectively only change the `stack2`, but it's safe to deploy both).
379
-
380
- DEPLOYMENT 2: remove the resource
381
-
382
- - You are now free to remove the `bucket` resource from `stack1`.
383
- - Don't forget to remove the `exportValue()` call as well.
384
- - Deploy again (this time only the `stack1` will be changed -- the bucket will be deleted).
385
-
386
- ## Durations
387
-
388
- To make specifications of time intervals unambiguous, a single class called
389
- `Duration` is used throughout the AWS Construct Library by all constructs
390
- that that take a time interval as a parameter (be it for a timeout, a
391
- rate, or something else).
392
-
393
- An instance of Duration is constructed by using one of the static factory
394
- methods on it:
395
-
396
- ```ts
397
- Duration.seconds(300) // 5 minutes
398
- Duration.minutes(5) // 5 minutes
399
- Duration.hours(1) // 1 hour
400
- Duration.days(7) // 7 days
401
- Duration.parse('PT5M') // 5 minutes
402
- ```
403
-
404
- Durations can be added or subtracted together:
405
-
406
- ```ts
407
- Duration.minutes(1).plus(Duration.seconds(60)); // 2 minutes
408
- Duration.minutes(5).minus(Duration.seconds(10)); // 290 secondes
409
- ```
410
-
411
- ## Size (Digital Information Quantity)
412
-
413
- To make specification of digital storage quantities unambiguous, a class called
414
- `Size` is available.
415
-
416
- An instance of `Size` is initialized through one of its static factory methods:
417
-
418
- ```ts
419
- Size.kibibytes(200) // 200 KiB
420
- Size.mebibytes(5) // 5 MiB
421
- Size.gibibytes(40) // 40 GiB
422
- Size.tebibytes(200) // 200 TiB
423
- Size.pebibytes(3) // 3 PiB
424
- ```
425
-
426
- Instances of `Size` created with one of the units can be converted into others.
427
- By default, conversion to a higher unit will fail if the conversion does not produce
428
- a whole number. This can be overridden by unsetting `integral` property.
429
-
430
- ```ts
431
- Size.mebibytes(2).toKibibytes() // yields 2048
432
- Size.kibibytes(2050).toMebibytes({ rounding: SizeRoundingBehavior.FLOOR }) // yields 2
433
- ```
434
-
435
- ## Secrets
436
-
437
- To help avoid accidental storage of secrets as plain text, we use the `SecretValue` type to
438
- represent secrets. Any construct that takes a value that should be a secret (such as
439
- a password or an access key) will take a parameter of type `SecretValue`.
440
-
441
- The best practice is to store secrets in AWS Secrets Manager and reference them using `SecretValue.secretsManager`:
442
-
443
- ```ts
444
- const secret = SecretValue.secretsManager('secretId', {
445
- jsonField: 'password', // optional: key of a JSON field to retrieve (defaults to all content),
446
- versionId: 'id', // optional: id of the version (default AWSCURRENT)
447
- versionStage: 'stage', // optional: version stage name (default AWSCURRENT)
448
- });
449
- ```
450
-
451
- Using AWS Secrets Manager is the recommended way to reference secrets in a CDK app.
452
- `SecretValue` also supports the following secret sources:
453
-
454
- - `SecretValue.unsafePlainText(secret)`: stores the secret as plain text in your app and the resulting template (not recommended).
455
- - `SecretValue.secretsManager(secret)`: refers to a secret stored in Secrets Manager
456
- - `SecretValue.ssmSecure(param, version)`: refers to a secret stored as a SecureString in the SSM
457
- Parameter Store. If you don't specify the exact version, AWS CloudFormation uses the latest
458
- version of the parameter.
459
- - `SecretValue.cfnParameter(param)`: refers to a secret passed through a CloudFormation parameter (must have `NoEcho: true`).
460
- - `SecretValue.cfnDynamicReference(dynref)`: refers to a secret described by a CloudFormation dynamic reference (used by `ssmSecure` and `secretsManager`).
461
- - `SecretValue.resourceAttribute(attr)`: refers to a secret returned from a CloudFormation resource creation.
462
-
463
- `SecretValue`s should only be passed to constructs that accept properties of type
464
- `SecretValue`. These constructs are written to ensure your secrets will not be
465
- exposed where they shouldn't be. If you try to use a `SecretValue` in a
466
- different location, an error about unsafe secret usage will be thrown at
467
- synthesis time.
468
-
469
- If you rotate the secret's value in Secrets Manager, you must also change at
470
- least one property on the resource where you are using the secret, to force
471
- CloudFormation to re-read the secret.
472
-
473
- `SecretValue.ssmSecure()` is only supported for a limited set of resources.
474
- [Click here for a list of supported resources and properties](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html#template-parameters-dynamic-patterns-resources).
475
-
476
- ## ARN manipulation
477
-
478
- Sometimes you will need to put together or pick apart Amazon Resource Names
479
- (ARNs). The functions `stack.formatArn()` and `stack.splitArn()` exist for
480
- this purpose.
481
-
482
- `formatArn()` can be used to build an ARN from components. It will automatically
483
- use the region and account of the stack you're calling it on:
484
-
485
- ```ts
486
- declare const stack: Stack;
487
-
488
- // Builds "arn:<PARTITION>:lambda:<REGION>:<ACCOUNT>:function:MyFunction"
489
- stack.formatArn({
490
- service: 'lambda',
491
- resource: 'function',
492
- arnFormat: ArnFormat.COLON_RESOURCE_NAME,
493
- resourceName: 'MyFunction'
494
- });
495
- ```
496
-
497
- `splitArn()` can be used to get a single component from an ARN. `splitArn()`
498
- will correctly deal with both literal ARNs and deploy-time values (tokens),
499
- but in case of a deploy-time value be aware that the result will be another
500
- deploy-time value which cannot be inspected in the CDK application.
501
-
502
- ```ts
503
- declare const stack: Stack;
504
-
505
- // Extracts the function name out of an AWS Lambda Function ARN
506
- const arnComponents = stack.splitArn(arn, ArnFormat.COLON_RESOURCE_NAME);
507
- const functionName = arnComponents.resourceName;
508
- ```
509
-
510
- Note that the format of the resource separator depends on the service and
511
- may be any of the values supported by `ArnFormat`. When dealing with these
512
- functions, it is important to know the format of the ARN you are dealing with.
513
-
514
- For an exhaustive list of ARN formats used in AWS, see [AWS ARNs and
515
- Namespaces](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html)
516
- in the AWS General Reference.
517
-
518
- ## Dependencies
519
-
520
- ### Construct Dependencies
521
-
522
- Sometimes AWS resources depend on other resources, and the creation of one
523
- resource must be completed before the next one can be started.
524
-
525
- In general, CloudFormation will correctly infer the dependency relationship
526
- between resources based on the property values that are used. In the cases where
527
- it doesn't, the AWS Construct Library will add the dependency relationship for
528
- you.
529
-
530
- If you need to add an ordering dependency that is not automatically inferred,
531
- you do so by adding a dependency relationship using
532
- `constructA.node.addDependency(constructB)`. This will add a dependency
533
- relationship between all resources in the scope of `constructA` and all
534
- resources in the scope of `constructB`.
535
-
536
- If you want a single object to represent a set of constructs that are not
537
- necessarily in the same scope, you can use a `DependencyGroup`. The
538
- following creates a single object that represents a dependency on two
539
- constructs, `constructB` and `constructC`:
540
-
541
- ```ts
542
- // Declare the dependable object
543
- const bAndC = new DependencyGroup();
544
- bAndC.add(constructB);
545
- bAndC.add(constructC);
546
-
547
- // Take the dependency
548
- constructA.node.addDependency(bAndC);
549
- ```
550
-
551
- ### Stack Dependencies
552
-
553
- Two different stack instances can have a dependency on one another. This
554
- happens when an resource from one stack is referenced in another stack. In
555
- that case, CDK records the cross-stack referencing of resources,
556
- automatically produces the right CloudFormation primitives, and adds a
557
- dependency between the two stacks. You can also manually add a dependency
558
- between two stacks by using the `stackA.addDependency(stackB)` method.
559
-
560
- A stack dependency has the following implications:
561
-
562
- - Cyclic dependencies are not allowed, so if `stackA` is using resources from
563
- `stackB`, the reverse is not possible anymore.
564
- - Stacks with dependencies between them are treated specially by the CDK
565
- toolkit:
566
- - If `stackA` depends on `stackB`, running `cdk deploy stackA` will also
567
- automatically deploy `stackB`.
568
- - `stackB`'s deployment will be performed *before* `stackA`'s deployment.
569
-
570
- ### CfnResource Dependencies
571
-
572
- To make declaring dependencies between `CfnResource` objects easier, you can declare dependencies from one `CfnResource` object on another by using the `cfnResource1.addDependency(cfnResource2)` method. This method will work for resources both within the same stack and across stacks as it detects the relative location of the two resources and adds the dependency either to the resource or between the relevant stacks, as appropriate. If more complex logic is in needed, you can similarly remove, replace, or view dependencies between `CfnResource` objects with the `CfnResource` `removeDependency`, `replaceDependency`, and `obtainDependencies` methods, respectively.
573
-
574
- ## Custom Resources
575
-
576
- Custom Resources are CloudFormation resources that are implemented by arbitrary
577
- user code. They can do arbitrary lookups or modifications during a
578
- CloudFormation deployment.
579
-
580
- Custom resources are backed by *custom resource providers*. Commonly, these are
581
- Lambda Functions that are deployed in the same deployment as the one that
582
- defines the custom resource itself, but they can also be backed by Lambda
583
- Functions deployed previously, or code responding to SNS Topic events running on
584
- EC2 instances in a completely different account. For more information on custom
585
- resource providers, see the next section.
586
-
587
- Once you have a provider, each definition of a `CustomResource` construct
588
- represents one invocation. A single provider can be used for the implementation
589
- of arbitrarily many custom resource definitions. A single definition looks like
590
- this:
591
-
592
- ```ts
593
- new CustomResource(this, 'MyMagicalResource', {
594
- resourceType: 'Custom::MyCustomResource', // must start with 'Custom::'
595
-
596
- // the resource properties
597
- // properties like serviceToken or serviceTimeout are ported into properties automatically
598
- // try not to use key names similar to these or there will be a risk of overwriting those values
599
- properties: {
600
- Property1: 'foo',
601
- Property2: 'bar',
602
- },
603
-
604
- // the ARN of the provider (SNS/Lambda) which handles
605
- // CREATE, UPDATE or DELETE events for this resource type
606
- // see next section for details
607
- serviceToken: 'ARN',
608
-
609
- // the maximum time, in seconds, that can elapse before a custom resource operation times out.
610
- serviceTimeout: Duration.seconds(60),
611
- });
612
- ```
613
-
614
- ### Custom Resource Providers
615
-
616
- Custom resources are backed by a **custom resource provider** which can be
617
- implemented in one of the following ways. The following table compares the
618
- various provider types (ordered from low-level to high-level):
619
-
620
- | Provider | Compute Type | Error Handling | Submit to CloudFormation | Max Timeout | Language | Footprint |
621
- | -------------------------------------------------------------------- | :----------: | :------------: | :----------------------: | :-------------: | :------: | :-------: |
622
- | [sns.Topic](#amazon-sns-topic) | Self-managed | Manual | Manual | Unlimited | Any | Depends |
623
- | [lambda.Function](#aws-lambda-function) | AWS Lambda | Manual | Manual | 15min | Any | Small |
624
- | [core.CustomResourceProvider](#the-corecustomresourceprovider-class) | AWS Lambda | Auto | Auto | 15min | Node.js | Small |
625
- | [custom-resources.Provider](#the-custom-resource-provider-framework) | AWS Lambda | Auto | Auto | Unlimited Async | Any | Large |
626
-
627
- Legend:
628
-
629
- - **Compute type**: which type of compute can be used to execute the handler.
630
- - **Error Handling**: whether errors thrown by handler code are automatically
631
- trapped and a FAILED response is submitted to CloudFormation. If this is
632
- "Manual", developers must take care of trapping errors. Otherwise, events
633
- could cause stacks to hang.
634
- - **Submit to CloudFormation**: whether the framework takes care of submitting
635
- SUCCESS/FAILED responses to CloudFormation through the event's response URL.
636
- - **Max Timeout**: maximum allows/possible timeout.
637
- - **Language**: which programming languages can be used to implement handlers.
638
- - **Footprint**: how many resources are used by the provider framework itself.
639
-
640
- **A NOTE ABOUT SINGLETONS**
641
-
642
- When defining resources for a custom resource provider, you will likely want to
643
- define them as a *stack singleton* so that only a single instance of the
644
- provider is created in your stack and which is used by all custom resources of
645
- that type.
646
-
647
- Here is a basic pattern for defining stack singletons in the CDK. The following
648
- examples ensures that only a single SNS topic is defined:
649
-
650
- ```ts
651
- function getOrCreate(scope: Construct): sns.Topic {
652
- const stack = Stack.of(scope);
653
- const uniqueid = 'GloballyUniqueIdForSingleton'; // For example, a UUID from `uuidgen`
654
- const existing = stack.node.tryFindChild(uniqueid);
655
- if (existing) {
656
- return existing as sns.Topic;
657
- }
658
- return new sns.Topic(stack, uniqueid);
659
- }
660
- ```
661
-
662
- #### Amazon SNS Topic
663
-
664
- Every time a resource event occurs (CREATE/UPDATE/DELETE), an SNS notification
665
- is sent to the SNS topic. Users must process these notifications (e.g. through a
666
- fleet of worker hosts) and submit success/failure responses to the
667
- CloudFormation service.
668
-
669
- > You only need to use this type of provider if your custom resource cannot run on AWS Lambda, for reasons other than the 15
670
- > minute timeout. If you are considering using this type of provider because you want to write a custom resource provider that may need
671
- > to wait for more than 15 minutes for the API calls to stabilize, have a look at the [`custom-resources`](#the-custom-resource-provider-framework) module first.
672
- >
673
- > Refer to the [CloudFormation Custom Resource documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html) for information on the contract your custom resource needs to adhere to.
674
-
675
- Set `serviceToken` to `topic.topicArn` in order to use this provider:
676
-
677
- ```ts
678
- const topic = new sns.Topic(this, 'MyProvider');
679
-
680
- new CustomResource(this, 'MyResource', {
681
- serviceToken: topic.topicArn
682
- });
683
- ```
684
-
685
- #### AWS Lambda Function
686
-
687
- An AWS lambda function is called *directly* by CloudFormation for all resource
688
- events. The handler must take care of explicitly submitting a success/failure
689
- response to the CloudFormation service and handle various error cases.
690
-
691
- > **We do not recommend you use this provider type.** The CDK has wrappers around Lambda Functions that make them easier to work with.
692
- >
693
- > If you do want to use this provider, refer to the [CloudFormation Custom Resource documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html) for information on the contract your custom resource needs to adhere to.
694
-
695
- Set `serviceToken` to `lambda.functionArn` to use this provider:
696
-
697
- ```ts
698
- const fn = new lambda.SingletonFunction(this, 'MyProvider', functionProps);
699
-
700
- new CustomResource(this, 'MyResource', {
701
- serviceToken: fn.functionArn,
702
- });
703
- ```
704
-
705
- #### The `core.CustomResourceProvider` class
706
-
707
- The class [`@aws-cdk/core.CustomResourceProvider`] offers a basic low-level
708
- framework designed to implement simple and slim custom resource providers. It
709
- currently only supports Node.js-based user handlers, represents permissions as raw
710
- JSON blobs instead of `iam.PolicyStatement` objects, and it does not have
711
- support for asynchronous waiting (handler cannot exceed the 15min lambda
712
- timeout). The `CustomResourceProviderRuntime` supports runtime `nodejs12.x`,
713
- `nodejs14.x`, `nodejs16.x`, `nodejs18.x`.
714
-
715
- [`@aws-cdk/core.CustomResourceProvider`]: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.CustomResourceProvider.html
716
-
717
- > **As an application builder, we do not recommend you use this provider type.** This provider exists purely for custom resources that are part of the AWS Construct Library.
718
- >
719
- > The [`custom-resources`](#the-custom-resource-provider-framework) provider is more convenient to work with and more fully-featured.
720
-
721
- The provider has a built-in singleton method which uses the resource type as a
722
- stack-unique identifier and returns the service token:
723
-
724
- ```ts
725
- const serviceToken = CustomResourceProvider.getOrCreate(this, 'Custom::MyCustomResourceType', {
726
- codeDirectory: `${__dirname}/my-handler`,
727
- runtime: CustomResourceProviderRuntime.NODEJS_18_X,
728
- description: "Lambda function created by the custom resource provider",
729
- });
730
-
731
- new CustomResource(this, 'MyResource', {
732
- resourceType: 'Custom::MyCustomResourceType',
733
- serviceToken: serviceToken
734
- });
735
- ```
736
-
737
- The directory (`my-handler` in the above example) must include an `index.js` file. It cannot import
738
- external dependencies or files outside this directory. It must export an async
739
- function named `handler`. This function accepts the CloudFormation resource
740
- event object and returns an object with the following structure:
741
-
742
- ```js
743
- exports.handler = async function(event) {
744
- const id = event.PhysicalResourceId; // only for "Update" and "Delete"
745
- const props = event.ResourceProperties;
746
- const oldProps = event.OldResourceProperties; // only for "Update"s
747
-
748
- switch (event.RequestType) {
749
- case "Create":
750
- // ...
751
-
752
- case "Update":
753
- // ...
754
-
755
- // if an error is thrown, a FAILED response will be submitted to CFN
756
- throw new Error('Failed!');
757
-
758
- case "Delete":
759
- // ...
760
- }
761
-
762
- return {
763
- // (optional) the value resolved from `resource.ref`
764
- // defaults to "event.PhysicalResourceId" or "event.RequestId"
765
- PhysicalResourceId: "REF",
766
-
767
- // (optional) calling `resource.getAtt("Att1")` on the custom resource in the CDK app
768
- // will return the value "BAR".
769
- Data: {
770
- Att1: "BAR",
771
- Att2: "BAZ"
772
- },
773
-
774
- // (optional) user-visible message
775
- Reason: "User-visible message",
776
-
777
- // (optional) hides values from the console
778
- NoEcho: true
779
- };
780
- }
781
- ```
782
-
783
- Here is an complete example of a custom resource that summarizes two numbers:
784
-
785
- `sum-handler/index.js`:
786
-
787
- ```js
788
- exports.handler = async (e) => {
789
- return {
790
- Data: {
791
- Result: e.ResourceProperties.lhs + e.ResourceProperties.rhs,
792
- },
793
- };
794
- };
795
- ```
796
-
797
- `sum.ts`:
798
-
799
- ```ts nofixture
800
- import { Construct } from 'constructs';
801
- import {
802
- CustomResource,
803
- CustomResourceProvider,
804
- CustomResourceProviderRuntime,
805
- Token,
806
- } from 'aws-cdk-lib';
807
-
808
- export interface SumProps {
809
- readonly lhs: number;
810
- readonly rhs: number;
811
- }
812
-
813
- export class Sum extends Construct {
814
- public readonly result: number;
815
-
816
- constructor(scope: Construct, id: string, props: SumProps) {
817
- super(scope, id);
818
-
819
- const resourceType = 'Custom::Sum';
820
- const serviceToken = CustomResourceProvider.getOrCreate(this, resourceType, {
821
- codeDirectory: `${__dirname}/sum-handler`,
822
- runtime: CustomResourceProviderRuntime.NODEJS_18_X,
823
- });
824
-
825
- const resource = new CustomResource(this, 'Resource', {
826
- resourceType: resourceType,
827
- serviceToken: serviceToken,
828
- properties: {
829
- lhs: props.lhs,
830
- rhs: props.rhs
831
- }
832
- });
833
-
834
- this.result = Token.asNumber(resource.getAtt('Result'));
835
- }
836
- }
837
- ```
838
-
839
- Usage will look like this:
840
-
841
- ```ts fixture=README-custom-resource-provider
842
- const sum = new Sum(this, 'MySum', { lhs: 40, rhs: 2 });
843
- new CfnOutput(this, 'Result', { value: Token.asString(sum.result) });
844
- ```
845
-
846
- To access the ARN of the provider's AWS Lambda function role, use the `getOrCreateProvider()`
847
- built-in singleton method:
848
-
849
- ```ts
850
- const provider = CustomResourceProvider.getOrCreateProvider(this, 'Custom::MyCustomResourceType', {
851
- codeDirectory: `${__dirname}/my-handler`,
852
- runtime: CustomResourceProviderRuntime.NODEJS_18_X,
853
- });
854
-
855
- const roleArn = provider.roleArn;
856
- ```
857
-
858
- This role ARN can then be used in resource-based IAM policies.
859
-
860
- To add IAM policy statements to this role, use `addToRolePolicy()`:
861
-
862
- ```ts
863
- const provider = CustomResourceProvider.getOrCreateProvider(this, 'Custom::MyCustomResourceType', {
864
- codeDirectory: `${__dirname}/my-handler`,
865
- runtime: CustomResourceProviderRuntime.NODEJS_18_X,
866
- });
867
- provider.addToRolePolicy({
868
- Effect: 'Allow',
869
- Action: 's3:GetObject',
870
- Resource: '*',
871
- })
872
- ```
873
-
874
- Note that `addToRolePolicy()` uses direct IAM JSON policy blobs, *not* a
875
- `iam.PolicyStatement` object like you will see in the rest of the CDK.
876
-
877
- #### The Custom Resource Provider Framework
878
-
879
- The [`@aws-cdk/custom-resources`] module includes an advanced framework for
880
- implementing custom resource providers.
881
-
882
- [`@aws-cdk/custom-resources`]: https://docs.aws.amazon.com/cdk/api/latest/docs/custom-resources-readme.html
883
-
884
- Handlers are implemented as AWS Lambda functions, which means that they can be
885
- implemented in any Lambda-supported runtime. Furthermore, this provider has an
886
- asynchronous mode, which means that users can provide an `isComplete` lambda
887
- function which is called periodically until the operation is complete. This
888
- allows implementing providers that can take up to two hours to stabilize.
889
-
890
- Set `serviceToken` to `provider.serviceToken` to use this type of provider:
891
-
892
- ```ts
893
- const provider = new customresources.Provider(this, 'MyProvider', {
894
- onEventHandler,
895
- isCompleteHandler, // optional async waiter
896
- });
897
-
898
- new CustomResource(this, 'MyResource', {
899
- serviceToken: provider.serviceToken
900
- });
901
- ```
902
-
903
- See the [documentation](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-cdk-lib.custom_resources-readme.html) for more details.
904
-
905
- ## AWS CloudFormation features
906
-
907
- A CDK stack synthesizes to an AWS CloudFormation Template. This section
908
- explains how this module allows users to access low-level CloudFormation
909
- features when needed.
910
-
911
- ### Stack Outputs
912
-
913
- CloudFormation [stack outputs][cfn-stack-output] and exports are created using
914
- the `CfnOutput` class:
915
-
916
- ```ts
917
- new CfnOutput(this, 'OutputName', {
918
- value: myBucket.bucketName,
919
- description: 'The name of an S3 bucket', // Optional
920
- exportName: 'TheAwesomeBucket', // Registers a CloudFormation export named "TheAwesomeBucket"
921
- });
922
- ```
923
-
924
- You can also use the `exportValue` method to export values as stack outputs:
925
-
926
- ```ts
927
- declare const stack: Stack;
928
-
929
- stack.exportValue(myBucket.bucketName, {
930
- name: 'TheAwesomeBucket',
931
- description: 'The name of an S3 bucket',
932
- });
933
- ```
934
-
935
- [cfn-stack-output]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html
936
-
937
- ### Parameters
938
-
939
- CloudFormation templates support the use of [Parameters][cfn-parameters] to
940
- customize a template. They enable CloudFormation users to input custom values to
941
- a template each time a stack is created or updated. While the CDK design
942
- philosophy favors using build-time parameterization, users may need to use
943
- CloudFormation in a number of cases (for example, when migrating an existing
944
- stack to the AWS CDK).
945
-
946
- Template parameters can be added to a stack by using the `CfnParameter` class:
947
-
948
- ```ts
949
- new CfnParameter(this, 'MyParameter', {
950
- type: 'Number',
951
- default: 1337,
952
- // See the API reference for more configuration props
953
- });
954
- ```
955
-
956
- The value of parameters can then be obtained using one of the `value` methods.
957
- As parameters are only resolved at deployment time, the values obtained are
958
- placeholder tokens for the real value (`Token.isUnresolved()` would return `true`
959
- for those):
960
-
961
- ```ts
962
- const param = new CfnParameter(this, 'ParameterName', { /* config */ });
963
-
964
- // If the parameter is a String
965
- param.valueAsString;
966
-
967
- // If the parameter is a Number
968
- param.valueAsNumber;
969
-
970
- // If the parameter is a List
971
- param.valueAsList;
972
- ```
973
-
974
- [cfn-parameters]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html
975
-
976
- ### Pseudo Parameters
977
-
978
- CloudFormation supports a number of [pseudo parameters][cfn-pseudo-params],
979
- which resolve to useful values at deployment time. CloudFormation pseudo
980
- parameters can be obtained from static members of the `Aws` class.
981
-
982
- It is generally recommended to access pseudo parameters from the scope's `stack`
983
- instead, which guarantees the values produced are qualifying the designated
984
- stack, which is essential in cases where resources are shared cross-stack:
985
-
986
- ```ts
987
- // "this" is the current construct
988
- const stack = Stack.of(this);
989
-
990
- stack.account; // Returns the AWS::AccountId for this stack (or the literal value if known)
991
- stack.region; // Returns the AWS::Region for this stack (or the literal value if known)
992
- stack.partition; // Returns the AWS::Partition for this stack (or the literal value if known)
993
- ```
994
-
995
- [cfn-pseudo-params]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html
996
-
997
- ### Resource Options
998
-
999
- CloudFormation resources can also specify [resource
1000
- attributes][cfn-resource-attributes]. The `CfnResource` class allows
1001
- accessing those through the `cfnOptions` property:
1002
-
1003
- ```ts
1004
- const rawBucket = new s3.CfnBucket(this, 'Bucket', { /* ... */ });
1005
- // -or-
1006
- const rawBucketAlt = myBucket.node.defaultChild as s3.CfnBucket;
1007
-
1008
- // then
1009
- rawBucket.cfnOptions.condition = new CfnCondition(this, 'EnableBucket', { /* ... */ });
1010
- rawBucket.cfnOptions.metadata = {
1011
- metadataKey: 'MetadataValue',
1012
- };
1013
- ```
1014
-
1015
- Resource dependencies (the `DependsOn` attribute) is modified using the
1016
- `cfnResource.addDependency` method:
1017
-
1018
- ```ts
1019
- const resourceA = new CfnResource(this, 'ResourceA', resourceProps);
1020
- const resourceB = new CfnResource(this, 'ResourceB', resourceProps);
1021
-
1022
- resourceB.addDependency(resourceA);
1023
- ```
1024
-
1025
- [cfn-resource-attributes]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-product-attribute-reference.html
1026
-
1027
- #### CreationPolicy
1028
-
1029
- Some resources support a [CreationPolicy][creation-policy] to be specified as a CfnOption.
1030
-
1031
- The creation policy is invoked only when AWS CloudFormation creates the associated resource. Currently, the only AWS CloudFormation resources that support creation policies are `CfnAutoScalingGroup`, `CfnInstance`, `CfnWaitCondition` and `CfnFleet`.
1032
-
1033
- The `CfnFleet` resource from the `aws-appstream` module supports specifying `startFleet` as
1034
- a property of the creationPolicy on the resource options. Setting it to true will make AWS CloudFormation wait until the fleet is started before continuing with the creation of
1035
- resources that depend on the fleet resource.
1036
-
1037
- ```ts
1038
- const fleet = new appstream.CfnFleet(this, 'Fleet', {
1039
- instanceType: 'stream.standard.small',
1040
- name: 'Fleet',
1041
- computeCapacity: {
1042
- desiredInstances: 1,
1043
- },
1044
- imageName: 'AppStream-AmazonLinux2-09-21-2022',
1045
- });
1046
- fleet.cfnOptions.creationPolicy = {
1047
- startFleet: true,
1048
- };
1049
- ```
1050
-
1051
- The properties passed to the level 2 constructs `AutoScalingGroup` and `Instance` from the
1052
- `aws-ec2` module abstract what is passed into the `CfnOption` properties `resourceSignal` and
1053
- `autoScalingCreationPolicy`, but when using level 1 constructs you can specify these yourself.
1054
-
1055
- The CfnWaitCondition resource from the `aws-cloudformation` module suppports the `resourceSignal`.
1056
- The format of the timeout is `PT#H#M#S`. In the example below AWS Cloudformation will wait for
1057
- 3 success signals to occur within 15 minutes before the status of the resource will be set to
1058
- `CREATE_COMPLETE`.
1059
-
1060
- ```ts
1061
- declare const resource: CfnResource;
1062
-
1063
- resource.cfnOptions.creationPolicy = {
1064
- resourceSignal: {
1065
- count: 3,
1066
- timeout: 'PR15M',
1067
- }
1068
- };
1069
- ```
1070
-
1071
- [creation-policy]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-creationpolicy.html
1072
-
1073
- ### Intrinsic Functions and Condition Expressions
1074
-
1075
- CloudFormation supports [intrinsic functions][cfn-intrinsics]. These functions
1076
- can be accessed from the `Fn` class, which provides type-safe methods for each
1077
- intrinsic function as well as condition expressions:
1078
-
1079
- ```ts
1080
- declare const myObjectOrArray: any;
1081
- declare const myArray: any;
1082
-
1083
- // To use Fn::Base64
1084
- Fn.base64('SGVsbG8gQ0RLIQo=');
1085
-
1086
- // To compose condition expressions:
1087
- const environmentParameter = new CfnParameter(this, 'Environment');
1088
- Fn.conditionAnd(
1089
- // The "Environment" CloudFormation template parameter evaluates to "Production"
1090
- Fn.conditionEquals('Production', environmentParameter),
1091
- // The AWS::Region pseudo-parameter value is NOT equal to "us-east-1"
1092
- Fn.conditionNot(Fn.conditionEquals('us-east-1', Aws.REGION)),
1093
- );
1094
-
1095
- // To use Fn::ToJsonString
1096
- Fn.toJsonString(myObjectOrArray);
1097
-
1098
- // To use Fn::Length
1099
- Fn.len(Fn.split(',', myArray));
1100
- ```
1101
-
1102
- When working with deploy-time values (those for which `Token.isUnresolved`
1103
- returns `true`), idiomatic conditionals from the programming language cannot be
1104
- used (the value will not be known until deployment time). When conditional logic
1105
- needs to be expressed with un-resolved values, it is necessary to use
1106
- CloudFormation conditions by means of the `CfnCondition` class:
1107
-
1108
- ```ts
1109
- const environmentParameter = new CfnParameter(this, 'Environment');
1110
- const isProd = new CfnCondition(this, 'IsProduction', {
1111
- expression: Fn.conditionEquals('Production', environmentParameter),
1112
- });
1113
-
1114
- // Configuration value that is a different string based on IsProduction
1115
- const stage = Fn.conditionIf(isProd.logicalId, 'Beta', 'Prod').toString();
1116
-
1117
- // Make Bucket creation condition to IsProduction by accessing
1118
- // and overriding the CloudFormation resource
1119
- const bucket = new s3.Bucket(this, 'Bucket');
1120
- const cfnBucket = myBucket.node.defaultChild as s3.CfnBucket;
1121
- cfnBucket.cfnOptions.condition = isProd;
1122
- ```
1123
-
1124
- [cfn-intrinsics]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
1125
-
1126
- ### Mappings
1127
-
1128
- CloudFormation [mappings][cfn-mappings] are created and queried using the
1129
- `CfnMappings` class:
1130
-
1131
- ```ts
1132
- const regionTable = new CfnMapping(this, 'RegionTable', {
1133
- mapping: {
1134
- 'us-east-1': {
1135
- regionName: 'US East (N. Virginia)',
1136
- // ...
1137
- },
1138
- 'us-east-2': {
1139
- regionName: 'US East (Ohio)',
1140
- // ...
1141
- },
1142
- // ...
1143
- }
1144
- });
1145
-
1146
- regionTable.findInMap(Aws.REGION, 'regionName')
1147
- ```
1148
-
1149
- This will yield the following template:
1150
-
1151
- ```yaml
1152
- Mappings:
1153
- RegionTable:
1154
- us-east-1:
1155
- regionName: US East (N. Virginia)
1156
- us-east-2:
1157
- regionName: US East (Ohio)
1158
- ```
1159
-
1160
- Mappings can also be synthesized "lazily"; lazy mappings will only render a "Mappings"
1161
- section in the synthesized CloudFormation template if some `findInMap` call is unable to
1162
- immediately return a concrete value due to one or both of the keys being unresolved tokens
1163
- (some value only available at deploy-time).
1164
-
1165
- For example, the following code will not produce anything in the "Mappings" section. The
1166
- call to `findInMap` will be able to resolve the value during synthesis and simply return
1167
- `'US East (Ohio)'`.
1168
-
1169
- ```ts
1170
- const regionTable = new CfnMapping(this, 'RegionTable', {
1171
- mapping: {
1172
- 'us-east-1': {
1173
- regionName: 'US East (N. Virginia)',
1174
- },
1175
- 'us-east-2': {
1176
- regionName: 'US East (Ohio)',
1177
- },
1178
- },
1179
- lazy: true,
1180
- });
1181
-
1182
- regionTable.findInMap('us-east-2', 'regionName');
1183
- ```
1184
-
1185
- On the other hand, the following code will produce the "Mappings" section shown above,
1186
- since the top-level key is an unresolved token. The call to `findInMap` will return a token that resolves to
1187
- `{ "Fn::FindInMap": [ "RegionTable", { "Ref": "AWS::Region" }, "regionName" ] }`.
1188
-
1189
- ```ts
1190
- declare const regionTable: CfnMapping;
1191
-
1192
- regionTable.findInMap(Aws.REGION, 'regionName');
1193
- ```
1194
-
1195
- An optional default value can also be passed to `findInMap`. If either key is not found in the map and the mapping is lazy, `findInMap` will return the default value and not render the mapping.
1196
- If the mapping is not lazy or either key is an unresolved token, the call to `findInMap` will return a token that resolves to
1197
- `{ "Fn::FindInMap": [ "MapName", "TopLevelKey", "SecondLevelKey", { "DefaultValue": "DefaultValue" } ] }`, and the mapping will be rendered.
1198
- Note that the `AWS::LanguageExtentions` transform is added to enable the default value functionality.
1199
-
1200
- For example, the following code will again not produce anything in the "Mappings" section. The
1201
- call to `findInMap` will be able to resolve the value during synthesis and simply return
1202
- `'Region not found'`.
1203
-
1204
- ```ts
1205
- const regionTable = new CfnMapping(this, 'RegionTable', {
1206
- mapping: {
1207
- 'us-east-1': {
1208
- regionName: 'US East (N. Virginia)',
1209
- },
1210
- 'us-east-2': {
1211
- regionName: 'US East (Ohio)',
1212
- },
1213
- },
1214
- lazy: true,
1215
- });
1216
-
1217
- regionTable.findInMap('us-west-1', 'regionName', 'Region not found');
1218
- ```
1219
-
1220
- [cfn-mappings]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.html
1221
-
1222
- ### Dynamic References
1223
-
1224
- CloudFormation supports [dynamically resolving][cfn-dynamic-references] values
1225
- for SSM parameters (including secure strings) and Secrets Manager. Encoding such
1226
- references is done using the `CfnDynamicReference` class:
1227
-
1228
- ```ts
1229
- new CfnDynamicReference(
1230
- CfnDynamicReferenceService.SECRETS_MANAGER,
1231
- 'secret-id:secret-string:json-key:version-stage:version-id',
1232
- );
1233
- ```
1234
-
1235
- [cfn-dynamic-references]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html
1236
-
1237
- ### Template Options & Transform
1238
-
1239
- CloudFormation templates support a number of options, including which Macros or
1240
- [Transforms][cfn-transform] to use when deploying the stack. Those can be
1241
- configured using the `stack.templateOptions` property:
1242
-
1243
- ```ts
1244
- const stack = new Stack(app, 'StackName');
1245
-
1246
- stack.templateOptions.description = 'This will appear in the AWS console';
1247
- stack.templateOptions.transforms = ['AWS::Serverless-2016-10-31'];
1248
- stack.templateOptions.metadata = {
1249
- metadataKey: 'MetadataValue',
1250
- };
1251
- ```
1252
-
1253
- [cfn-transform]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html
1254
-
1255
- ### Emitting Raw Resources
1256
-
1257
- The `CfnResource` class allows emitting arbitrary entries in the
1258
- [Resources][cfn-resources] section of the CloudFormation template.
1259
-
1260
- ```ts
1261
- new CfnResource(this, 'ResourceId', {
1262
- type: 'AWS::S3::Bucket',
1263
- properties: {
1264
- BucketName: 'amzn-s3-demo-bucket'
1265
- },
1266
- });
1267
- ```
1268
-
1269
- As for any other resource, the logical ID in the CloudFormation template will be
1270
- generated by the AWS CDK, but the type and properties will be copied verbatim in
1271
- the synthesized template.
1272
-
1273
- [cfn-resources]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html
1274
-
1275
- ### Including raw CloudFormation template fragments
1276
-
1277
- When migrating a CloudFormation stack to the AWS CDK, it can be useful to
1278
- include fragments of an existing template verbatim in the synthesized template.
1279
- This can be achieved using the `CfnInclude` class.
1280
-
1281
- ```ts
1282
- new CfnInclude(this, 'ID', {
1283
- template: {
1284
- Resources: {
1285
- Bucket: {
1286
- Type: 'AWS::S3::Bucket',
1287
- Properties: {
1288
- BucketName: 'my-shiny-bucket'
1289
- }
1290
- }
1291
- }
1292
- },
1293
- });
1294
- ```
1295
-
1296
- ### Termination Protection
1297
-
1298
- You can prevent a stack from being accidentally deleted by enabling termination
1299
- protection on the stack. If a user attempts to delete a stack with termination
1300
- protection enabled, the deletion fails and the stack--including its status--remains
1301
- unchanged. Enabling or disabling termination protection on a stack sets it for any
1302
- nested stacks belonging to that stack as well. You can enable termination protection
1303
- on a stack by setting the `terminationProtection` prop to `true`.
1304
-
1305
- ```ts
1306
- const stack = new Stack(app, 'StackName', {
1307
- terminationProtection: true,
1308
- });
1309
- ```
1310
-
1311
- You can also set termination protection with the setter after you've instantiated the stack.
1312
-
1313
- ```ts
1314
- const stack = new Stack(app, 'StackName', {});
1315
- stack.terminationProtection = true;
1316
- ```
1317
-
1318
- By default, termination protection is disabled.
1319
-
1320
- ### Description
1321
-
1322
- You can add a description of the stack in the same way as `StackProps`.
1323
-
1324
- ```ts
1325
- const stack = new Stack(app, 'StackName', {
1326
- description: 'This is a description.',
1327
- });
1328
- ```
1329
-
1330
- ### Receiving CloudFormation Stack Events
1331
-
1332
- You can add one or more SNS Topic ARNs to any Stack:
1333
-
1334
- ```ts
1335
- const stack = new Stack(app, 'StackName', {
1336
- notificationArns: ['arn:aws:sns:us-east-1:23456789012:Topic'],
1337
- });
1338
- ```
1339
-
1340
- Stack events will be sent to any SNS Topics in this list. These ARNs are added to those specified using
1341
- the `--notification-arns` command line option.
1342
-
1343
- Note that in order to do delete notification ARNs entirely, you must pass an empty array ([]) instead of omitting it.
1344
- If you omit the property, no action on existing ARNs will take place.
1345
-
1346
- > [!NOTICE]
1347
- > Adding the `notificationArns` property (or using the `--notification-arns` CLI options) will **override**
1348
- > any existing ARNs configured on the stack. If you have an external system managing notification ARNs,
1349
- > either migrate to use this mechanism, or avoid specfying notification ARNs with the CDK.
1350
-
1351
- ### CfnJson
1352
-
1353
- `CfnJson` allows you to postpone the resolution of a JSON blob from
1354
- deployment-time. This is useful in cases where the CloudFormation JSON template
1355
- cannot express a certain value.
1356
-
1357
- A common example is to use `CfnJson` in order to render a JSON map which needs
1358
- to use intrinsic functions in keys. Since JSON map keys must be strings, it is
1359
- impossible to use intrinsics in keys and `CfnJson` can help.
1360
-
1361
- The following example defines an IAM role which can only be assumed by
1362
- principals that are tagged with a specific tag.
1363
-
1364
- ```ts
1365
- const tagParam = new CfnParameter(this, 'TagName');
1366
-
1367
- const stringEquals = new CfnJson(this, 'ConditionJson', {
1368
- value: {
1369
- [`aws:PrincipalTag/${tagParam.valueAsString}`]: true,
1370
- },
1371
- });
1372
-
1373
- const principal = new iam.AccountRootPrincipal().withConditions({
1374
- StringEquals: stringEquals,
1375
- });
1376
-
1377
- new iam.Role(this, 'MyRole', { assumedBy: principal });
1378
- ```
1379
-
1380
- **Explanation**: since in this example we pass the tag name through a parameter, it
1381
- can only be resolved during deployment. The resolved value can be represented in
1382
- the template through a `{ "Ref": "TagName" }`. However, since we want to use
1383
- this value inside a [`aws:PrincipalTag/TAG-NAME`](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-principaltag)
1384
- IAM operator, we need it in the *key* of a `StringEquals` condition. JSON keys
1385
- *must be* strings, so to circumvent this limitation, we use `CfnJson`
1386
- to "delay" the rendition of this template section to deploy-time. This means
1387
- that the value of `StringEquals` in the template will be `{ "Fn::GetAtt": [ "ConditionJson", "Value" ] }`, and will only "expand" to the operator we synthesized during deployment.
1388
-
1389
- ### Stack Resource Limit
1390
-
1391
- When deploying to AWS CloudFormation, it needs to keep in check the amount of resources being added inside a Stack. Currently it's possible to check the limits in the [AWS CloudFormation quotas](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html) page.
1392
-
1393
- It's possible to synthesize the project with more Resources than the allowed (or even reduce the number of Resources).
1394
-
1395
- Set the context key `@aws-cdk/core:stackResourceLimit` with the proper value, being 0 for disable the limit of resources.
1396
-
1397
- ### Template Indentation
1398
-
1399
- The AWS CloudFormation templates generated by CDK include indentation by default.
1400
- Indentation makes the templates more readable, but also increases their size,
1401
- and CloudFormation templates cannot exceed 1MB.
1402
-
1403
- It's possible to reduce the size of your templates by suppressing indentation.
1404
-
1405
- To do this for all templates, set the context key `@aws-cdk/core:suppressTemplateIndentation` to `true`.
1406
-
1407
- To do this for a specific stack, add a `suppressTemplateIndentation: true` property to the
1408
- stack's `StackProps` parameter. You can also set this property to `false` to override
1409
- the context key setting.
1410
-
1411
- ## App Context
1412
-
1413
- [Context values](https://docs.aws.amazon.com/cdk/v2/guide/context.html) are key-value pairs that can be associated with an app, stack, or construct.
1414
- One common use case for context is to use it for enabling/disabling [feature flags](https://docs.aws.amazon.com/cdk/v2/guide/featureflags.html). There are several places
1415
- where context can be specified. They are listed below in the order they are evaluated (items at the
1416
- top take precedence over those below).
1417
-
1418
- - The `node.setContext()` method
1419
- - The `postCliContext` prop when you create an `App`
1420
- - The CLI via the `--context` CLI argument
1421
- - The `cdk.json` file via the `context` key:
1422
- - The `cdk.context.json` file:
1423
- - The `~/.cdk.json` file via the `context` key:
1424
- - The `context` prop when you create an `App`
1425
-
1426
- ### Examples of setting context
1427
-
1428
- ```ts
1429
- new App({
1430
- context: {
1431
- '@aws-cdk/core:newStyleStackSynthesis': true,
1432
- },
1433
- });
1434
- ```
1435
-
1436
- ```ts
1437
- const app = new App();
1438
- app.node.setContext('@aws-cdk/core:newStyleStackSynthesis', true);
1439
- ```
1440
-
1441
- ```ts
1442
- new App({
1443
- postCliContext: {
1444
- '@aws-cdk/core:newStyleStackSynthesis': true,
1445
- },
1446
- });
1447
- ```
1448
-
1449
- ```console
1450
- cdk synth --context @aws-cdk/core:newStyleStackSynthesis=true
1451
- ```
1452
-
1453
- _cdk.json_
1454
-
1455
- ```json
1456
- {
1457
- "context": {
1458
- "@aws-cdk/core:newStyleStackSynthesis": true
1459
- }
1460
- }
1461
- ```
1462
-
1463
- _cdk.context.json_
1464
-
1465
- ```json
1466
- {
1467
- "@aws-cdk/core:newStyleStackSynthesis": true
1468
- }
1469
- ```
1470
-
1471
- _~/.cdk.json_
1472
-
1473
- ```json
1474
- {
1475
- "context": {
1476
- "@aws-cdk/core:newStyleStackSynthesis": true
1477
- }
1478
- }
1479
- ```
1480
-
1481
- ## IAM Permissions Boundary
1482
-
1483
- It is possible to apply an [IAM permissions boundary](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html)
1484
- to all roles within a specific construct scope. The most common use case would
1485
- be to apply a permissions boundary at the `Stage` level.
1486
-
1487
- ```ts
1488
- const prodStage = new Stage(app, 'ProdStage', {
1489
- permissionsBoundary: PermissionsBoundary.fromName('cdk-${Qualifier}-PermissionsBoundary'),
1490
- });
1491
- ```
1492
-
1493
- Any IAM Roles or Users created within this Stage will have the default
1494
- permissions boundary attached.
1495
-
1496
- For more details see the [Permissions Boundary](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam-readme.html#permissions-boundaries) section in the IAM guide.
1497
-
1498
- ## Policy Validation
1499
-
1500
- If you or your organization use (or would like to use) any policy validation tool, such as
1501
- [CloudFormation
1502
- Guard](https://docs.aws.amazon.com/cfn-guard/latest/ug/what-is-guard.html) or
1503
- [OPA](https://www.openpolicyagent.org/), to define constraints on your
1504
- CloudFormation template, you can incorporate them into the CDK application.
1505
- By using the appropriate plugin, you can make the CDK application check the
1506
- generated CloudFormation templates against your policies immediately after
1507
- synthesis. If there are any violations, the synthesis will fail and a report
1508
- will be printed to the console or to a file (see below).
1509
-
1510
- > **Note**
1511
- > This feature is considered experimental, and both the plugin API and the
1512
- > format of the validation report are subject to change in the future.
1513
-
1514
- ### For application developers
1515
-
1516
- To use one or more validation plugins in your application, use the
1517
- `policyValidationBeta1` property of `Stage`:
1518
-
1519
- ```ts fixture=validation-plugin
1520
- // globally for the entire app (an app is a stage)
1521
- const app = new App({
1522
- policyValidationBeta1: [
1523
- // These hypothetical classes implement IPolicyValidationPluginBeta1:
1524
- new ThirdPartyPluginX(),
1525
- new ThirdPartyPluginY(),
1526
- ],
1527
- });
1528
-
1529
- // only apply to a particular stage
1530
- const prodStage = new Stage(app, 'ProdStage', {
1531
- policyValidationBeta1: [
1532
- new ThirdPartyPluginX(),
1533
- ],
1534
- });
1535
- ```
1536
-
1537
- Immediately after synthesis, all plugins registered this way will be invoked to
1538
- validate all the templates generated in the scope you defined. In particular, if
1539
- you register the templates in the `App` object, all templates will be subject to
1540
- validation.
1541
-
1542
- > **Warning**
1543
- > Other than modifying the cloud assembly, plugins can do anything that your CDK
1544
- > application can. They can read data from the filesystem, access the network
1545
- > etc. It's your responsibility as the consumer of a plugin to verify that it is
1546
- > secure to use.
1547
-
1548
- By default, the report will be printed in a human readable format. If you want a
1549
- report in JSON format, enable it using the `@aws-cdk/core:validationReportJson`
1550
- context passing it directly to the application:
1551
-
1552
- ```ts
1553
- const app = new App({
1554
- context: { '@aws-cdk/core:validationReportJson': true },
1555
- });
1556
- ```
1557
-
1558
- Alternatively, you can set this context key-value pair using the `cdk.json` or
1559
- `cdk.context.json` files in your project directory (see
1560
- [Runtime context](https://docs.aws.amazon.com/cdk/v2/guide/context.html)).
1561
-
1562
- If you choose the JSON format, the CDK will print the policy validation report
1563
- to a file called `policy-validation-report.json` in the cloud assembly
1564
- directory. For the default, human-readable format, the report will be printed to
1565
- the standard output.
1566
-
1567
- ### For plugin authors
1568
-
1569
- The communication protocol between the CDK core module and your policy tool is
1570
- defined by the `IPolicyValidationPluginBeta1` interface. To create a new plugin you must
1571
- write a class that implements this interface. There are two things you need to
1572
- implement: the plugin name (by overriding the `name` property), and the
1573
- `validate()` method.
1574
-
1575
- The framework will call `validate()`, passing an `IPolicyValidationContextBeta1` object.
1576
- The location of the templates to be validated is given by `templatePaths`. The
1577
- plugin should return an instance of `PolicyValidationPluginReportBeta1`. This object
1578
- represents the report that the user wil receive at the end of the synthesis.
1579
-
1580
- ```ts fixture=validation-plugin
1581
- class MyPlugin implements IPolicyValidationPluginBeta1 {
1582
- public readonly name = 'MyPlugin';
1583
-
1584
- public validate(context: IPolicyValidationContextBeta1): PolicyValidationPluginReportBeta1 {
1585
- // First read the templates using context.templatePaths...
1586
-
1587
- // ...then perform the validation, and then compose and return the report.
1588
- // Using hard-coded values here for better clarity:
1589
- return {
1590
- success: false,
1591
- violations: [{
1592
- ruleName: 'CKV_AWS_117',
1593
- description: 'Ensure that AWS Lambda function is configured inside a VPC',
1594
- fix: 'https://docs.bridgecrew.io/docs/ensure-that-aws-lambda-function-is-configured-inside-a-vpc-1',
1595
- violatingResources: [{
1596
- resourceLogicalId: 'MyFunction3BAA72D1',
1597
- templatePath: '/home/johndoe/myapp/cdk.out/MyService.template.json',
1598
- locations: ['Properties/VpcConfig'],
1599
- }],
1600
- }],
1601
- };
1602
- }
1603
- }
1604
- ```
1605
-
1606
- In addition to the name, plugins may optionally report their version (`version`
1607
- property ) and a list of IDs of the rules they are going to evaluate (`ruleIds`
1608
- property).
1609
-
1610
- Note that plugins are not allowed to modify anything in the cloud assembly. Any
1611
- attempt to do so will result in synthesis failure.
1612
-
1613
- If your plugin depends on an external tool, keep in mind that some developers may
1614
- not have that tool installed in their workstations yet. To minimize friction, we
1615
- highly recommend that you provide some installation script along with your
1616
- plugin package, to automate the whole process. Better yet, run that script as
1617
- part of the installation of your package. With `npm`, for example, you can run
1618
- add it to the `postinstall`
1619
- [script](https://docs.npmjs.com/cli/v9/using-npm/scripts) in the `package.json`
1620
- file.
1621
-
1622
- ## Annotations
1623
-
1624
- Construct authors can add annotations to constructs to report at three different
1625
- levels: `ERROR`, `WARN`, `INFO`.
1626
-
1627
- Typically warnings are added for things that are important for the user to be
1628
- aware of, but will not cause deployment errors in all cases. Some common
1629
- scenarios are (non-exhaustive list):
1630
-
1631
- - Warn when the user needs to take a manual action, e.g. IAM policy should be
1632
- added to an referenced resource.
1633
- - Warn if the user configuration might not follow best practices (but is still
1634
- valid)
1635
- - Warn if the user is using a deprecated API
1636
-
1637
- ## Aspects
1638
-
1639
- [Aspects](https://docs.aws.amazon.com/cdk/v2/guide/aspects.html) is a feature in CDK that allows you to apply operations or transformations across all
1640
- constructs in a construct tree. Common use cases include tagging resources, enforcing encryption on S3 Buckets, or applying specific security or
1641
- compliance rules to all resources in a stack.
1642
-
1643
- Conceptually, there are two types of Aspects:
1644
-
1645
- - **Read-only aspects** scan the construct tree but do not make changes to the tree. Common use cases of read-only aspects include performing validations
1646
- (for example, enforcing that all S3 Buckets have versioning enabled) and logging (for example, collecting information about all deployed resources for
1647
- audits or compliance).
1648
- - **Mutating aspects** either (1.) add new nodes or (2.) mutate existing nodes of the tree in-place. One commonly used mutating Aspect is adding Tags to
1649
- resources. An example of an Aspect that adds a node is one that automatically adds a security group to every EC2 instance in the construct tree if
1650
- no default is specified.
1651
-
1652
- Here is a simple example of creating and applying an Aspect on a Stack to enable versioning on all S3 Buckets:
1653
-
1654
- ```ts
1655
- import { IAspect, IConstruct, Tags, Stack } from 'aws-cdk-lib';
1656
-
1657
- class EnableBucketVersioning implements IAspect {
1658
- visit(node: IConstruct) {
1659
- if (node instanceof CfnBucket) {
1660
- node.versioningConfiguration = {
1661
- status: 'Enabled'
1662
- };
1663
- }
1664
- }
1665
- }
1666
-
1667
- const app = new App();
1668
- const stack = new MyStack(app, 'MyStack');
1669
-
1670
- // Apply the aspect to enable versioning on all S3 Buckets
1671
- Aspects.of(stack).add(new EnableBucketVersioning());
1672
- ```
1673
-
1674
- ### Aspect Stabilization
1675
-
1676
- The modern behavior is that Aspects automatically run on newly added nodes to the construct tree. This is controlled by the
1677
- flag `@aws-cdk/core:aspectStabilization`, which is default for new projects (since version 2.172.0).
1678
-
1679
- The old behavior of Aspects (without stabilization) was that Aspect invocation runs once on the entire construct
1680
- tree. This meant that nested Aspects (Aspects that create new Aspects) are not invoked and nodes created by Aspects at a higher level of the construct tree are not visited.
1681
-
1682
- To enable the stabilization behavior for older versions, use this feature by putting the following into your `cdk.context.json`:
1683
-
1684
- ```json
1685
- {
1686
- "@aws-cdk/core:aspectStabilization": true
1687
- }
1688
- ```
1689
-
1690
- ### Aspect Priorities
1691
-
1692
- Users can specify the order in which Aspects are applied on a construct by using the optional priority parameter when applying an Aspect. Priority
1693
- values must be non-negative integers, where a higher number means the Aspect will be applied later, and a lower number means it will be applied sooner.
1694
-
1695
- By default, newly created nodes always inherit aspects. Priorities are mainly for ordering between mutating aspects on the construct tree.
1696
-
1697
- CDK provides standard priority values for mutating and readonly aspects to help ensure consistency across different construct libraries.
1698
- Note that Aspects that have same priority value are not guaranteed to be executed
1699
- in a consistent order.
1700
-
1701
-
1702
- ```ts
1703
- /**
1704
- * Default Priority values for Aspects.
1705
- */
1706
- export class AspectPriority {
1707
- /**
1708
- * Suggested priority for Aspects that mutate the construct tree.
1709
- */
1710
- static readonly MUTATING: number = 200;
1711
-
1712
- /**
1713
- * Suggested priority for Aspects that only read the construct tree.
1714
- */
1715
- static readonly READONLY: number = 1000;
1716
-
1717
- /**
1718
- * Default priority for Aspects that are applied without a priority.
1719
- */
1720
- static readonly DEFAULT: number = 500;
1721
- }
1722
- ```
1723
-
1724
- If no priority is provided, the default value will be 500. This ensures that aspects without a specified priority run after mutating aspects but before
1725
- any readonly aspects.
1726
-
1727
- Correctly applying Aspects with priority values ensures that mutating aspects (such as adding tags or resources) run before validation aspects. This allows users to avoid misconfigurations and ensure that the final
1728
- construct tree is fully validated before being synthesized.
1729
-
1730
- ### Applying Aspects with Priority
1731
-
1732
- ```ts
1733
- import { Aspects, Stack, IAspect, Tags } from 'aws-cdk-lib';
1734
- import { Bucket } from 'aws-cdk-lib/aws-s3';
1735
-
1736
- class MyAspect implements IAspect {
1737
- visit(node: IConstruct) {
1738
- // Modifies a resource in some way
1739
- }
1740
- }
1741
-
1742
- class ValidationAspect implements IAspect {
1743
- visit(node: IConstruct) {
1744
- // Perform some readonly validation on the cosntruct tree
1745
- }
1746
- }
1747
-
1748
- const stack = new Stack();
1749
-
1750
- Aspects.of(stack).add(new MyAspect(), { priority: AspectPriority.MUTATING } ); // Run first (mutating aspects)
1751
- Aspects.of(stack).add(new ValidationAspect(), { priority: AspectPriority.READONLY } ); // Run later (readonly aspects)
1752
- ```
1753
-
1754
- ### Inspecting applied aspects and changing priorities
1755
-
1756
- We also give customers the ability to view all of their applied aspects and override the priority on these aspects.
1757
- The `AspectApplication` class represents an Aspect that is applied to a node of the construct tree with a priority.
1758
-
1759
- Users can access AspectApplications on a node by calling `applied` from the Aspects class as follows:
1760
-
1761
- ```ts
1762
- const app = new App();
1763
- const stack = new MyStack(app, 'MyStack');
1764
-
1765
- Aspects.of(stack).add(new MyAspect());
1766
-
1767
- let aspectApplications: AspectApplication[] = Aspects.of(root).applied;
1768
-
1769
- for (const aspectApplication of aspectApplications) {
1770
- // The aspect we are applying
1771
- console.log(aspectApplication.aspect);
1772
- // The construct we are applying the aspect to
1773
- console.log(aspectApplication.construct);
1774
- // The priority it was applied with
1775
- console.log(aspectApplication.priority);
1776
-
1777
- // Change the priority
1778
- aspectApplication.priority = 700;
1779
- }
1780
- ```
1781
-
1782
- ### Acknowledging Warnings
1783
-
1784
- If you would like to run with `--strict` mode enabled (warnings will throw
1785
- errors) it is possible to `acknowledge` warnings to make the warning go away.
1786
-
1787
- For example, if > 10 IAM managed policies are added to an IAM Group, a warning
1788
- will be created:
1789
-
1790
- ```text
1791
- IAM:Group:MaxPoliciesExceeded: You added 11 to IAM Group my-group. The maximum number of managed policies attached to an IAM group is 10.
1792
- ```
1793
-
1794
- If you have requested a [quota increase](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-quotas-entities)
1795
- you may have the ability to add > 10 managed policies which means that this
1796
- warning does not apply to you. You can acknowledge this by `acknowledging` the
1797
- warning by the `id`.
1798
-
1799
- ```ts
1800
- Annotations.of(this).acknowledgeWarning('IAM:Group:MaxPoliciesExceeded', 'Account has quota increased to 20');
1801
- ```
1802
-
1803
- ## RemovalPolicies
1804
-
1805
- The `RemovalPolicies` class provides a convenient way to manage removal policies for AWS CDK resources within a construct scope. It allows you to apply removal policies to multiple resources at once, with options to include or exclude specific resource types.
1806
-
1807
- ### Usage
1808
-
1809
- ```typescript
1810
- import { RemovalPolicies, MissingRemovalPolicies } from 'aws-cdk-lib';
1811
-
1812
- // Apply DESTROY policy to all resources in a scope
1813
- RemovalPolicies.of(scope).destroy();
1814
-
1815
- // Apply RETAIN policy to all resources in a scope
1816
- RemovalPolicies.of(scope).retain();
1817
-
1818
- // Apply SNAPSHOT policy to all resources in a scope
1819
- RemovalPolicies.of(scope).snapshot();
1820
-
1821
- // Apply RETAIN_ON_UPDATE_OR_DELETE policy to all resources in a scope
1822
- RemovalPolicies.of(scope).retainOnUpdateOrDelete();
1823
-
1824
- // Apply RETAIN policy only to specific resource types
1825
- RemovalPolicies.of(parent).retain({
1826
- applyToResourceTypes: [
1827
- 'AWS::DynamoDB::Table',
1828
- bucket.cfnResourceType, // 'AWS::S3::Bucket'
1829
- CfnDBInstance.CFN_RESOURCE_TYPE_NAME, // 'AWS::RDS::DBInstance'
1830
- ],
1831
- });
1832
-
1833
- // Apply SNAPSHOT policy excluding specific resource types
1834
- RemovalPolicies.of(scope).snapshot({
1835
- excludeResourceTypes: ['AWS::Test::Resource'],
1836
- });
1837
- ```
1838
-
1839
- ### RemovalPolicies vs MissingRemovalPolicies
1840
-
1841
- CDK provides two different classes for managing removal policies:
1842
-
1843
- - RemovalPolicies: Always applies the specified removal policy, overriding any existing policies.
1844
- - MissingRemovalPolicies: Applies the removal policy only to resources that don't already have a policy set.
1845
-
1846
- ```typescript
1847
- // Override any existing policies
1848
- RemovalPolicies.of(scope).retain();
1849
-
1850
- // Only apply to resources without existing policies
1851
- MissingRemovalPolicies.of(scope).retain();
1852
- ```
1853
-
1854
- ### Aspect Priority
1855
-
1856
- Both RemovalPolicies and MissingRemovalPolicies are implemented as Aspects. You can control the order in which they're applied using the priority parameter:
1857
-
1858
- ```typescript
1859
- // Apply in a specific order based on priority
1860
- RemovalPolicies.of(stack).retain({ priority: 100 });
1861
- RemovalPolicies.of(stack).destroy({ priority: 200 }); // This will override the RETAIN policy
1862
- ```
1863
-
1864
- For RemovalPolicies, the policies are applied in order of aspect execution, with the last applied policy overriding previous ones. The priority only affects the order in which aspects are applied during synthesis.
1865
-
1866
- #### Note
1867
-
1868
- When using MissingRemovalPolicies with priority, a warning will be issued as this can lead to unexpected behavior. This is because MissingRemovalPolicies only applies to resources without existing policies, making priority less relevant.
1869
-
1870
-
1871
- <!--END CORE DOCUMENTATION-->
3
+ See top-level [README](../README.md).