@@ -396,7 +396,7 @@ CloudFormation to re-read the secret.
396
396
## ARN manipulation
397
397
398
398
Sometimes you will need to put together or pick apart Amazon Resource Names
399
- (ARNs). The functions ` stack.formatArn() ` and ` stack.parseArn () ` exist for
399
+ (ARNs). The functions ` stack.formatArn() ` and ` stack.splitArn () ` exist for
400
400
this purpose.
401
401
402
402
` formatArn() ` can be used to build an ARN from components. It will automatically
@@ -409,12 +409,12 @@ declare const stack: Stack;
409
409
stack .formatArn ({
410
410
service: ' lambda' ,
411
411
resource: ' function' ,
412
- sep: ' : ' ,
412
+ arnFormat: ArnFormat . COLON_RESOURCE_NAME ,
413
413
resourceName: ' MyFunction'
414
414
});
415
415
```
416
416
417
- ` parseArn ()` can be used to get a single component from an ARN. ` parseArn ()`
417
+ ` splitArn ()` can be used to get a single component from an ARN. ` splitArn ()`
418
418
will correctly deal with both literal ARNs and deploy-time values (tokens),
419
419
but in case of a deploy-time value be aware that the result will be another
420
420
deploy-time value which cannot be inspected in the CDK application.
@@ -423,14 +423,13 @@ deploy-time value which cannot be inspected in the CDK application.
423
423
declare const stack: Stack ;
424
424
425
425
// Extracts the function name out of an AWS Lambda Function ARN
426
- const arnComponents = stack .parseArn (arn , ' : ' );
426
+ const arnComponents = stack .splitArn (arn , ArnFormat . COLON_RESOURCE_NAME );
427
427
const functionName = arnComponents .resourceName ;
428
428
```
429
429
430
- Note that depending on the service, the resource separator can be either
431
- ` : ` or ` / ` , and the resource name can be either the 6th or 7th
432
- component in the ARN. When using these functions, you will need to know
433
- the format of the ARN you are dealing with.
430
+ Note that the format of the resource separator depends on the service and
431
+ may be any of the values supported by ` ArnFormat ` . When dealing with these
432
+ functions, it is important to know the format of the ARN you are dealing with.
434
433
435
434
For an exhaustive list of ARN formats used in AWS, see [ AWS ARNs and
436
435
Namespaces] ( https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html )
@@ -611,7 +610,7 @@ response to the CloudFormation service and handle various error cases.
611
610
Set ` serviceToken ` to ` lambda.functionArn ` to use this provider:
612
611
613
612
``` ts
614
- const fn = new lambda .Function (this , ' MyProvider' , functionProps );
613
+ const fn = new lambda .SingletonFunction (this , ' MyProvider' , functionProps );
615
614
616
615
new CustomResource (this , ' MyResource' , {
617
616
serviceToken: fn .functionArn ,
@@ -625,7 +624,8 @@ framework designed to implement simple and slim custom resource providers. It
625
624
currently only supports Node.js-based user handlers, represents permissions as raw
626
625
JSON blobs instead of ` iam.PolicyStatement ` objects, and it does not have
627
626
support for asynchronous waiting (handler cannot exceed the 15min lambda
628
- timeout).
627
+ timeout). The ` CustomResourceProviderRuntime ` supports runtime ` nodejs12.x ` ,
628
+ ` nodejs14.x ` , ` nodejs16.x ` , ` nodejs18.x ` .
629
629
630
630
[ `@aws-cdk/core.CustomResourceProvider` ] : https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.CustomResourceProvider.html
631
631
@@ -1096,6 +1096,31 @@ declare const regionTable: CfnMapping;
1096
1096
regionTable.findInMap(Aws.REGION, 'regionName');
1097
1097
` ` `
1098
1098
1099
+ 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.
1100
+ If the mapping is not lazy or either key is an unresolved token, the call to `findInMap` will return a token that resolves to
1101
+ `{ "Fn::FindInMap" : [ "MapName", "TopLevelKey", "SecondLevelKey", { "DefaultValue": "DefaultValue" } ] }`, and the mapping will be rendered.
1102
+ Note that the `AWS::LanguageExtentions` transform is added to enable the default value functionality.
1103
+
1104
+ For example, the following code will again not produce anything in the "Mappings" section. The
1105
+ call to `findInMap` will be able to resolve the value during synthesis and simply return
1106
+ ` 'Region not found'` .
1107
+
1108
+ ` ` ` ts
1109
+ const regionTable = new CfnMapping(this, 'RegionTable', {
1110
+ mapping: {
1111
+ 'us-east-1': {
1112
+ regionName: 'US East (N. Virginia)',
1113
+ },
1114
+ 'us-east-2': {
1115
+ regionName: 'US East (Ohio)',
1116
+ },
1117
+ },
1118
+ lazy: true,
1119
+ });
1120
+
1121
+ regionTable.findInMap('us-west-1', 'regionName', 'Region not found');
1122
+ ` ` `
1123
+
1099
1124
[cfn-mappings] : https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.html
1100
1125
1101
1126
# ## Dynamic References
@@ -1187,6 +1212,13 @@ const stack = new Stack(app, 'StackName', {
1187
1212
});
1188
1213
` ` `
1189
1214
1215
+ You can also set termination protection with the setter after you've instantiated the stack.
1216
+
1217
+ ` ` ` ts
1218
+ const stack = new Stack(app, 'StackName', {});
1219
+ stack.terminationProtection = true;
1220
+ ` ` `
1221
+
1190
1222
By default, termination protection is disabled.
1191
1223
1192
1224
# ## Description
@@ -1245,6 +1277,20 @@ It's possible to synthesize the project with more Resources than the allowed (or
1245
1277
1246
1278
Set the context key `@aws-cdk/core:stackResourceLimit` with the proper value, being 0 for disable the limit of resources.
1247
1279
1280
+ # ## Template Indentation
1281
+
1282
+ The AWS CloudFormation templates generated by CDK include indentation by default.
1283
+ Indentation makes the templates more readable, but also increases their size,
1284
+ and CloudFormation templates cannot exceed 1MB.
1285
+
1286
+ It's possible to reduce the size of your templates by suppressing indentation.
1287
+
1288
+ To do this for all templates, set the context key `@aws-cdk/core:suppressTemplateIndentation` to `true`.
1289
+
1290
+ To do this for a specific stack, add a `suppressTemplateIndentation : true` property to the
1291
+ stack's `StackProps` parameter. You can also set this property to `false` to override
1292
+ the context key setting.
1293
+
1248
1294
# # App Context
1249
1295
1250
1296
[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.
@@ -1440,6 +1486,10 @@ class MyPlugin implements IPolicyValidationPluginBeta1 {
1440
1486
}
1441
1487
` ` `
1442
1488
1489
+ In addition to the name, plugins may optionally report their version (`version`
1490
+ property ) and a list of IDs of the rules they are going to evaluate (`ruleIds`
1491
+ property).
1492
+
1443
1493
Note that plugins are not allowed to modify anything in the cloud assembly. Any
1444
1494
attempt to do so will result in synthesis failure.
1445
1495
@@ -1452,4 +1502,40 @@ add it to the `postinstall`
1452
1502
[script](https://docs.npmjs.com/cli/v9/using-npm/scripts) in the `package.json`
1453
1503
file.
1454
1504
1505
+ # # Annotations
1506
+
1507
+ Construct authors can add annotations to constructs to report at three different
1508
+ levels : ` ERROR` , `WARN`, `INFO`.
1509
+
1510
+ Typically warnings are added for things that are important for the user to be
1511
+ aware of, but will not cause deployment errors in all cases. Some common
1512
+ scenarios are (non-exhaustive list) :
1513
+
1514
+ - Warn when the user needs to take a manual action, e.g. IAM policy should be
1515
+ added to an referenced resource.
1516
+ - Warn if the user configuration might not follow best practices (but is still
1517
+ valid)
1518
+ - Warn if the user is using a deprecated API
1519
+
1520
+ # ## Acknowledging Warnings
1521
+
1522
+ If you would like to run with `--strict` mode enabled (warnings will throw
1523
+ errors) it is possible to `acknowledge` warnings to make the warning go away.
1524
+
1525
+ For example, if > 10 IAM managed policies are added to an IAM Group, a warning
1526
+ will be created :
1527
+
1528
+ ` ` ` text
1529
+ IAM:Group:MaxPoliciesExceeded: You added 11 to IAM Group my-group. The maximum number of managed policies attached to an IAM group is 10.
1530
+ ` ` `
1531
+
1532
+ If you have requested a [quota increase](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html#reference_iam-quotas-entities)
1533
+ you may have the ability to add > 10 managed policies which means that this
1534
+ warning does not apply to you. You can acknowledge this by `acknowledging` the
1535
+ warning by the `id`.
1536
+
1537
+ ` ` ` ts
1538
+ Annotations.of(this).acknowledgeWarning('IAM:Group:MaxPoliciesExceeded', 'Account has quota increased to 20');
1539
+ ` ` `
1540
+
1455
1541
<!--END CORE DOCUMENTATION-->
0 commit comments