Skip to content

Commit 0aee083

Browse files
authored
feat(core): support bundling for single non-archive file (#26106)
This PR adds a possibility to use local bundling and let the final asset be one single file that is uploaded as-is. This can be used for several types of assets, e.g. AppSync functions. In contrast to Lambda, these functions to not expect the asset to be a zip file. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 7af20ba commit 0aee083

15 files changed

+635
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "32.0.0",
3+
"files": {
4+
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
5+
"source": {
6+
"path": "IntegTestDefaultTestDeployAssertE3E7D2A4.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Parameters": {
3+
"BootstrapVersion": {
4+
"Type": "AWS::SSM::Parameter::Value<String>",
5+
"Default": "/cdk-bootstrap/hnb659fds/version",
6+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
7+
}
8+
},
9+
"Rules": {
10+
"CheckBootstrapVersion": {
11+
"Assertions": [
12+
{
13+
"Assert": {
14+
"Fn::Not": [
15+
{
16+
"Fn::Contains": [
17+
[
18+
"1",
19+
"2",
20+
"3",
21+
"4",
22+
"5"
23+
],
24+
{
25+
"Ref": "BootstrapVersion"
26+
}
27+
]
28+
}
29+
]
30+
},
31+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
32+
}
33+
]
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h3>This is a sample file</h3>
2+
3+
<p>With <strong>markdown</strong></p>

packages/@aws-cdk-testing/framework-integ/test/aws-s3-assets/test/integ.assets.file-bundling.lit.js.snapshot/asset.68c2f55451f9566ae0c08664249d08921ab032b2aea797bd8ba293885bf00d64/index.html

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "32.0.0",
3+
"files": {
4+
"68c2f55451f9566ae0c08664249d08921ab032b2aea797bd8ba293885bf00d64": {
5+
"source": {
6+
"path": "asset.68c2f55451f9566ae0c08664249d08921ab032b2aea797bd8ba293885bf00d64.html",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "68c2f55451f9566ae0c08664249d08921ab032b2aea797bd8ba293885bf00d64.html",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
},
17+
"90c0edfc12d01dfffaee94d9f09e061a7db55c839a6105e5a94f9d96dc51e4fd": {
18+
"source": {
19+
"path": "cdk-integ-assets-bundling.template.json",
20+
"packaging": "file"
21+
},
22+
"destinations": {
23+
"current_account-current_region": {
24+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25+
"objectKey": "90c0edfc12d01dfffaee94d9f09e061a7db55c839a6105e5a94f9d96dc51e4fd.json",
26+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
27+
}
28+
}
29+
}
30+
},
31+
"dockerImages": {}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"Resources": {
3+
"MyUserDC45028B": {
4+
"Type": "AWS::IAM::User"
5+
},
6+
"MyUserDefaultPolicy7B897426": {
7+
"Type": "AWS::IAM::Policy",
8+
"Properties": {
9+
"PolicyDocument": {
10+
"Statement": [
11+
{
12+
"Action": [
13+
"s3:GetBucket*",
14+
"s3:GetObject*",
15+
"s3:List*"
16+
],
17+
"Effect": "Allow",
18+
"Resource": [
19+
{
20+
"Fn::Join": [
21+
"",
22+
[
23+
"arn:",
24+
{
25+
"Ref": "AWS::Partition"
26+
},
27+
":s3:::",
28+
{
29+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
30+
},
31+
"/*"
32+
]
33+
]
34+
},
35+
{
36+
"Fn::Join": [
37+
"",
38+
[
39+
"arn:",
40+
{
41+
"Ref": "AWS::Partition"
42+
},
43+
":s3:::",
44+
{
45+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
46+
}
47+
]
48+
]
49+
}
50+
]
51+
}
52+
],
53+
"Version": "2012-10-17"
54+
},
55+
"PolicyName": "MyUserDefaultPolicy7B897426",
56+
"Users": [
57+
{
58+
"Ref": "MyUserDC45028B"
59+
}
60+
]
61+
}
62+
}
63+
},
64+
"Parameters": {
65+
"BootstrapVersion": {
66+
"Type": "AWS::SSM::Parameter::Value<String>",
67+
"Default": "/cdk-bootstrap/hnb659fds/version",
68+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
69+
}
70+
},
71+
"Rules": {
72+
"CheckBootstrapVersion": {
73+
"Assertions": [
74+
{
75+
"Assert": {
76+
"Fn::Not": [
77+
{
78+
"Fn::Contains": [
79+
[
80+
"1",
81+
"2",
82+
"3",
83+
"4",
84+
"5"
85+
],
86+
{
87+
"Ref": "BootstrapVersion"
88+
}
89+
]
90+
}
91+
]
92+
},
93+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
94+
}
95+
]
96+
}
97+
}
98+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"32.0.0"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "32.0.0",
3+
"testCases": {
4+
"IntegTest/DefaultTest": {
5+
"stacks": [
6+
"cdk-integ-assets-bundling"
7+
],
8+
"assertionStack": "IntegTest/DefaultTest/DeployAssert",
9+
"assertionStackName": "IntegTestDefaultTestDeployAssertE3E7D2A4"
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
{
2+
"version": "32.0.0",
3+
"artifacts": {
4+
"cdk-integ-assets-bundling.assets": {
5+
"type": "cdk:asset-manifest",
6+
"properties": {
7+
"file": "cdk-integ-assets-bundling.assets.json",
8+
"requiresBootstrapStackVersion": 6,
9+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
10+
}
11+
},
12+
"cdk-integ-assets-bundling": {
13+
"type": "aws:cloudformation:stack",
14+
"environment": "aws://unknown-account/unknown-region",
15+
"properties": {
16+
"templateFile": "cdk-integ-assets-bundling.template.json",
17+
"validateOnSynth": false,
18+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
19+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/90c0edfc12d01dfffaee94d9f09e061a7db55c839a6105e5a94f9d96dc51e4fd.json",
21+
"requiresBootstrapStackVersion": 6,
22+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
23+
"additionalDependencies": [
24+
"cdk-integ-assets-bundling.assets"
25+
],
26+
"lookupRole": {
27+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
28+
"requiresBootstrapStackVersion": 8,
29+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
30+
}
31+
},
32+
"dependencies": [
33+
"cdk-integ-assets-bundling.assets"
34+
],
35+
"metadata": {
36+
"/cdk-integ-assets-bundling/MyUser/Resource": [
37+
{
38+
"type": "aws:cdk:logicalId",
39+
"data": "MyUserDC45028B"
40+
}
41+
],
42+
"/cdk-integ-assets-bundling/MyUser/DefaultPolicy/Resource": [
43+
{
44+
"type": "aws:cdk:logicalId",
45+
"data": "MyUserDefaultPolicy7B897426"
46+
}
47+
],
48+
"/cdk-integ-assets-bundling/BootstrapVersion": [
49+
{
50+
"type": "aws:cdk:logicalId",
51+
"data": "BootstrapVersion"
52+
}
53+
],
54+
"/cdk-integ-assets-bundling/CheckBootstrapVersion": [
55+
{
56+
"type": "aws:cdk:logicalId",
57+
"data": "CheckBootstrapVersion"
58+
}
59+
]
60+
},
61+
"displayName": "cdk-integ-assets-bundling"
62+
},
63+
"IntegTestDefaultTestDeployAssertE3E7D2A4.assets": {
64+
"type": "cdk:asset-manifest",
65+
"properties": {
66+
"file": "IntegTestDefaultTestDeployAssertE3E7D2A4.assets.json",
67+
"requiresBootstrapStackVersion": 6,
68+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
69+
}
70+
},
71+
"IntegTestDefaultTestDeployAssertE3E7D2A4": {
72+
"type": "aws:cloudformation:stack",
73+
"environment": "aws://unknown-account/unknown-region",
74+
"properties": {
75+
"templateFile": "IntegTestDefaultTestDeployAssertE3E7D2A4.template.json",
76+
"validateOnSynth": false,
77+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
78+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
79+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
80+
"requiresBootstrapStackVersion": 6,
81+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
82+
"additionalDependencies": [
83+
"IntegTestDefaultTestDeployAssertE3E7D2A4.assets"
84+
],
85+
"lookupRole": {
86+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
87+
"requiresBootstrapStackVersion": 8,
88+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
89+
}
90+
},
91+
"dependencies": [
92+
"IntegTestDefaultTestDeployAssertE3E7D2A4.assets"
93+
],
94+
"metadata": {
95+
"/IntegTest/DefaultTest/DeployAssert/BootstrapVersion": [
96+
{
97+
"type": "aws:cdk:logicalId",
98+
"data": "BootstrapVersion"
99+
}
100+
],
101+
"/IntegTest/DefaultTest/DeployAssert/CheckBootstrapVersion": [
102+
{
103+
"type": "aws:cdk:logicalId",
104+
"data": "CheckBootstrapVersion"
105+
}
106+
]
107+
},
108+
"displayName": "IntegTest/DefaultTest/DeployAssert"
109+
},
110+
"Tree": {
111+
"type": "cdk:tree",
112+
"properties": {
113+
"file": "tree.json"
114+
}
115+
}
116+
}
117+
}

0 commit comments

Comments
 (0)