-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Fn.findInMap supports default value (#26543)
Cloudformation recently [added support](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-findinmap-enhancements.html) for a default value in the FindInMap intrinsic function. This adds that support. Closes #26125. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
13 changed files
with
840 additions
and
22 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...ind-in-map.js.snapshot/CfnMappingFindInMapTestDefaultTestDeployAssertEA32B10D.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "32.0.0", | ||
"files": { | ||
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { | ||
"source": { | ||
"path": "CfnMappingFindInMapTestDefaultTestDeployAssertEA32B10D.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
36 changes: 36 additions & 0 deletions
36
...d-in-map.js.snapshot/CfnMappingFindInMapTestDefaultTestDeployAssertEA32B10D.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...testing/framework-integ/test/core/test/integ.cfn-mappings-find-in-map.js.snapshot/cdk.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":"32.0.0"} |
19 changes: 19 additions & 0 deletions
19
.../test/core/test/integ.cfn-mappings-find-in-map.js.snapshot/core-cfn-mapping-1.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "32.0.0", | ||
"files": { | ||
"175902e9c94a814a5739a092426ef29b46a5098db6118c5c464b507fa4e867e5": { | ||
"source": { | ||
"path": "core-cfn-mapping-1.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "175902e9c94a814a5739a092426ef29b46a5098db6118c5c464b507fa4e867e5.json", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
120 changes: 120 additions & 0 deletions
120
...est/core/test/integ.cfn-mappings-find-in-map.js.snapshot/core-cfn-mapping-1.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
{ | ||
"Transform": [ | ||
"AWS::LanguageExtensions" | ||
], | ||
"Mappings": { | ||
"Regularmapping": { | ||
"TopLevelKey1": { | ||
"SecondLevelKey1": "Yes", | ||
"SecondLevelKey2": "No" | ||
} | ||
}, | ||
"Lazymapping": { | ||
"TopLevelKey1": { | ||
"SecondLevelKey1": "Yes", | ||
"SecondLevelKey2": "No" | ||
} | ||
} | ||
}, | ||
"Outputs": { | ||
"Output0": { | ||
"Value": { | ||
"Fn::FindInMap": [ | ||
"Regularmapping", | ||
"TopLevelKey1", | ||
"SecondLevelKey1", | ||
{ | ||
"DefaultValue": "foob" | ||
} | ||
] | ||
} | ||
}, | ||
"Output1": { | ||
"Value": { | ||
"Fn::FindInMap": [ | ||
"Regularmapping", | ||
"TopLevelKey1", | ||
{ | ||
"Ref": "AWS::Region" | ||
}, | ||
{ | ||
"DefaultValue": "foob" | ||
} | ||
] | ||
} | ||
}, | ||
"Output2": { | ||
"Value": { | ||
"Fn::FindInMap": [ | ||
"Regularmapping", | ||
"TopLevelKey1", | ||
"SecondLevelKey3", | ||
{ | ||
"DefaultValue": "foob" | ||
} | ||
] | ||
} | ||
}, | ||
"Output3": { | ||
"Value": "No" | ||
}, | ||
"Output4": { | ||
"Value": "bart" | ||
}, | ||
"Output5": { | ||
"Value": { | ||
"Fn::FindInMap": [ | ||
"Lazymapping", | ||
{ | ||
"Ref": "AWS::Region" | ||
}, | ||
"SecondLevelKey2", | ||
{ | ||
"DefaultValue": "bart" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"Resources": { | ||
"CfnMappingFindInMapBucket6F72FEE7": { | ||
"Type": "AWS::S3::Bucket", | ||
"UpdateReplacePolicy": "Retain", | ||
"DeletionPolicy": "Retain" | ||
} | ||
}, | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ting/framework-integ/test/core/test/integ.cfn-mappings-find-in-map.js.snapshot/integ.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": "32.0.0", | ||
"testCases": { | ||
"CfnMappingFindInMapTest/DefaultTest": { | ||
"stacks": [ | ||
"core-cfn-mapping-1" | ||
], | ||
"assertionStack": "CfnMappingFindInMapTest/DefaultTest/DeployAssert", | ||
"assertionStackName": "CfnMappingFindInMapTestDefaultTestDeployAssertEA32B10D" | ||
} | ||
} | ||
} |
159 changes: 159 additions & 0 deletions
159
...g/framework-integ/test/core/test/integ.cfn-mappings-find-in-map.js.snapshot/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
{ | ||
"version": "32.0.0", | ||
"artifacts": { | ||
"core-cfn-mapping-1.assets": { | ||
"type": "cdk:asset-manifest", | ||
"properties": { | ||
"file": "core-cfn-mapping-1.assets.json", | ||
"requiresBootstrapStackVersion": 6, | ||
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" | ||
} | ||
}, | ||
"core-cfn-mapping-1": { | ||
"type": "aws:cloudformation:stack", | ||
"environment": "aws://unknown-account/unknown-region", | ||
"properties": { | ||
"templateFile": "core-cfn-mapping-1.template.json", | ||
"validateOnSynth": false, | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", | ||
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", | ||
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/175902e9c94a814a5739a092426ef29b46a5098db6118c5c464b507fa4e867e5.json", | ||
"requiresBootstrapStackVersion": 6, | ||
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", | ||
"additionalDependencies": [ | ||
"core-cfn-mapping-1.assets" | ||
], | ||
"lookupRole": { | ||
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", | ||
"requiresBootstrapStackVersion": 8, | ||
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" | ||
} | ||
}, | ||
"dependencies": [ | ||
"core-cfn-mapping-1.assets" | ||
], | ||
"metadata": { | ||
"/core-cfn-mapping-1/Regular mapping": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "Regularmapping" | ||
} | ||
], | ||
"/core-cfn-mapping-1/Lazy mapping": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "Lazymapping" | ||
} | ||
], | ||
"/core-cfn-mapping-1/Output0": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "Output0" | ||
} | ||
], | ||
"/core-cfn-mapping-1/Output1": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "Output1" | ||
} | ||
], | ||
"/core-cfn-mapping-1/Output2": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "Output2" | ||
} | ||
], | ||
"/core-cfn-mapping-1/Output3": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "Output3" | ||
} | ||
], | ||
"/core-cfn-mapping-1/Output4": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "Output4" | ||
} | ||
], | ||
"/core-cfn-mapping-1/Output5": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "Output5" | ||
} | ||
], | ||
"/core-cfn-mapping-1/CfnMappingFindInMapBucket/Resource": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "CfnMappingFindInMapBucket6F72FEE7" | ||
} | ||
], | ||
"/core-cfn-mapping-1/BootstrapVersion": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "BootstrapVersion" | ||
} | ||
], | ||
"/core-cfn-mapping-1/CheckBootstrapVersion": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "CheckBootstrapVersion" | ||
} | ||
] | ||
}, | ||
"displayName": "core-cfn-mapping-1" | ||
}, | ||
"CfnMappingFindInMapTestDefaultTestDeployAssertEA32B10D.assets": { | ||
"type": "cdk:asset-manifest", | ||
"properties": { | ||
"file": "CfnMappingFindInMapTestDefaultTestDeployAssertEA32B10D.assets.json", | ||
"requiresBootstrapStackVersion": 6, | ||
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" | ||
} | ||
}, | ||
"CfnMappingFindInMapTestDefaultTestDeployAssertEA32B10D": { | ||
"type": "aws:cloudformation:stack", | ||
"environment": "aws://unknown-account/unknown-region", | ||
"properties": { | ||
"templateFile": "CfnMappingFindInMapTestDefaultTestDeployAssertEA32B10D.template.json", | ||
"validateOnSynth": false, | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", | ||
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", | ||
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", | ||
"requiresBootstrapStackVersion": 6, | ||
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", | ||
"additionalDependencies": [ | ||
"CfnMappingFindInMapTestDefaultTestDeployAssertEA32B10D.assets" | ||
], | ||
"lookupRole": { | ||
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", | ||
"requiresBootstrapStackVersion": 8, | ||
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" | ||
} | ||
}, | ||
"dependencies": [ | ||
"CfnMappingFindInMapTestDefaultTestDeployAssertEA32B10D.assets" | ||
], | ||
"metadata": { | ||
"/CfnMappingFindInMapTest/DefaultTest/DeployAssert/BootstrapVersion": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "BootstrapVersion" | ||
} | ||
], | ||
"/CfnMappingFindInMapTest/DefaultTest/DeployAssert/CheckBootstrapVersion": [ | ||
{ | ||
"type": "aws:cdk:logicalId", | ||
"data": "CheckBootstrapVersion" | ||
} | ||
] | ||
}, | ||
"displayName": "CfnMappingFindInMapTest/DefaultTest/DeployAssert" | ||
}, | ||
"Tree": { | ||
"type": "cdk:tree", | ||
"properties": { | ||
"file": "tree.json" | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.