aws-cdk-lib 2.211.0__py3-none-any.whl → 2.212.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.
Potentially problematic release.
This version of aws-cdk-lib might be problematic. Click here for more details.
- aws_cdk/__init__.py +398 -43
- aws_cdk/_jsii/__init__.py +1 -1
- aws_cdk/_jsii/{aws-cdk-lib@2.211.0.jsii.tgz → aws-cdk-lib@2.212.0.jsii.tgz} +0 -0
- aws_cdk/aws_apigateway/__init__.py +2 -0
- aws_cdk/aws_apigatewayv2/__init__.py +1798 -74
- aws_cdk/aws_appintegrations/__init__.py +395 -0
- aws_cdk/aws_arcregionswitch/__init__.py +118 -0
- aws_cdk/aws_batch/__init__.py +4 -4
- aws_cdk/aws_bedrock/__init__.py +18 -0
- aws_cdk/aws_billingconductor/__init__.py +3 -3
- aws_cdk/aws_cloudfront/__init__.py +19 -0
- aws_cdk/aws_codebuild/__init__.py +122 -0
- aws_cdk/aws_codepipeline/__init__.py +51 -50
- aws_cdk/aws_connect/__init__.py +40 -15
- aws_cdk/aws_deadline/__init__.py +16 -5
- aws_cdk/aws_dynamodb/__init__.py +86 -16
- aws_cdk/aws_ec2/__init__.py +266 -55
- aws_cdk/aws_ecs/__init__.py +7 -9
- aws_cdk/aws_eks/__init__.py +6 -4
- aws_cdk/aws_elasticloadbalancingv2/__init__.py +2 -2
- aws_cdk/aws_gameliftstreams/__init__.py +7 -6
- aws_cdk/aws_glue/__init__.py +18 -9
- aws_cdk/aws_guardduty/__init__.py +1233 -113
- aws_cdk/aws_imagebuilder/__init__.py +34 -20
- aws_cdk/aws_inspectorv2/__init__.py +1516 -0
- aws_cdk/aws_ivs/__init__.py +1 -1
- aws_cdk/aws_lakeformation/__init__.py +1 -1
- aws_cdk/aws_lambda/__init__.py +6 -6
- aws_cdk/aws_omics/__init__.py +1 -1
- aws_cdk/aws_opensearchservice/__init__.py +128 -0
- aws_cdk/aws_pcs/__init__.py +16 -8
- aws_cdk/aws_quicksight/__init__.py +81 -83
- aws_cdk/aws_rds/__init__.py +31 -163
- aws_cdk/aws_s3express/__init__.py +7 -3
- aws_cdk/aws_s3tables/__init__.py +2 -2
- aws_cdk/aws_sagemaker/__init__.py +62 -20
- aws_cdk/aws_sqs/__init__.py +4 -3
- aws_cdk/aws_stepfunctions_tasks/__init__.py +16 -9
- aws_cdk/aws_synthetics/__init__.py +116 -0
- aws_cdk/cx_api/__init__.py +22 -0
- {aws_cdk_lib-2.211.0.dist-info → aws_cdk_lib-2.212.0.dist-info}/METADATA +329 -9
- {aws_cdk_lib-2.211.0.dist-info → aws_cdk_lib-2.212.0.dist-info}/RECORD +46 -46
- {aws_cdk_lib-2.211.0.dist-info → aws_cdk_lib-2.212.0.dist-info}/LICENSE +0 -0
- {aws_cdk_lib-2.211.0.dist-info → aws_cdk_lib-2.212.0.dist-info}/NOTICE +0 -0
- {aws_cdk_lib-2.211.0.dist-info → aws_cdk_lib-2.212.0.dist-info}/WHEEL +0 -0
- {aws_cdk_lib-2.211.0.dist-info → aws_cdk_lib-2.212.0.dist-info}/top_level.txt +0 -0
aws_cdk/__init__.py
CHANGED
|
@@ -155,6 +155,76 @@ MyStack(app, "MyStack",
|
|
|
155
155
|
For more information on bootstrapping accounts and customizing synthesis,
|
|
156
156
|
see [Bootstrapping in the CDK Developer Guide](https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html).
|
|
157
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
|
+
Refer to [the bootstrapping guide](https://docs.aws.amazon.com/cdk/v2/guide/bootstrapping-env.html#bootstrapping-env-roles) for further context.
|
|
164
|
+
|
|
165
|
+
These options are available via the `DefaultStackSynthesizer` properties:
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
class MyStack(Stack):
|
|
169
|
+
def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, notificationArns=None, synthesizer=None, terminationProtection=None, analyticsReporting=None, crossRegionReferences=None, permissionsBoundary=None, suppressTemplateIndentation=None, propertyInjectors=None):
|
|
170
|
+
super().__init__(scope, id,
|
|
171
|
+
(SpreadAssignment ...props
|
|
172
|
+
description=description, env=env, stackName=stackName, tags=tags, notificationArns=notificationArns, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting, crossRegionReferences=crossRegionReferences, permissionsBoundary=permissionsBoundary, suppressTemplateIndentation=suppressTemplateIndentation, propertyInjectors=propertyInjectors),
|
|
173
|
+
synthesizer=DefaultStackSynthesizer(
|
|
174
|
+
deploy_role_external_id="",
|
|
175
|
+
deploy_role_additional_options={},
|
|
176
|
+
file_asset_publishing_external_id="",
|
|
177
|
+
file_asset_publishing_role_additional_options={},
|
|
178
|
+
image_asset_publishing_external_id="",
|
|
179
|
+
image_asset_publishing_role_additional_options={},
|
|
180
|
+
lookup_role_external_id="",
|
|
181
|
+
lookup_role_additional_options={}
|
|
182
|
+
)
|
|
183
|
+
)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
> Note that the `*additionalOptions` property does not allow passing `ExternalId` or `RoleArn`, as these options
|
|
187
|
+
> have dedicated properties that configure them.
|
|
188
|
+
|
|
189
|
+
#### Session Tags
|
|
190
|
+
|
|
191
|
+
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).
|
|
192
|
+
|
|
193
|
+
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).
|
|
194
|
+
|
|
195
|
+
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:
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
class MyStack(Stack):
|
|
199
|
+
def __init__(self, parent, id, *, description=None, env=None, stackName=None, tags=None, notificationArns=None, synthesizer=None, terminationProtection=None, analyticsReporting=None, crossRegionReferences=None, permissionsBoundary=None, suppressTemplateIndentation=None, propertyInjectors=None):
|
|
200
|
+
super().__init__(parent, id,
|
|
201
|
+
(SpreadAssignment ...props
|
|
202
|
+
description=description, env=env, stackName=stackName, tags=tags, notificationArns=notificationArns, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting, crossRegionReferences=crossRegionReferences, permissionsBoundary=permissionsBoundary, suppressTemplateIndentation=suppressTemplateIndentation, propertyInjectors=propertyInjectors),
|
|
203
|
+
synthesizer=DefaultStackSynthesizer(
|
|
204
|
+
deploy_role_additional_options={
|
|
205
|
+
"Tags": [{"Key": "Department", "Value": "Engineering"}]
|
|
206
|
+
},
|
|
207
|
+
file_asset_publishing_role_additional_options={
|
|
208
|
+
"Tags": [{"Key": "Department", "Value": "Engineering"}]
|
|
209
|
+
},
|
|
210
|
+
image_asset_publishing_role_additional_options={
|
|
211
|
+
"Tags": [{"Key": "Department", "Value": "Engineering"}]
|
|
212
|
+
},
|
|
213
|
+
lookup_role_additional_options={
|
|
214
|
+
"Tags": [{"Key": "Department", "Value": "Engineering"}]
|
|
215
|
+
}
|
|
216
|
+
)
|
|
217
|
+
)
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
This will cause the CDK CLI to include session tags when assuming each of these roles during deployment.
|
|
221
|
+
Note that the trust policy of the role must contain permissions for the `sts:TagSession` action.
|
|
222
|
+
|
|
223
|
+
Refer to the [IAM user guide on session tags](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_permissions-required).
|
|
224
|
+
|
|
225
|
+
* If you are using a custom bootstrap template, make sure the template includes these permissions.
|
|
226
|
+
* If you are using the default bootstrap template from a CDK version lower than XXXX, you will need to rebootstrap your enviroment (once).
|
|
227
|
+
|
|
158
228
|
## Nested Stacks
|
|
159
229
|
|
|
160
230
|
[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.
|
|
@@ -521,6 +591,8 @@ CustomResource(self, "MyMagicalResource",
|
|
|
521
591
|
resource_type="Custom::MyCustomResource", # must start with 'Custom::'
|
|
522
592
|
|
|
523
593
|
# the resource properties
|
|
594
|
+
# properties like serviceToken or serviceTimeout are ported into properties automatically
|
|
595
|
+
# try not to use key names similar to these or there will be a risk of overwriting those values
|
|
524
596
|
properties={
|
|
525
597
|
"Property1": "foo",
|
|
526
598
|
"Property2": "bar"
|
|
@@ -529,7 +601,10 @@ CustomResource(self, "MyMagicalResource",
|
|
|
529
601
|
# the ARN of the provider (SNS/Lambda) which handles
|
|
530
602
|
# CREATE, UPDATE or DELETE events for this resource type
|
|
531
603
|
# see next section for details
|
|
532
|
-
service_token="ARN"
|
|
604
|
+
service_token="ARN",
|
|
605
|
+
|
|
606
|
+
# the maximum time, in seconds, that can elapse before a custom resource operation times out.
|
|
607
|
+
service_timeout=Duration.seconds(60)
|
|
533
608
|
)
|
|
534
609
|
```
|
|
535
610
|
|
|
@@ -559,7 +634,7 @@ Legend:
|
|
|
559
634
|
* **Language**: which programming languages can be used to implement handlers.
|
|
560
635
|
* **Footprint**: how many resources are used by the provider framework itself.
|
|
561
636
|
|
|
562
|
-
|
|
637
|
+
#### A note about singletons
|
|
563
638
|
|
|
564
639
|
When defining resources for a custom resource provider, you will likely want to
|
|
565
640
|
define them as a *stack singleton* so that only a single instance of the
|
|
@@ -824,6 +899,18 @@ CfnOutput(self, "OutputName",
|
|
|
824
899
|
)
|
|
825
900
|
```
|
|
826
901
|
|
|
902
|
+
You can also use the `exportValue` method to export values as stack outputs:
|
|
903
|
+
|
|
904
|
+
```python
|
|
905
|
+
# stack: Stack
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
stack.export_value(my_bucket.bucket_name,
|
|
909
|
+
name="TheAwesomeBucket",
|
|
910
|
+
description="The name of an S3 bucket"
|
|
911
|
+
)
|
|
912
|
+
```
|
|
913
|
+
|
|
827
914
|
### Parameters
|
|
828
915
|
|
|
829
916
|
CloudFormation templates support the use of [Parameters](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html) to
|
|
@@ -1105,6 +1192,74 @@ references is done using the `CfnDynamicReference` class:
|
|
|
1105
1192
|
CfnDynamicReference(CfnDynamicReferenceService.SECRETS_MANAGER, "secret-id:secret-string:json-key:version-stage:version-id")
|
|
1106
1193
|
```
|
|
1107
1194
|
|
|
1195
|
+
## RemovalPolicies
|
|
1196
|
+
|
|
1197
|
+
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.
|
|
1198
|
+
|
|
1199
|
+
```python
|
|
1200
|
+
# scope: Construct
|
|
1201
|
+
# parent: Construct
|
|
1202
|
+
# bucket: s3.CfnBucket
|
|
1203
|
+
|
|
1204
|
+
|
|
1205
|
+
# Apply DESTROY policy to all resources in a scope
|
|
1206
|
+
RemovalPolicies.of(scope).destroy()
|
|
1207
|
+
|
|
1208
|
+
# Apply RETAIN policy to all resources in a scope
|
|
1209
|
+
RemovalPolicies.of(scope).retain()
|
|
1210
|
+
|
|
1211
|
+
# Apply SNAPSHOT policy to all resources in a scope
|
|
1212
|
+
RemovalPolicies.of(scope).snapshot()
|
|
1213
|
+
|
|
1214
|
+
# Apply RETAIN_ON_UPDATE_OR_DELETE policy to all resources in a scope
|
|
1215
|
+
RemovalPolicies.of(scope).retain_on_update_or_delete()
|
|
1216
|
+
|
|
1217
|
+
# Apply RETAIN policy only to specific resource types
|
|
1218
|
+
RemovalPolicies.of(parent).retain(
|
|
1219
|
+
apply_to_resource_types=["AWS::DynamoDB::Table", bucket.cfn_resource_type, rds.CfnDBInstance.CFN_RESOURCE_TYPE_NAME
|
|
1220
|
+
]
|
|
1221
|
+
)
|
|
1222
|
+
|
|
1223
|
+
# Apply SNAPSHOT policy excluding specific resource types
|
|
1224
|
+
RemovalPolicies.of(scope).snapshot(
|
|
1225
|
+
exclude_resource_types=["AWS::Test::Resource"]
|
|
1226
|
+
)
|
|
1227
|
+
```
|
|
1228
|
+
|
|
1229
|
+
### RemovalPolicies vs MissingRemovalPolicies
|
|
1230
|
+
|
|
1231
|
+
CDK provides two different classes for managing removal policies:
|
|
1232
|
+
|
|
1233
|
+
* RemovalPolicies: Always applies the specified removal policy, overriding any existing policies.
|
|
1234
|
+
* MissingRemovalPolicies: Applies the removal policy only to resources that don't already have a policy set.
|
|
1235
|
+
|
|
1236
|
+
```python
|
|
1237
|
+
# Override any existing policies
|
|
1238
|
+
RemovalPolicies.of(scope).retain()
|
|
1239
|
+
|
|
1240
|
+
# Only apply to resources without existing policies
|
|
1241
|
+
MissingRemovalPolicies.of(scope).retain()
|
|
1242
|
+
```
|
|
1243
|
+
|
|
1244
|
+
### Aspect Priority
|
|
1245
|
+
|
|
1246
|
+
Both RemovalPolicies and MissingRemovalPolicies are implemented as [Aspects](#aspects). You can control the order in which they're applied using the priority parameter:
|
|
1247
|
+
|
|
1248
|
+
```python
|
|
1249
|
+
# stack: Stack
|
|
1250
|
+
|
|
1251
|
+
|
|
1252
|
+
# Apply in a specific order based on priority
|
|
1253
|
+
RemovalPolicies.of(stack).retain(priority=100)
|
|
1254
|
+
RemovalPolicies.of(stack).destroy(priority=200)
|
|
1255
|
+
```
|
|
1256
|
+
|
|
1257
|
+
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.
|
|
1258
|
+
|
|
1259
|
+
#### Note
|
|
1260
|
+
|
|
1261
|
+
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.
|
|
1262
|
+
|
|
1108
1263
|
### Template Options & Transform
|
|
1109
1264
|
|
|
1110
1265
|
CloudFormation templates support a number of options, including which Macros or
|
|
@@ -1194,6 +1349,27 @@ stack = Stack(app, "StackName",
|
|
|
1194
1349
|
)
|
|
1195
1350
|
```
|
|
1196
1351
|
|
|
1352
|
+
### Receiving CloudFormation Stack Events
|
|
1353
|
+
|
|
1354
|
+
You can add one or more SNS Topic ARNs to any Stack:
|
|
1355
|
+
|
|
1356
|
+
```python
|
|
1357
|
+
stack = Stack(app, "StackName",
|
|
1358
|
+
notification_arns=["arn:aws:sns:us-east-1:123456789012:Topic"]
|
|
1359
|
+
)
|
|
1360
|
+
```
|
|
1361
|
+
|
|
1362
|
+
Stack events will be sent to any SNS Topics in this list. These ARNs are added to those specified using
|
|
1363
|
+
the `--notification-arns` command line option.
|
|
1364
|
+
|
|
1365
|
+
Note that in order to do delete notification ARNs entirely, you must pass an empty array ([]) instead of omitting it.
|
|
1366
|
+
If you omit the property, no action on existing ARNs will take place.
|
|
1367
|
+
|
|
1368
|
+
> [!NOTE]
|
|
1369
|
+
> Adding the `notificationArns` property (or using the `--notification-arns` CLI options) will **override**
|
|
1370
|
+
> any existing ARNs configured on the stack. If you have an external system managing notification ARNs,
|
|
1371
|
+
> either migrate to use this mechanism, or avoid specfying notification ARNs with the CDK.
|
|
1372
|
+
|
|
1197
1373
|
### CfnJson
|
|
1198
1374
|
|
|
1199
1375
|
`CfnJson` allows you to postpone the resolution of a JSON blob from
|
|
@@ -1296,7 +1472,7 @@ App(
|
|
|
1296
1472
|
cdk synth --context @aws-cdk/core:newStyleStackSynthesis=true
|
|
1297
1473
|
```
|
|
1298
1474
|
|
|
1299
|
-
|
|
1475
|
+
#### `cdk.json`
|
|
1300
1476
|
|
|
1301
1477
|
```json
|
|
1302
1478
|
{
|
|
@@ -1306,7 +1482,7 @@ cdk synth --context @aws-cdk/core:newStyleStackSynthesis=true
|
|
|
1306
1482
|
}
|
|
1307
1483
|
```
|
|
1308
1484
|
|
|
1309
|
-
|
|
1485
|
+
#### `cdk.context.json`
|
|
1310
1486
|
|
|
1311
1487
|
```json
|
|
1312
1488
|
{
|
|
@@ -1314,7 +1490,7 @@ cdk synth --context @aws-cdk/core:newStyleStackSynthesis=true
|
|
|
1314
1490
|
}
|
|
1315
1491
|
```
|
|
1316
1492
|
|
|
1317
|
-
|
|
1493
|
+
#### `~/.cdk.json`
|
|
1318
1494
|
|
|
1319
1495
|
```json
|
|
1320
1496
|
{
|
|
@@ -1353,7 +1529,7 @@ generated CloudFormation templates against your policies immediately after
|
|
|
1353
1529
|
synthesis. If there are any violations, the synthesis will fail and a report
|
|
1354
1530
|
will be printed to the console or to a file (see below).
|
|
1355
1531
|
|
|
1356
|
-
>
|
|
1532
|
+
> [!NOTE]
|
|
1357
1533
|
> This feature is considered experimental, and both the plugin API and the
|
|
1358
1534
|
> format of the validation report are subject to change in the future.
|
|
1359
1535
|
|
|
@@ -1391,7 +1567,7 @@ validation.
|
|
|
1391
1567
|
> etc. It's your responsibility as the consumer of a plugin to verify that it is
|
|
1392
1568
|
> secure to use.
|
|
1393
1569
|
|
|
1394
|
-
By default, the report will be printed in a human
|
|
1570
|
+
By default, the report will be printed in a human-readable format. If you want a
|
|
1395
1571
|
report in JSON format, enable it using the `@aws-cdk/core:validationReportJson`
|
|
1396
1572
|
context passing it directly to the application:
|
|
1397
1573
|
|
|
@@ -1405,6 +1581,18 @@ Alternatively, you can set this context key-value pair using the `cdk.json` or
|
|
|
1405
1581
|
`cdk.context.json` files in your project directory (see
|
|
1406
1582
|
[Runtime context](https://docs.aws.amazon.com/cdk/v2/guide/context.html)).
|
|
1407
1583
|
|
|
1584
|
+
It is also possible to enable both JSON and human-readable formats by setting
|
|
1585
|
+
`@aws-cdk/core:validationReportPrettyPrint` context key explicitly:
|
|
1586
|
+
|
|
1587
|
+
```python
|
|
1588
|
+
app = App(
|
|
1589
|
+
context={
|
|
1590
|
+
"@aws-cdk/core:validationReportJson": True,
|
|
1591
|
+
"@aws-cdk/core:validationReportPrettyPrint": True
|
|
1592
|
+
}
|
|
1593
|
+
)
|
|
1594
|
+
```
|
|
1595
|
+
|
|
1408
1596
|
If you choose the JSON format, the CDK will print the policy validation report
|
|
1409
1597
|
to a file called `policy-validation-report.json` in the cloud assembly
|
|
1410
1598
|
directory. For the default, human-readable format, the report will be printed to
|
|
@@ -1499,6 +1687,138 @@ warning by the `id`.
|
|
|
1499
1687
|
Annotations.of(self).acknowledge_warning("IAM:Group:MaxPoliciesExceeded", "Account has quota increased to 20")
|
|
1500
1688
|
```
|
|
1501
1689
|
|
|
1690
|
+
### Acknowledging Infos
|
|
1691
|
+
|
|
1692
|
+
Informational messages can also be emitted and acknowledged. Use `addInfoV2()`
|
|
1693
|
+
to add an info message that can later be suppressed with `acknowledgeInfo()`.
|
|
1694
|
+
Unlike warnings, info messages are not affected by the `--strict` mode and will never cause synthesis to fail.
|
|
1695
|
+
|
|
1696
|
+
```python
|
|
1697
|
+
Annotations.of(self).add_info_v2("my-lib:Construct.someInfo", "Some message explaining the info")
|
|
1698
|
+
Annotations.of(self).acknowledge_info("my-lib:Construct.someInfo", "This info can be ignored")
|
|
1699
|
+
```
|
|
1700
|
+
|
|
1701
|
+
## Aspects
|
|
1702
|
+
|
|
1703
|
+
[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
|
|
1704
|
+
constructs in a construct tree. Common use cases include tagging resources, enforcing encryption on S3 Buckets, or applying specific security or
|
|
1705
|
+
compliance rules to all resources in a stack.
|
|
1706
|
+
|
|
1707
|
+
Conceptually, there are two types of Aspects:
|
|
1708
|
+
|
|
1709
|
+
* **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
|
|
1710
|
+
(for example, enforcing that all S3 Buckets have versioning enabled) and logging (for example, collecting information about all deployed resources for
|
|
1711
|
+
audits or compliance).
|
|
1712
|
+
* **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
|
|
1713
|
+
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
|
|
1714
|
+
no default is specified.
|
|
1715
|
+
|
|
1716
|
+
Here is a simple example of creating and applying an Aspect on a Stack to enable versioning on all S3 Buckets:
|
|
1717
|
+
|
|
1718
|
+
```python
|
|
1719
|
+
@jsii.implements(IAspect)
|
|
1720
|
+
class EnableBucketVersioning:
|
|
1721
|
+
def visit(self, node):
|
|
1722
|
+
if node instanceof s3.CfnBucket:
|
|
1723
|
+
node.versioning_configuration = s3.CfnBucket.VersioningConfigurationProperty(
|
|
1724
|
+
status="Enabled"
|
|
1725
|
+
)
|
|
1726
|
+
|
|
1727
|
+
app = App()
|
|
1728
|
+
stack = MyStack(app, "MyStack")
|
|
1729
|
+
|
|
1730
|
+
# Apply the aspect to enable versioning on all S3 Buckets
|
|
1731
|
+
Aspects.of(stack).add(EnableBucketVersioning())
|
|
1732
|
+
```
|
|
1733
|
+
|
|
1734
|
+
### Aspect Stabilization
|
|
1735
|
+
|
|
1736
|
+
The modern behavior is that Aspects automatically run on newly added nodes to the construct tree. This is controlled by the
|
|
1737
|
+
flag `@aws-cdk/core:aspectStabilization`, which is default for new projects (since version 2.172.0).
|
|
1738
|
+
|
|
1739
|
+
The old behavior of Aspects (without stabilization) was that Aspect invocation runs once on the entire construct
|
|
1740
|
+
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.
|
|
1741
|
+
|
|
1742
|
+
To enable the stabilization behavior for older versions, use this feature by putting the following into your `cdk.context.json`:
|
|
1743
|
+
|
|
1744
|
+
```json
|
|
1745
|
+
{
|
|
1746
|
+
"@aws-cdk/core:aspectStabilization": true
|
|
1747
|
+
}
|
|
1748
|
+
```
|
|
1749
|
+
|
|
1750
|
+
### Aspect Priorities
|
|
1751
|
+
|
|
1752
|
+
Users can specify the order in which Aspects are applied on a construct by using the optional priority parameter when applying an Aspect. Priority
|
|
1753
|
+
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.
|
|
1754
|
+
|
|
1755
|
+
By default, newly created nodes always inherit aspects. Priorities are mainly for ordering between mutating aspects on the construct tree.
|
|
1756
|
+
|
|
1757
|
+
CDK provides standard priority values for mutating and readonly aspects to help ensure consistency across different construct libraries.
|
|
1758
|
+
Note that Aspects that have same priority value are not guaranteed to be executed
|
|
1759
|
+
in a consistent order.
|
|
1760
|
+
|
|
1761
|
+
```python
|
|
1762
|
+
#
|
|
1763
|
+
# Default Priority values for Aspects.
|
|
1764
|
+
#
|
|
1765
|
+
class AspectPriority:
|
|
1766
|
+
```
|
|
1767
|
+
|
|
1768
|
+
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
|
|
1769
|
+
any readonly aspects.
|
|
1770
|
+
|
|
1771
|
+
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
|
|
1772
|
+
construct tree is fully validated before being synthesized.
|
|
1773
|
+
|
|
1774
|
+
### Applying Aspects with Priority
|
|
1775
|
+
|
|
1776
|
+
```python
|
|
1777
|
+
@jsii.implements(IAspect)
|
|
1778
|
+
class MutatingAspect:
|
|
1779
|
+
def visit(self, node):
|
|
1780
|
+
pass
|
|
1781
|
+
|
|
1782
|
+
@jsii.implements(IAspect)
|
|
1783
|
+
class ValidationAspect:
|
|
1784
|
+
def visit(self, node):
|
|
1785
|
+
pass
|
|
1786
|
+
|
|
1787
|
+
stack = Stack()
|
|
1788
|
+
|
|
1789
|
+
Aspects.of(stack).add(MutatingAspect(), priority=AspectPriority.MUTATING) # Run first (mutating aspects)
|
|
1790
|
+
Aspects.of(stack).add(ValidationAspect(), priority=AspectPriority.READONLY)
|
|
1791
|
+
```
|
|
1792
|
+
|
|
1793
|
+
### Inspecting applied aspects and changing priorities
|
|
1794
|
+
|
|
1795
|
+
We also give customers the ability to view all of their applied aspects and override the priority on these aspects.
|
|
1796
|
+
The `AspectApplication` class represents an Aspect that is applied to a node of the construct tree with a priority.
|
|
1797
|
+
|
|
1798
|
+
Users can access AspectApplications on a node by calling `applied` from the Aspects class as follows:
|
|
1799
|
+
|
|
1800
|
+
```python
|
|
1801
|
+
# root: Construct
|
|
1802
|
+
|
|
1803
|
+
app = App()
|
|
1804
|
+
stack = MyStack(app, "MyStack")
|
|
1805
|
+
|
|
1806
|
+
Aspects.of(stack).add(MyAspect())
|
|
1807
|
+
|
|
1808
|
+
aspect_applications = Aspects.of(root).applied
|
|
1809
|
+
|
|
1810
|
+
for aspect_application in aspect_applications:
|
|
1811
|
+
# The aspect we are applying
|
|
1812
|
+
print(aspect_application.aspect)
|
|
1813
|
+
# The construct we are applying the aspect to
|
|
1814
|
+
print(aspect_application.construct)
|
|
1815
|
+
# The priority it was applied with
|
|
1816
|
+
print(aspect_application.priority)
|
|
1817
|
+
|
|
1818
|
+
# Change the priority
|
|
1819
|
+
aspect_application.priority = 700
|
|
1820
|
+
```
|
|
1821
|
+
|
|
1502
1822
|
## Blueprint Property Injection
|
|
1503
1823
|
|
|
1504
1824
|
The goal of Blueprint Property Injection is to provide builders an automatic way to set default property values.
|
|
@@ -2597,17 +2917,24 @@ class AspectOptions:
|
|
|
2597
2917
|
|
|
2598
2918
|
:param priority: The priority value to apply on an Aspect. Priority must be a non-negative integer. Aspects that have same priority value are not guaranteed to be executed in a consistent order. Default: AspectPriority.DEFAULT
|
|
2599
2919
|
|
|
2600
|
-
:exampleMetadata:
|
|
2920
|
+
:exampleMetadata: infused
|
|
2601
2921
|
|
|
2602
2922
|
Example::
|
|
2603
2923
|
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2924
|
+
@jsii.implements(IAspect)
|
|
2925
|
+
class MutatingAspect:
|
|
2926
|
+
def visit(self, node):
|
|
2927
|
+
pass
|
|
2607
2928
|
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2929
|
+
@jsii.implements(IAspect)
|
|
2930
|
+
class ValidationAspect:
|
|
2931
|
+
def visit(self, node):
|
|
2932
|
+
pass
|
|
2933
|
+
|
|
2934
|
+
stack = Stack()
|
|
2935
|
+
|
|
2936
|
+
Aspects.of(stack).add(MutatingAspect(), priority=AspectPriority.MUTATING) # Run first (mutating aspects)
|
|
2937
|
+
Aspects.of(stack).add(ValidationAspect(), priority=AspectPriority.READONLY)
|
|
2611
2938
|
'''
|
|
2612
2939
|
if __debug__:
|
|
2613
2940
|
type_hints = typing.get_type_hints(_typecheckingstub__1761263abda35b4b2f599d4ff5122c0e7ad15a95af4498d9c6e04e78bc4a4b76)
|
|
@@ -11727,9 +12054,16 @@ class DefaultStackSynthesizerProps:
|
|
|
11727
12054
|
|
|
11728
12055
|
Example::
|
|
11729
12056
|
|
|
11730
|
-
|
|
12057
|
+
# app: App
|
|
12058
|
+
|
|
12059
|
+
|
|
12060
|
+
prod_stage = Stage(app, "ProdStage",
|
|
12061
|
+
permissions_boundary=PermissionsBoundary.from_name("cdk-${Qualifier}-PermissionsBoundary-${AWS::AccountId}-${AWS::Region}")
|
|
12062
|
+
)
|
|
12063
|
+
|
|
12064
|
+
Stack(prod_stage, "ProdStack",
|
|
11731
12065
|
synthesizer=DefaultStackSynthesizer(
|
|
11732
|
-
|
|
12066
|
+
qualifier="custom"
|
|
11733
12067
|
)
|
|
11734
12068
|
)
|
|
11735
12069
|
'''
|
|
@@ -13926,17 +14260,16 @@ class ExportValueOptions:
|
|
|
13926
14260
|
:param description: The description of the outputs. Default: - No description
|
|
13927
14261
|
:param name: The name of the export to create. Default: - A name is automatically chosen
|
|
13928
14262
|
|
|
13929
|
-
:exampleMetadata:
|
|
14263
|
+
:exampleMetadata: infused
|
|
13930
14264
|
|
|
13931
14265
|
Example::
|
|
13932
14266
|
|
|
13933
|
-
#
|
|
13934
|
-
# The values are placeholders you should change.
|
|
13935
|
-
import aws_cdk as cdk
|
|
14267
|
+
# stack: Stack
|
|
13936
14268
|
|
|
13937
|
-
|
|
13938
|
-
|
|
13939
|
-
name="
|
|
14269
|
+
|
|
14270
|
+
stack.export_value(my_bucket.bucket_name,
|
|
14271
|
+
name="TheAwesomeBucket",
|
|
14272
|
+
description="The name of an S3 bucket"
|
|
13940
14273
|
)
|
|
13941
14274
|
'''
|
|
13942
14275
|
if __debug__:
|
|
@@ -20194,18 +20527,36 @@ class RemovalPolicyProps:
|
|
|
20194
20527
|
:param exclude_resource_types: Exclude specific resource types from the removal policy. Can be a CloudFormation resource type string (e.g., 'AWS::S3::Bucket'). Default: - no exclusions
|
|
20195
20528
|
:param priority: The priority to use when applying this policy. The priority affects only the order in which aspects are applied during synthesis. For RemovalPolicies, the last applied policy will override previous ones. NOTE: Priority does NOT determine which policy "wins" when there are conflicts. The order of application determines the final policy, with later policies overriding earlier ones. Default: - AspectPriority.MUTATING
|
|
20196
20529
|
|
|
20197
|
-
:exampleMetadata:
|
|
20530
|
+
:exampleMetadata: infused
|
|
20198
20531
|
|
|
20199
20532
|
Example::
|
|
20200
20533
|
|
|
20201
|
-
#
|
|
20202
|
-
#
|
|
20203
|
-
|
|
20534
|
+
# scope: Construct
|
|
20535
|
+
# parent: Construct
|
|
20536
|
+
# bucket: s3.CfnBucket
|
|
20204
20537
|
|
|
20205
|
-
|
|
20206
|
-
|
|
20207
|
-
|
|
20208
|
-
|
|
20538
|
+
|
|
20539
|
+
# Apply DESTROY policy to all resources in a scope
|
|
20540
|
+
RemovalPolicies.of(scope).destroy()
|
|
20541
|
+
|
|
20542
|
+
# Apply RETAIN policy to all resources in a scope
|
|
20543
|
+
RemovalPolicies.of(scope).retain()
|
|
20544
|
+
|
|
20545
|
+
# Apply SNAPSHOT policy to all resources in a scope
|
|
20546
|
+
RemovalPolicies.of(scope).snapshot()
|
|
20547
|
+
|
|
20548
|
+
# Apply RETAIN_ON_UPDATE_OR_DELETE policy to all resources in a scope
|
|
20549
|
+
RemovalPolicies.of(scope).retain_on_update_or_delete()
|
|
20550
|
+
|
|
20551
|
+
# Apply RETAIN policy only to specific resource types
|
|
20552
|
+
RemovalPolicies.of(parent).retain(
|
|
20553
|
+
apply_to_resource_types=["AWS::DynamoDB::Table", bucket.cfn_resource_type, rds.CfnDBInstance.CFN_RESOURCE_TYPE_NAME
|
|
20554
|
+
]
|
|
20555
|
+
)
|
|
20556
|
+
|
|
20557
|
+
# Apply SNAPSHOT policy excluding specific resource types
|
|
20558
|
+
RemovalPolicies.of(scope).snapshot(
|
|
20559
|
+
exclude_resource_types=["AWS::Test::Resource"]
|
|
20209
20560
|
)
|
|
20210
20561
|
'''
|
|
20211
20562
|
if __debug__:
|
|
@@ -37060,18 +37411,22 @@ class DefaultStackSynthesizer(
|
|
|
37060
37411
|
|
|
37061
37412
|
Example::
|
|
37062
37413
|
|
|
37063
|
-
|
|
37064
|
-
|
|
37065
|
-
|
|
37066
|
-
|
|
37067
|
-
|
|
37068
|
-
|
|
37069
|
-
|
|
37070
|
-
|
|
37071
|
-
|
|
37072
|
-
|
|
37073
|
-
|
|
37074
|
-
|
|
37414
|
+
class MyStack(Stack):
|
|
37415
|
+
def __init__(self, scope, id, *, description=None, env=None, stackName=None, tags=None, notificationArns=None, synthesizer=None, terminationProtection=None, analyticsReporting=None, crossRegionReferences=None, permissionsBoundary=None, suppressTemplateIndentation=None, propertyInjectors=None):
|
|
37416
|
+
super().__init__(scope, id,
|
|
37417
|
+
(SpreadAssignment ...props
|
|
37418
|
+
description=description, env=env, stackName=stackName, tags=tags, notificationArns=notificationArns, synthesizer=synthesizer, terminationProtection=terminationProtection, analyticsReporting=analyticsReporting, crossRegionReferences=crossRegionReferences, permissionsBoundary=permissionsBoundary, suppressTemplateIndentation=suppressTemplateIndentation, propertyInjectors=propertyInjectors),
|
|
37419
|
+
synthesizer=DefaultStackSynthesizer(
|
|
37420
|
+
deploy_role_external_id="",
|
|
37421
|
+
deploy_role_additional_options={},
|
|
37422
|
+
file_asset_publishing_external_id="",
|
|
37423
|
+
file_asset_publishing_role_additional_options={},
|
|
37424
|
+
image_asset_publishing_external_id="",
|
|
37425
|
+
image_asset_publishing_role_additional_options={},
|
|
37426
|
+
lookup_role_external_id="",
|
|
37427
|
+
lookup_role_additional_options={}
|
|
37428
|
+
)
|
|
37429
|
+
)
|
|
37075
37430
|
'''
|
|
37076
37431
|
|
|
37077
37432
|
def __init__(
|
aws_cdk/_jsii/__init__.py
CHANGED
|
@@ -34,7 +34,7 @@ import aws_cdk.cloud_assembly_schema._jsii
|
|
|
34
34
|
import constructs._jsii
|
|
35
35
|
|
|
36
36
|
__jsii_assembly__ = jsii.JSIIAssembly.load(
|
|
37
|
-
"aws-cdk-lib", "2.
|
|
37
|
+
"aws-cdk-lib", "2.212.0", __name__[0:-6], "aws-cdk-lib@2.212.0.jsii.tgz"
|
|
38
38
|
)
|
|
39
39
|
|
|
40
40
|
__all__ = [
|
|
Binary file
|
|
@@ -6343,6 +6343,8 @@ class CfnDeployment(
|
|
|
6343
6343
|
) -> None:
|
|
6344
6344
|
'''The ``MethodSetting`` property type configures settings for all methods in a stage.
|
|
6345
6345
|
|
|
6346
|
+
If you modify this property type, you must create a new deployment for your API.
|
|
6347
|
+
|
|
6346
6348
|
The ``MethodSettings`` property of the `Amazon API Gateway Deployment StageDescription <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-deployment-stagedescription.html>`_ property type contains a list of ``MethodSetting`` property types.
|
|
6347
6349
|
|
|
6348
6350
|
:param cache_data_encrypted: Specifies whether the cached responses are encrypted.
|