-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(cfn-include): add support for the Fn::Sub function #9275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
db60c27
doc: added slack link to readme
comcalvi 5924f3b
Merge branch 'master' into master
comcalvi f0c85a3
Update README.md
comcalvi f37e60e
Merge branch 'master' into master
mergify[bot] 83ed743
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi c6664af
added support for Fn::Select, Fn::FindInMap, Fn::Cidr, Fn::GetAZs, Fn…
comcalvi d0f64d2
added support for the 'Fn::Transform' cloudformation intrinsic function.
comcalvi d69e46d
added support for the Fn::Base64 Intrinsic Function
comcalvi df1446a
tested more complex combinations of conditional and non-conditional i…
comcalvi 132cb4d
fixed linter issues
comcalvi ae7c570
implmented Adam's requests and fixed additional linter issues
comcalvi 7ca707e
updated README to reflect the newly supported cloudformation functions
comcalvi 63c27a7
removed quotes from the type of Transform's parameter argument, modif…
comcalvi 4179271
fixed teseting issue related to Fn::Select
comcalvi 117ae63
Merge branch 'master' into CfnFunctions
comcalvi dbb9ef8
fixing merge conflicts
comcalvi bdab761
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi d390580
Merge branch 'master' of https://github.com/aws/aws-cdk into CfnFunct…
comcalvi 14a0d64
merge conflict resolution
comcalvi dfb42b9
Merge branch 'CfnFunctions' of github.com:comcalvi/aws-cdk into CfnFu…
comcalvi 9f1b2d9
Merge branch 'master' of https://github.com/aws/aws-cdk into CfnFunct…
comcalvi 4c9d1ec
fixed typo in condition name
comcalvi e15c187
Merge branch 'CfnFunctions'
comcalvi 82c4317
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi 42c0228
removed parameters from _toCloudFormation()
comcalvi 6a2df1e
added support for parameters in templates
comcalvi 43198b7
fixed merge conflict
comcalvi cd27ff6
updated documentation
comcalvi 1e72465
updated readme
comcalvi 070f902
incorporated adam's comments
comcalvi b10a1ed
fixed spacing
comcalvi 68d2fbc
fixed merge conflicts
comcalvi 225d1ce
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi badeae8
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi 5bf4760
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi 479931e
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi c3fa10e
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi 685d57d
added outputs array
comcalvi e334814
added support for retrieving and modifying outputs
comcalvi 34d5c34
fixed linter issues
comcalvi 95badbe
updated README
comcalvi fa39d72
updated documentation
comcalvi a3940e3
removed unneeded line in tests
comcalvi fbf17f2
added newline
comcalvi c719e85
incorporated PR requests
comcalvi f05aae1
updated the example in the readme
comcalvi 69223d2
added support for common-named outputs. Fixed a bug in the export nam…
comcalvi 0c55180
added a negative test case and a new error message if an output refer…
comcalvi 7557a00
incorporated changes to PR
comcalvi 356fc8f
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi 6c62755
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi 783e1f4
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi 0e59c33
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi 98498d1
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi 8d5deff
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi 59abb94
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi 3b902af
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi bdc9fd1
Merge branch 'master' of https://github.com/aws/aws-cdk
comcalvi 0541ded
added fn::sub now turns into fn::join in cfnInclude
comcalvi f7f6a25
added a new way to resolve tokens
comcalvi 344d3e9
we now support pseudo parameters
comcalvi 2d95d9d
added full support for the string form of Fn::Sub, including literals
comcalvi d6406fa
added support for basic usage of both Fn::Sub forms.
comcalvi 2ac07ef
refactored code and improved testing
comcalvi 40520d0
substantially refactored the parsing of the string argument to Fn::Sub
comcalvi ae3a04b
improved tests and refactored implementation
comcalvi ea0372d
improved documentation
comcalvi 6ecf479
updated README
comcalvi bb03256
added support for yaml templates that use Fn::Sub
comcalvi 970fa59
incorporated review comments
comcalvi 1d91d61
incorporated review requests, improved testing
comcalvi 58a3496
added newline
comcalvi 3067019
Update the type of specialCaseSubRefs like in the comment
skinny85 4932e78
Remove the redundant map || {} expression
skinny85 35850a9
Merge branch 'master' into sub
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
55 changes: 55 additions & 0 deletions
55
packages/@aws-cdk/cloudformation-include/test/test-templates/fn-sub-brace-edges.json
This file contains hidden or 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,55 @@ | ||
| { | ||
| "Resources": { | ||
| "Bucket": { | ||
| "Type": "Custom::ManyStrings", | ||
| "Properties": { | ||
| "SymbolsOnly": { | ||
| "DollarSign": { | ||
| "Fn::Sub": "$" | ||
| }, | ||
| "OpeningBrace": { | ||
| "Fn::Sub": "{" | ||
| }, | ||
| "ClosingBrace": { | ||
| "Fn::Sub": "}" | ||
| }, | ||
| "DollarOpeningBrace": { | ||
| "Fn::Sub": "${" | ||
| }, | ||
| "DollarClosingBrace": { | ||
| "Fn::Sub": "$}" | ||
| }, | ||
| "OpeningBraceDollar": { | ||
| "Fn::Sub": "{$" | ||
| }, | ||
| "ClosingBraceDollar": { | ||
| "Fn::Sub": "}$" | ||
| } | ||
| }, | ||
| "SymbolsAndResources": { | ||
| "DollarSign": { | ||
| "Fn::Sub": "DoesNotExist$DoesNotExist" | ||
| }, | ||
| "OpeningBrace": { | ||
| "Fn::Sub": "DoesNotExist{DoesNotExist" | ||
| }, | ||
| "ClosingBrace": { | ||
| "Fn::Sub": "DoesNotExist}DoesNotExist" | ||
| }, | ||
| "DollarOpeningBrace": { | ||
| "Fn::Sub": "DoesNotExist${DoesNotExist" | ||
| }, | ||
| "DollarClosingBrace": { | ||
| "Fn::Sub": "DoesNotExist$}DoesNotExist" | ||
| }, | ||
| "OpeningBraceDollar": { | ||
| "Fn::Sub": "DoesNotExist{$DoesNotExist" | ||
| }, | ||
| "ClosingBraceDollar": { | ||
| "Fn::Sub": "DoesNotExist}$DoesNotExist" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
packages/@aws-cdk/cloudformation-include/test/test-templates/fn-sub-escaping.json
This file contains hidden or 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,10 @@ | ||
| { | ||
| "Resources": { | ||
| "Bucket": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "Properties": { | ||
| "BucketName": { "Fn::Sub": "some-bucket${!AWS::AccountId}7896${ ! DoesNotExist}${!Immediate}234" } | ||
| } | ||
| } | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
...ges/@aws-cdk/cloudformation-include/test/test-templates/fn-sub-map-dotted-attributes.json
This file contains hidden or 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,25 @@ | ||
| { | ||
| "Resources": { | ||
| "Bucket": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "Properties": { | ||
| "BucketName": { | ||
| "Fn::Sub": "${ELB.SourceSecurityGroup.GroupName}" | ||
| } | ||
| } | ||
| }, | ||
| "ELB": { | ||
| "Type": "AWS::ElasticLoadBalancing::LoadBalancer", | ||
| "Properties": { | ||
| "AvailabilityZones": [ | ||
| "us-east-1a" | ||
| ], | ||
| "Listeners": [{ | ||
| "LoadBalancerPort": "80", | ||
| "InstancePort": "80", | ||
| "Protocol": "HTTP" | ||
| }] | ||
| } | ||
| } | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
packages/@aws-cdk/cloudformation-include/test/test-templates/fn-sub-override.json
This file contains hidden or 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,16 @@ | ||
| { | ||
| "Resources": { | ||
| "Bucket": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "Properties": { | ||
| "BucketName": "bucket" | ||
| } | ||
| }, | ||
| "AnotherBucket": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "Properties": { | ||
| "BucketName": { "Fn::Sub": "${Bucket}-${!Bucket}-${Bucket.DomainName}" } | ||
| } | ||
| } | ||
| } | ||
| } |
Empty file.
20 changes: 20 additions & 0 deletions
20
packages/@aws-cdk/cloudformation-include/test/test-templates/fn-sub-shadow-attribute.json
This file contains hidden or 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,20 @@ | ||
| { | ||
| "Resources": { | ||
| "Bucket": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "Properties": { | ||
| "BucketName": { | ||
| "Fn::Sub": [ | ||
| "${AnotherBucket.DomainName}", | ||
comcalvi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| "AnotherBucket": "whatever" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "AnotherBucket": { | ||
| "Type": "AWS::S3::Bucket" | ||
| } | ||
| } | ||
| } | ||
20 changes: 20 additions & 0 deletions
20
packages/@aws-cdk/cloudformation-include/test/test-templates/fn-sub-shadow.json
This file contains hidden or 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,20 @@ | ||
| { | ||
| "Resources": { | ||
| "Bucket": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "Properties": { | ||
| "BucketName": { | ||
| "Fn::Sub": [ | ||
| "${AnotherBucket}", | ||
| { | ||
| "AnotherBucket": { "Ref" : "AnotherBucket" } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "AnotherBucket": { | ||
| "Type": "AWS::S3::Bucket" | ||
| } | ||
| } | ||
| } | ||
comcalvi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
16 changes: 16 additions & 0 deletions
16
packages/@aws-cdk/cloudformation-include/test/test-templates/fn-sub-string.json
This file contains hidden or 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,16 @@ | ||
| { | ||
| "Resources": { | ||
| "Bucket": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "Properties": { | ||
| "BucketName": "bucket" | ||
| } | ||
| }, | ||
| "AnotherBucket": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "Properties": { | ||
| "BucketName": { "Fn::Sub": "1-${AWS::Region}-foo-${Bucket}-${!Literal}-${Bucket.DomainName}-${AWS::Region}" } | ||
| } | ||
| } | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
packages/@aws-cdk/cloudformation-include/test/test-templates/invalid/fn-sub-${}-only.json
This file contains hidden or 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 @@ | ||
| { | ||
| "Resources": { | ||
| "Bucket": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "Properties": { | ||
| "BucketName": { | ||
| "Fn::Sub": "${}" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
...cloudformation-include/test/test-templates/invalid/fn-sub-key-not-in-template-string.json
This file contains hidden or 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,10 @@ | ||
| { | ||
| "Resources": { | ||
| "Bucket": { | ||
| "Type": "AWS::S3::Bucket", | ||
| "Properties": { | ||
| "AccessControl": { "Fn::Sub": "${AFakeResource}" } | ||
| } | ||
| } | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
...ws-cdk/cloudformation-include/test/test-templates/yaml/invalid/short-form-import-sub.yaml
This file contains hidden or 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,7 @@ | ||
| Resources: | ||
| Bucket: | ||
| Type: AWS::S3::Bucket | ||
| Properties: | ||
| BucketName: | ||
| !ImportValue | ||
| !Sub ${AWS::Region} |
This file contains hidden or 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
11 changes: 11 additions & 0 deletions
11
...ges/@aws-cdk/cloudformation-include/test/test-templates/yaml/short-form-fnsub-string.yaml
This file contains hidden or 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,11 @@ | ||
| Resources: | ||
| Bucket: | ||
| Type: AWS::S3::Bucket | ||
| Properties: | ||
| BucketName: | ||
| Fn::Sub: some-bucket${!AWS::AccountId}7896${ ! AWS::Region}1-1${!Immediate}234 | ||
| AnotherBucket: | ||
| Type: AWS::S3::Bucket | ||
| Properties: | ||
| BucketName: | ||
| !Sub 1-${AWS::Region}-foo-${Bucket}-${!Literal}-${Bucket.DomainName}-${AWS::Region} |
15 changes: 15 additions & 0 deletions
15
packages/@aws-cdk/cloudformation-include/test/test-templates/yaml/short-form-sub-map.yaml
This file contains hidden or 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,15 @@ | ||
| Resources: | ||
| Bucket: | ||
| Type: AWS::S3::Bucket | ||
| Properties: | ||
| BucketName: | ||
| !Sub | ||
| - "${Region}-foo-${!Immediate}-foo-${AnotherBucket}-${AnotherBucket.DomainName}-${Name}" | ||
| - Name: | ||
| Ref: AnotherBucket | ||
| Region: | ||
| Fn::Base64: AWS::Region | ||
| AnotherBucket: | ||
| Type: AWS::S3::Bucket | ||
| Properties: | ||
| BucketName: another-bucket |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.