Skip to content

Commit 33c32a8

Browse files
authored
feat(core): Pre-concatenate Fn::Join (#967)
This restores the pre-concatenation of `Fn::Join` fragments that was introduced in #916 and reverted in #958 due to an other feature part of the same commit. The goal is to pre-concatenate the string literals present in the concatenated values, and flatten `Fn::Join` nested under another `Fn::Join` using the same delimiter, so as to produce more readable CloudFormation templates. Additionally, if the `Fn::Join` pre-concatenation results in a single string being left, then the `Fn::Join` intrinsic is erased and replaced with a string literal.
1 parent 1626c37 commit 33c32a8

File tree

61 files changed

+930
-1964
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+930
-1964
lines changed

packages/@aws-cdk/assets/test/integ.assets.directory.lit.expected.json

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,11 @@
3030
"Fn::Join": [
3131
"",
3232
[
33-
"arn",
34-
":",
33+
"arn:",
3534
{
3635
"Ref": "AWS::Partition"
3736
},
38-
":",
39-
"s3",
40-
":",
41-
"",
42-
":",
43-
"",
44-
":",
37+
":s3:::",
4538
{
4639
"Ref": "SampleAssetS3BucketE6B2908E"
4740
}
@@ -52,50 +45,29 @@
5245
"Fn::Join": [
5346
"",
5447
[
48+
"arn:",
5549
{
56-
"Fn::Join": [
57-
"",
58-
[
59-
"arn",
60-
":",
61-
{
62-
"Ref": "AWS::Partition"
63-
},
64-
":",
65-
"s3",
66-
":",
67-
"",
68-
":",
69-
"",
70-
":",
71-
{
72-
"Ref": "SampleAssetS3BucketE6B2908E"
73-
}
74-
]
75-
]
50+
"Ref": "AWS::Partition"
51+
},
52+
":s3:::",
53+
{
54+
"Ref": "SampleAssetS3BucketE6B2908E"
7655
},
7756
"/",
7857
{
79-
"Fn::Join": [
80-
"",
81-
[
82-
{
83-
"Fn::Select": [
84-
0,
85-
{
86-
"Fn::Split": [
87-
"||",
88-
{
89-
"Ref": "SampleAssetS3VersionKey3E106D34"
90-
}
91-
]
92-
}
93-
]
94-
},
95-
"*"
96-
]
58+
"Fn::Select": [
59+
0,
60+
{
61+
"Fn::Split": [
62+
"||",
63+
{
64+
"Ref": "SampleAssetS3VersionKey3E106D34"
65+
}
66+
]
67+
}
9768
]
98-
}
69+
},
70+
"*"
9971
]
10072
]
10173
}

packages/@aws-cdk/assets/test/integ.assets.file.lit.expected.json

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,11 @@
3030
"Fn::Join": [
3131
"",
3232
[
33-
"arn",
34-
":",
33+
"arn:",
3534
{
3635
"Ref": "AWS::Partition"
3736
},
38-
":",
39-
"s3",
40-
":",
41-
"",
42-
":",
43-
"",
44-
":",
37+
":s3:::",
4538
{
4639
"Ref": "SampleAssetS3BucketE6B2908E"
4740
}
@@ -52,50 +45,29 @@
5245
"Fn::Join": [
5346
"",
5447
[
48+
"arn:",
5549
{
56-
"Fn::Join": [
57-
"",
58-
[
59-
"arn",
60-
":",
61-
{
62-
"Ref": "AWS::Partition"
63-
},
64-
":",
65-
"s3",
66-
":",
67-
"",
68-
":",
69-
"",
70-
":",
71-
{
72-
"Ref": "SampleAssetS3BucketE6B2908E"
73-
}
74-
]
75-
]
50+
"Ref": "AWS::Partition"
51+
},
52+
":s3:::",
53+
{
54+
"Ref": "SampleAssetS3BucketE6B2908E"
7655
},
7756
"/",
7857
{
79-
"Fn::Join": [
80-
"",
81-
[
82-
{
83-
"Fn::Select": [
84-
0,
85-
{
86-
"Fn::Split": [
87-
"||",
88-
{
89-
"Ref": "SampleAssetS3VersionKey3E106D34"
90-
}
91-
]
92-
}
93-
]
94-
},
95-
"*"
96-
]
58+
"Fn::Select": [
59+
0,
60+
{
61+
"Fn::Split": [
62+
"||",
63+
{
64+
"Ref": "SampleAssetS3VersionKey3E106D34"
65+
}
66+
]
67+
}
9768
]
98-
}
69+
},
70+
"*"
9971
]
10072
]
10173
}

packages/@aws-cdk/assets/test/integ.assets.permissions.lit.expected.json

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,11 @@
3030
"Fn::Join": [
3131
"",
3232
[
33-
"arn",
34-
":",
33+
"arn:",
3534
{
3635
"Ref": "AWS::Partition"
3736
},
38-
":",
39-
"s3",
40-
":",
41-
"",
42-
":",
43-
"",
44-
":",
37+
":s3:::",
4538
{
4639
"Ref": "MyFileS3BucketACE13C36"
4740
}
@@ -52,50 +45,29 @@
5245
"Fn::Join": [
5346
"",
5447
[
48+
"arn:",
5549
{
56-
"Fn::Join": [
57-
"",
58-
[
59-
"arn",
60-
":",
61-
{
62-
"Ref": "AWS::Partition"
63-
},
64-
":",
65-
"s3",
66-
":",
67-
"",
68-
":",
69-
"",
70-
":",
71-
{
72-
"Ref": "MyFileS3BucketACE13C36"
73-
}
74-
]
75-
]
50+
"Ref": "AWS::Partition"
51+
},
52+
":s3:::",
53+
{
54+
"Ref": "MyFileS3BucketACE13C36"
7655
},
7756
"/",
7857
{
79-
"Fn::Join": [
80-
"",
81-
[
82-
{
83-
"Fn::Select": [
84-
0,
85-
{
86-
"Fn::Split": [
87-
"||",
88-
{
89-
"Ref": "MyFileS3VersionKey568C3C9F"
90-
}
91-
]
92-
}
93-
]
94-
},
95-
"*"
96-
]
58+
"Fn::Select": [
59+
0,
60+
{
61+
"Fn::Split": [
62+
"||",
63+
{
64+
"Ref": "MyFileS3VersionKey568C3C9F"
65+
}
66+
]
67+
}
9768
]
98-
}
69+
},
70+
"*"
9971
]
10072
]
10173
}

0 commit comments

Comments
 (0)