Skip to content

Commit 4f2b757

Browse files
feat(stepfunctions-tasks): start build batch integration (#29296)
### Issue # (if applicable) Closes #29119. ### Reason for this change There is an optimized integration with codebuild but it is not able to integrate by AWS CDK. ### Description of changes Add CodeBuildStartBuildBatch class ```ts declare const project: codebuild.Project; const buildconfig = project.enableBatchBuilds(); const startBuildBatch = new tasks.CodeBuildStartBuildBatch(this, 'buildTask', { project, integrationPattern: sfn.IntegrationPattern.REQUEST_RESPONSE, environmentVariablesOverride: { test: { type: codebuild.BuildEnvironmentVariableType.PLAINTEXT, value: 'testValue', }, }, }); ``` ### Description of how you validated changes I've implemented both unit and integ tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent f5e7717 commit 4f2b757

File tree

13 files changed

+1695
-0
lines changed

13 files changed

+1695
-0
lines changed

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,364 @@
1+
{
2+
"Resources": {
3+
"ProjectRole4CCB274E": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "codebuild.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
}
18+
}
19+
},
20+
"ProjectRoleDefaultPolicy7F29461B": {
21+
"Type": "AWS::IAM::Policy",
22+
"Properties": {
23+
"PolicyDocument": {
24+
"Statement": [
25+
{
26+
"Action": [
27+
"logs:CreateLogGroup",
28+
"logs:CreateLogStream",
29+
"logs:PutLogEvents"
30+
],
31+
"Effect": "Allow",
32+
"Resource": [
33+
{
34+
"Fn::Join": [
35+
"",
36+
[
37+
"arn:",
38+
{
39+
"Ref": "AWS::Partition"
40+
},
41+
":logs:",
42+
{
43+
"Ref": "AWS::Region"
44+
},
45+
":",
46+
{
47+
"Ref": "AWS::AccountId"
48+
},
49+
":log-group:/aws/codebuild/",
50+
{
51+
"Ref": "ProjectC78D97AD"
52+
},
53+
":*"
54+
]
55+
]
56+
},
57+
{
58+
"Fn::Join": [
59+
"",
60+
[
61+
"arn:",
62+
{
63+
"Ref": "AWS::Partition"
64+
},
65+
":logs:",
66+
{
67+
"Ref": "AWS::Region"
68+
},
69+
":",
70+
{
71+
"Ref": "AWS::AccountId"
72+
},
73+
":log-group:/aws/codebuild/",
74+
{
75+
"Ref": "ProjectC78D97AD"
76+
}
77+
]
78+
]
79+
}
80+
]
81+
},
82+
{
83+
"Action": [
84+
"codebuild:BatchPutCodeCoverages",
85+
"codebuild:BatchPutTestCases",
86+
"codebuild:CreateReport",
87+
"codebuild:CreateReportGroup",
88+
"codebuild:UpdateReport"
89+
],
90+
"Effect": "Allow",
91+
"Resource": {
92+
"Fn::Join": [
93+
"",
94+
[
95+
"arn:",
96+
{
97+
"Ref": "AWS::Partition"
98+
},
99+
":codebuild:",
100+
{
101+
"Ref": "AWS::Region"
102+
},
103+
":",
104+
{
105+
"Ref": "AWS::AccountId"
106+
},
107+
":report-group/",
108+
{
109+
"Ref": "ProjectC78D97AD"
110+
},
111+
"-*"
112+
]
113+
]
114+
}
115+
}
116+
],
117+
"Version": "2012-10-17"
118+
},
119+
"PolicyName": "ProjectRoleDefaultPolicy7F29461B",
120+
"Roles": [
121+
{
122+
"Ref": "ProjectRole4CCB274E"
123+
}
124+
]
125+
}
126+
},
127+
"ProjectC78D97AD": {
128+
"Type": "AWS::CodeBuild::Project",
129+
"Properties": {
130+
"Artifacts": {
131+
"Type": "NO_ARTIFACTS"
132+
},
133+
"BuildBatchConfig": {
134+
"ServiceRole": {
135+
"Fn::GetAtt": [
136+
"ProjectBatchServiceRoleF97A1CFB",
137+
"Arn"
138+
]
139+
}
140+
},
141+
"Cache": {
142+
"Type": "NO_CACHE"
143+
},
144+
"EncryptionKey": "alias/aws/s3",
145+
"Environment": {
146+
"ComputeType": "BUILD_GENERAL1_SMALL",
147+
"Image": "aws/codebuild/standard:5.0",
148+
"ImagePullCredentialsType": "CODEBUILD",
149+
"PrivilegedMode": false,
150+
"Type": "LINUX_CONTAINER"
151+
},
152+
"Name": "MyTestProject",
153+
"ServiceRole": {
154+
"Fn::GetAtt": [
155+
"ProjectRole4CCB274E",
156+
"Arn"
157+
]
158+
},
159+
"Source": {
160+
"BuildSpec": "version: 0.2\nbatch:\n fast-fail: true\n build-list:\n - identifier: linux_small\n env:\n compute-type: BUILD_GENERAL1_SMALL\n image: aws/codebuild/standard:5.0\n type: LINUX_CONTAINER\n variables:\n key1: value1\n buildspec: |-\n version: 0.2\n phases:\n build:\n commands:\n - echo \"Hello, from small!\"\n - identifier: linux_medium\n env:\n compute-type: BUILD_GENERAL1_MEDIUM\n image: aws/codebuild/standard:4.0\n type: LINUX_CONTAINER\n variables:\n key2: value2\n buildspec: |-\n version: 0.2\n phases:\n build:\n commands:\n - echo \"Hello, from medium!\"\n",
161+
"Type": "NO_SOURCE"
162+
},
163+
"TimeoutInMinutes": 60
164+
}
165+
},
166+
"ProjectBatchServiceRoleF97A1CFB": {
167+
"Type": "AWS::IAM::Role",
168+
"Properties": {
169+
"AssumeRolePolicyDocument": {
170+
"Statement": [
171+
{
172+
"Action": "sts:AssumeRole",
173+
"Effect": "Allow",
174+
"Principal": {
175+
"Service": "codebuild.amazonaws.com"
176+
}
177+
}
178+
],
179+
"Version": "2012-10-17"
180+
}
181+
}
182+
},
183+
"ProjectBatchServiceRoleDefaultPolicy5E00842B": {
184+
"Type": "AWS::IAM::Policy",
185+
"Properties": {
186+
"PolicyDocument": {
187+
"Statement": [
188+
{
189+
"Action": [
190+
"codebuild:RetryBuild",
191+
"codebuild:StartBuild",
192+
"codebuild:StopBuild"
193+
],
194+
"Effect": "Allow",
195+
"Resource": {
196+
"Fn::GetAtt": [
197+
"ProjectC78D97AD",
198+
"Arn"
199+
]
200+
}
201+
}
202+
],
203+
"Version": "2012-10-17"
204+
},
205+
"PolicyName": "ProjectBatchServiceRoleDefaultPolicy5E00842B",
206+
"Roles": [
207+
{
208+
"Ref": "ProjectBatchServiceRoleF97A1CFB"
209+
}
210+
]
211+
}
212+
},
213+
"StateMachineRoleB840431D": {
214+
"Type": "AWS::IAM::Role",
215+
"Properties": {
216+
"AssumeRolePolicyDocument": {
217+
"Statement": [
218+
{
219+
"Action": "sts:AssumeRole",
220+
"Effect": "Allow",
221+
"Principal": {
222+
"Service": "states.amazonaws.com"
223+
}
224+
}
225+
],
226+
"Version": "2012-10-17"
227+
}
228+
}
229+
},
230+
"StateMachineRoleDefaultPolicyDF1E6607": {
231+
"Type": "AWS::IAM::Policy",
232+
"Properties": {
233+
"PolicyDocument": {
234+
"Statement": [
235+
{
236+
"Action": [
237+
"codebuild:BatchGetBuildBatches",
238+
"codebuild:StartBuildBatch",
239+
"codebuild:StopBuildBatch"
240+
],
241+
"Effect": "Allow",
242+
"Resource": {
243+
"Fn::GetAtt": [
244+
"ProjectC78D97AD",
245+
"Arn"
246+
]
247+
}
248+
},
249+
{
250+
"Action": [
251+
"events:DescribeRule",
252+
"events:PutRule",
253+
"events:PutTargets"
254+
],
255+
"Effect": "Allow",
256+
"Resource": {
257+
"Fn::Join": [
258+
"",
259+
[
260+
"arn:",
261+
{
262+
"Ref": "AWS::Partition"
263+
},
264+
":events:",
265+
{
266+
"Ref": "AWS::Region"
267+
},
268+
":",
269+
{
270+
"Ref": "AWS::AccountId"
271+
},
272+
":rule/StepFunctionsGetEventForCodeBuildStartBuildBatchRule"
273+
]
274+
]
275+
}
276+
}
277+
],
278+
"Version": "2012-10-17"
279+
},
280+
"PolicyName": "StateMachineRoleDefaultPolicyDF1E6607",
281+
"Roles": [
282+
{
283+
"Ref": "StateMachineRoleB840431D"
284+
}
285+
]
286+
}
287+
},
288+
"StateMachine2E01A3A5": {
289+
"Type": "AWS::StepFunctions::StateMachine",
290+
"Properties": {
291+
"DefinitionString": {
292+
"Fn::Join": [
293+
"",
294+
[
295+
"{\"StartAt\":\"Start\",\"States\":{\"Start\":{\"Type\":\"Pass\",\"Result\":{\"bar\":\"SomeValue\"},\"Next\":\"buildTask1\"},\"buildTask1\":{\"Next\":\"buildTask2\",\"Type\":\"Task\",\"Resource\":\"arn:",
296+
{
297+
"Ref": "AWS::Partition"
298+
},
299+
":states:::codebuild:startBuildBatch\",\"Parameters\":{\"ProjectName\":\"",
300+
{
301+
"Ref": "ProjectC78D97AD"
302+
},
303+
"\",\"EnvironmentVariablesOverride\":[{\"Name\":\"test\",\"Type\":\"PLAINTEXT\",\"Value\":\"testValue\"}]}},\"buildTask2\":{\"End\":true,\"Type\":\"Task\",\"Resource\":\"arn:",
304+
{
305+
"Ref": "AWS::Partition"
306+
},
307+
":states:::codebuild:startBuildBatch.sync\",\"Parameters\":{\"ProjectName\":\"",
308+
{
309+
"Ref": "ProjectC78D97AD"
310+
},
311+
"\",\"EnvironmentVariablesOverride\":[{\"Name\":\"test\",\"Type\":\"PLAINTEXT\",\"Value\":\"testValue\"}]}}}}"
312+
]
313+
]
314+
},
315+
"RoleArn": {
316+
"Fn::GetAtt": [
317+
"StateMachineRoleB840431D",
318+
"Arn"
319+
]
320+
}
321+
},
322+
"DependsOn": [
323+
"StateMachineRoleDefaultPolicyDF1E6607",
324+
"StateMachineRoleB840431D"
325+
],
326+
"UpdateReplacePolicy": "Delete",
327+
"DeletionPolicy": "Delete"
328+
}
329+
},
330+
"Parameters": {
331+
"BootstrapVersion": {
332+
"Type": "AWS::SSM::Parameter::Value<String>",
333+
"Default": "/cdk-bootstrap/hnb659fds/version",
334+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
335+
}
336+
},
337+
"Rules": {
338+
"CheckBootstrapVersion": {
339+
"Assertions": [
340+
{
341+
"Assert": {
342+
"Fn::Not": [
343+
{
344+
"Fn::Contains": [
345+
[
346+
"1",
347+
"2",
348+
"3",
349+
"4",
350+
"5"
351+
],
352+
{
353+
"Ref": "BootstrapVersion"
354+
}
355+
]
356+
}
357+
]
358+
},
359+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
360+
}
361+
]
362+
}
363+
}
364+
}

0 commit comments

Comments
 (0)