From 28302f77840e341846dd27aa82f39ae181b3580f Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Thu, 29 Feb 2024 00:42:46 +0900 Subject: [PATCH 01/18] feat: add start-build-batch.ts --- .../lib/codebuild/start-build-batch.ts | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts new file mode 100644 index 0000000000000..4a1fbf07656c4 --- /dev/null +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts @@ -0,0 +1,113 @@ +import { Construct } from 'constructs'; +import * as codebuild from '../../../aws-codebuild'; +import * as iam from '../../../aws-iam'; +import * as sfn from '../../../aws-stepfunctions'; +import * as cdk from '../../../core'; +import { integrationResourceArn, validatePatternSupported } from '../private/task-utils'; + +/** + * Properties for CodeBuildStartBuildBatch + */ +export interface CodeBuildStartBuildBatchProps extends sfn.TaskStateBaseProps { + /** + * CodeBuild project to start + */ + readonly project: codebuild.IProject; + /** + * A set of environment variables to be used for this build only. + * + * @default - the latest environment variables already defined in the build project. + */ + readonly environmentVariablesOverride?: { [name: string]: codebuild.BuildEnvironmentVariable }; +} + +/** + * Start a CodeBuild BatchBuild as a task + * + * @see https://docs.aws.amazon.com/step-functions/latest/dg/connect-codebuild.html + */ +export class CodeBuildStartBuildBatch extends sfn.TaskStateBase { + private static readonly SUPPORTED_INTEGRATION_PATTERNS: sfn.IntegrationPattern[] = [ + sfn.IntegrationPattern.REQUEST_RESPONSE, + sfn.IntegrationPattern.RUN_JOB, + ]; + + protected readonly taskMetrics?: sfn.TaskMetricsConfig; + protected readonly taskPolicies?: iam.PolicyStatement[]; + + private readonly integrationPattern: sfn.IntegrationPattern; + + constructor(scope: Construct, id: string, private readonly props: CodeBuildStartBuildBatchProps) { + super(scope, id, props); + this.integrationPattern = props.integrationPattern ?? sfn.IntegrationPattern.REQUEST_RESPONSE; + + validatePatternSupported(this.integrationPattern, CodeBuildStartBuildBatch.SUPPORTED_INTEGRATION_PATTERNS); + + this.taskMetrics = { + metricPrefixSingular: 'CodeBuildProject', + metricPrefixPlural: 'CodeBuildProjects', + metricDimensions: { + ProjectArn: this.props.project.projectArn, + }, + }; + + this.taskPolicies = this.configurePolicyStatements(); + } + + private configurePolicyStatements(): iam.PolicyStatement[] { + let policyStatements = [ + new iam.PolicyStatement({ + resources: [this.props.project.projectArn], + actions: [ + 'codebuild:StartBuildBatch', + 'codebuild:StopBuildBatch', + 'codebuild:BatchGetBuilds', + 'codebuild:BatchGetReports', + 'codebuild:ListBuildsForProject', + ], + }), + ]; + + if (this.integrationPattern === sfn.IntegrationPattern.RUN_JOB) { + policyStatements.push( + new iam.PolicyStatement({ + actions: ['events:PutTargets', 'events:PutRule', 'events:DescribeRule'], + resources: [ + cdk.Stack.of(this).formatArn({ + service: 'events', + resource: 'rule/StepFunctionsGetEventForCodeBuildStartBuildRule', + }), + ], + }), + ); + } + + return policyStatements; + } + + /** + * Provides the CodeBuild StartBuild service integration task configuration + */ + /** + * @internal + */ + protected _renderTask(): any { + return { + Resource: integrationResourceArn('codebuild', 'startBuildBatch', this.integrationPattern), + Parameters: sfn.FieldUtils.renderObject({ + ProjectName: this.props.project.projectName, + EnvironmentVariablesOverride: this.props.environmentVariablesOverride + ? this.serializeEnvVariables(this.props.environmentVariablesOverride) + : undefined, + }), + }; + } + + private serializeEnvVariables(environmentVariables: { [name: string]: codebuild.BuildEnvironmentVariable }) { + return Object.keys(environmentVariables).map(name => ({ + Name: name, + Type: environmentVariables[name].type || codebuild.BuildEnvironmentVariableType.PLAINTEXT, + Value: environmentVariables[name].value, + })); + } +} From cf792dcc364764b25ca3222cfe371db12da042d2 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Thu, 29 Feb 2024 11:17:15 +0900 Subject: [PATCH 02/18] test: add integ test --- .../StartBuildBatch.assets.json | 19 + .../StartBuildBatch.template.json | 335 ++++++++++ ...efaultTestDeployAssert4AD576F9.assets.json | 19 + ...aultTestDeployAssert4AD576F9.template.json | 36 ++ .../cdk.out | 1 + .../integ.json | 12 + .../manifest.json | 155 +++++ .../tree.json | 576 ++++++++++++++++++ .../test/codebuild/integ.start-build-batch.ts | 84 +++ 9 files changed, 1237 insertions(+) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchintegDefaultTestDeployAssert4AD576F9.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json new file mode 100644 index 0000000000000..eae29824b6d9d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.0", + "files": { + "385cfd090a9450cdd83f0613d8806bf6b8c6f2289254e0ce20583a0008a9498c": { + "source": { + "path": "StartBuildBatch.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "385cfd090a9450cdd83f0613d8806bf6b8c6f2289254e0ce20583a0008a9498c.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json new file mode 100644 index 0000000000000..7a177e67ffabb --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json @@ -0,0 +1,335 @@ +{ + "Resources": { + "ProjectRole4CCB274E": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "codebuild.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "ProjectRoleDefaultPolicy7F29461B": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "ProjectC78D97AD" + }, + ":*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "ProjectC78D97AD" + } + ] + ] + } + ] + }, + { + "Action": [ + "codebuild:BatchPutCodeCoverages", + "codebuild:BatchPutTestCases", + "codebuild:CreateReport", + "codebuild:CreateReportGroup", + "codebuild:UpdateReport" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":codebuild:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":report-group/", + { + "Ref": "ProjectC78D97AD" + }, + "-*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "ProjectRoleDefaultPolicy7F29461B", + "Roles": [ + { + "Ref": "ProjectRole4CCB274E" + } + ] + } + }, + "ProjectC78D97AD": { + "Type": "AWS::CodeBuild::Project", + "Properties": { + "Artifacts": { + "Type": "NO_ARTIFACTS" + }, + "BuildBatchConfig": { + "ServiceRole": { + "Fn::GetAtt": [ + "ProjectBatchServiceRoleF97A1CFB", + "Arn" + ] + } + }, + "Cache": { + "Type": "NO_CACHE" + }, + "EncryptionKey": "alias/aws/s3", + "Environment": { + "ComputeType": "BUILD_GENERAL1_SMALL", + "EnvironmentVariables": [ + { + "Name": "zone", + "Type": "PLAINTEXT", + "Value": "defaultZone" + } + ], + "Image": "aws/codebuild/standard:1.0", + "ImagePullCredentialsType": "CODEBUILD", + "PrivilegedMode": false, + "Type": "LINUX_CONTAINER" + }, + "Name": "MyTestProject", + "ServiceRole": { + "Fn::GetAtt": [ + "ProjectRole4CCB274E", + "Arn" + ] + }, + "Source": { + "BuildSpec": "{\n \"version\": \"0.2\",\n \"batch\": {\n \"fast-fail\": true,\n \"buildGraph\": [\n {\n \"identifier\": \"linux_small\",\n \"env\": {\n \"computeType\": \"BUILD_GENERAL1_SMALL\",\n \"image\": \"aws/codebuild/standard:4.0\",\n \"type\": \"LINUX_CONTAINER\"\n }\n },\n {\n \"identifier\": \"linux_medium\",\n \"env\": {\n \"computeType\": \"BUILD_GENERAL1_MEDIUM\",\n \"image\": \"aws/codebuild/standard:4.0\",\n \"type\": \"LINUX_CONTAINER\"\n },\n \"depends-on\": [\n \"linux_small\"\n ]\n }\n ]\n },\n \"phases\": {\n \"build\": {\n \"commands\": [\n \"echo \\\"Hello, CodeBuild!\\\"\"\n ]\n }\n }\n}", + "Type": "NO_SOURCE" + } + } + }, + "ProjectBatchServiceRoleF97A1CFB": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "codebuild.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "ProjectBatchServiceRoleDefaultPolicy5E00842B": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "codebuild:RetryBuild", + "codebuild:StartBuild", + "codebuild:StopBuild" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "ProjectC78D97AD", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "ProjectBatchServiceRoleDefaultPolicy5E00842B", + "Roles": [ + { + "Ref": "ProjectBatchServiceRoleF97A1CFB" + } + ] + } + }, + "StateMachineRoleB840431D": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "states.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "StateMachineRoleDefaultPolicyDF1E6607": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "codebuild:BatchGetBuilds", + "codebuild:BatchGetReports", + "codebuild:StartBuild", + "codebuild:StopBuild" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "ProjectC78D97AD", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "StateMachineRoleDefaultPolicyDF1E6607", + "Roles": [ + { + "Ref": "StateMachineRoleB840431D" + } + ] + } + }, + "StateMachine2E01A3A5": { + "Type": "AWS::StepFunctions::StateMachine", + "Properties": { + "DefinitionString": { + "Fn::Join": [ + "", + [ + "{\"StartAt\":\"Start\",\"States\":{\"Start\":{\"Type\":\"Pass\",\"Result\":{\"bar\":\"SomeValue\"},\"Next\":\"build-task\"},\"build-task\":{\"End\":true,\"Type\":\"Task\",\"Resource\":\"arn:", + { + "Ref": "AWS::Partition" + }, + ":states:::codebuild:startBuild\",\"Parameters\":{\"ProjectName\":\"", + { + "Ref": "ProjectC78D97AD" + }, + "\",\"EnvironmentVariablesOverride\":[{\"Name\":\"ZONE\",\"Type\":\"PLAINTEXT\",\"Value.$\":\"$.envVariables.zone\"}]}}}}" + ] + ] + }, + "RoleArn": { + "Fn::GetAtt": [ + "StateMachineRoleB840431D", + "Arn" + ] + } + }, + "DependsOn": [ + "StateMachineRoleDefaultPolicyDF1E6607", + "StateMachineRoleB840431D" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "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." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets.json new file mode 100644 index 0000000000000..44af2929912e5 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "StartBuildBatchintegDefaultTestDeployAssert4AD576F9.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": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchintegDefaultTestDeployAssert4AD576F9.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchintegDefaultTestDeployAssert4AD576F9.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchintegDefaultTestDeployAssert4AD576F9.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "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." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/cdk.out new file mode 100644 index 0000000000000..1f0068d32659a --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"36.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/integ.json new file mode 100644 index 0000000000000..2bf83d5028b93 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "36.0.0", + "testCases": { + "StartBuildBatchinteg/DefaultTest": { + "stacks": [ + "StartBuildBatch" + ], + "assertionStack": "StartBuildBatchinteg/DefaultTest/DeployAssert", + "assertionStackName": "StartBuildBatchintegDefaultTestDeployAssert4AD576F9" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json new file mode 100644 index 0000000000000..595e7d7e0c73c --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json @@ -0,0 +1,155 @@ +{ + "version": "36.0.0", + "artifacts": { + "StartBuildBatch.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "StartBuildBatch.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "StartBuildBatch": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "StartBuildBatch.template.json", + "terminationProtection": false, + "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}/385cfd090a9450cdd83f0613d8806bf6b8c6f2289254e0ce20583a0008a9498c.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "StartBuildBatch.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": [ + "StartBuildBatch.assets" + ], + "metadata": { + "/StartBuildBatch/Project/Role/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ProjectRole4CCB274E" + } + ], + "/StartBuildBatch/Project/Role/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ProjectRoleDefaultPolicy7F29461B" + } + ], + "/StartBuildBatch/Project/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ProjectC78D97AD" + } + ], + "/StartBuildBatch/Project/BatchServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ProjectBatchServiceRoleF97A1CFB" + } + ], + "/StartBuildBatch/Project/BatchServiceRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ProjectBatchServiceRoleDefaultPolicy5E00842B" + } + ], + "/StartBuildBatch/StateMachine/Role/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StateMachineRoleB840431D" + } + ], + "/StartBuildBatch/StateMachine/Role/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StateMachineRoleDefaultPolicyDF1E6607" + } + ], + "/StartBuildBatch/StateMachine/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StateMachine2E01A3A5" + } + ], + "/StartBuildBatch/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/StartBuildBatch/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "StartBuildBatch" + }, + "StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "StartBuildBatchintegDefaultTestDeployAssert4AD576F9": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "StartBuildBatchintegDefaultTestDeployAssert4AD576F9.template.json", + "terminationProtection": false, + "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": [ + "StartBuildBatchintegDefaultTestDeployAssert4AD576F9.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": [ + "StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets" + ], + "metadata": { + "/StartBuildBatchinteg/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/StartBuildBatchinteg/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "StartBuildBatchinteg/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json new file mode 100644 index 0000000000000..50872a1a15ccc --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json @@ -0,0 +1,576 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "StartBuildBatch": { + "id": "StartBuildBatch", + "path": "StartBuildBatch", + "children": { + "Project": { + "id": "Project", + "path": "StartBuildBatch/Project", + "children": { + "Role": { + "id": "Role", + "path": "StartBuildBatch/Project/Role", + "children": { + "ImportRole": { + "id": "ImportRole", + "path": "StartBuildBatch/Project/Role/ImportRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "StartBuildBatch/Project/Role/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "codebuild.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "StartBuildBatch/Project/Role/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "StartBuildBatch/Project/Role/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "ProjectC78D97AD" + }, + ":*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/codebuild/", + { + "Ref": "ProjectC78D97AD" + } + ] + ] + } + ] + }, + { + "Action": [ + "codebuild:BatchPutCodeCoverages", + "codebuild:BatchPutTestCases", + "codebuild:CreateReport", + "codebuild:CreateReportGroup", + "codebuild:UpdateReport" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":codebuild:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":report-group/", + { + "Ref": "ProjectC78D97AD" + }, + "-*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "ProjectRoleDefaultPolicy7F29461B", + "roles": [ + { + "Ref": "ProjectRole4CCB274E" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "StartBuildBatch/Project/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CodeBuild::Project", + "aws:cdk:cloudformation:props": { + "artifacts": { + "type": "NO_ARTIFACTS" + }, + "buildBatchConfig": { + "serviceRole": { + "Fn::GetAtt": [ + "ProjectBatchServiceRoleF97A1CFB", + "Arn" + ] + } + }, + "cache": { + "type": "NO_CACHE" + }, + "encryptionKey": "alias/aws/s3", + "environment": { + "type": "LINUX_CONTAINER", + "image": "aws/codebuild/standard:1.0", + "imagePullCredentialsType": "CODEBUILD", + "privilegedMode": false, + "computeType": "BUILD_GENERAL1_SMALL", + "environmentVariables": [ + { + "name": "zone", + "type": "PLAINTEXT", + "value": "defaultZone" + } + ] + }, + "name": "MyTestProject", + "serviceRole": { + "Fn::GetAtt": [ + "ProjectRole4CCB274E", + "Arn" + ] + }, + "source": { + "type": "NO_SOURCE", + "buildSpec": "{\n \"version\": \"0.2\",\n \"batch\": {\n \"fast-fail\": true,\n \"buildGraph\": [\n {\n \"identifier\": \"linux_small\",\n \"env\": {\n \"computeType\": \"BUILD_GENERAL1_SMALL\",\n \"image\": \"aws/codebuild/standard:4.0\",\n \"type\": \"LINUX_CONTAINER\"\n }\n },\n {\n \"identifier\": \"linux_medium\",\n \"env\": {\n \"computeType\": \"BUILD_GENERAL1_MEDIUM\",\n \"image\": \"aws/codebuild/standard:4.0\",\n \"type\": \"LINUX_CONTAINER\"\n },\n \"depends-on\": [\n \"linux_small\"\n ]\n }\n ]\n },\n \"phases\": {\n \"build\": {\n \"commands\": [\n \"echo \\\"Hello, CodeBuild!\\\"\"\n ]\n }\n }\n}" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_codebuild.CfnProject", + "version": "0.0.0" + } + }, + "BatchServiceRole": { + "id": "BatchServiceRole", + "path": "StartBuildBatch/Project/BatchServiceRole", + "children": { + "ImportBatchServiceRole": { + "id": "ImportBatchServiceRole", + "path": "StartBuildBatch/Project/BatchServiceRole/ImportBatchServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "StartBuildBatch/Project/BatchServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "codebuild.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "StartBuildBatch/Project/BatchServiceRole/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "StartBuildBatch/Project/BatchServiceRole/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": [ + "codebuild:RetryBuild", + "codebuild:StartBuild", + "codebuild:StopBuild" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "ProjectC78D97AD", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "ProjectBatchServiceRoleDefaultPolicy5E00842B", + "roles": [ + { + "Ref": "ProjectBatchServiceRoleF97A1CFB" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_codebuild.Project", + "version": "0.0.0" + } + }, + "build-task": { + "id": "build-task", + "path": "StartBuildBatch/build-task", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions_tasks.CodeBuildStartBuild", + "version": "0.0.0" + } + }, + "Start": { + "id": "Start", + "path": "StartBuildBatch/Start", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions.Pass", + "version": "0.0.0" + } + }, + "StateMachine": { + "id": "StateMachine", + "path": "StartBuildBatch/StateMachine", + "children": { + "Role": { + "id": "Role", + "path": "StartBuildBatch/StateMachine/Role", + "children": { + "ImportRole": { + "id": "ImportRole", + "path": "StartBuildBatch/StateMachine/Role/ImportRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "StartBuildBatch/StateMachine/Role/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "states.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "StartBuildBatch/StateMachine/Role/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "StartBuildBatch/StateMachine/Role/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": [ + "codebuild:BatchGetBuilds", + "codebuild:BatchGetReports", + "codebuild:StartBuild", + "codebuild:StopBuild" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "ProjectC78D97AD", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "StateMachineRoleDefaultPolicyDF1E6607", + "roles": [ + { + "Ref": "StateMachineRoleB840431D" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "StartBuildBatch/StateMachine/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::StepFunctions::StateMachine", + "aws:cdk:cloudformation:props": { + "definitionString": { + "Fn::Join": [ + "", + [ + "{\"StartAt\":\"Start\",\"States\":{\"Start\":{\"Type\":\"Pass\",\"Result\":{\"bar\":\"SomeValue\"},\"Next\":\"build-task\"},\"build-task\":{\"End\":true,\"Type\":\"Task\",\"Resource\":\"arn:", + { + "Ref": "AWS::Partition" + }, + ":states:::codebuild:startBuild\",\"Parameters\":{\"ProjectName\":\"", + { + "Ref": "ProjectC78D97AD" + }, + "\",\"EnvironmentVariablesOverride\":[{\"Name\":\"ZONE\",\"Type\":\"PLAINTEXT\",\"Value.$\":\"$.envVariables.zone\"}]}}}}" + ] + ] + }, + "roleArn": { + "Fn::GetAtt": [ + "StateMachineRoleB840431D", + "Arn" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions.CfnStateMachine", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions.StateMachine", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "StartBuildBatch/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "StartBuildBatch/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "StartBuildBatchinteg": { + "id": "StartBuildBatchinteg", + "path": "StartBuildBatchinteg", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "StartBuildBatchinteg/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "StartBuildBatchinteg/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "StartBuildBatchinteg/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "StartBuildBatchinteg/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "StartBuildBatchinteg/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.ts new file mode 100644 index 0000000000000..be907f60c3179 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.ts @@ -0,0 +1,84 @@ +import * as codebuild from 'aws-cdk-lib/aws-codebuild'; +import * as sfn from 'aws-cdk-lib/aws-stepfunctions'; +import * as cdk from 'aws-cdk-lib'; +import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; + +class TestStack extends cdk.Stack { + constructor(scope: cdk.App, id: string, props: cdk.StackProps = {}) { + super(scope, id, props); + + const project = new codebuild.Project(this, 'Project', { + projectName: 'MyTestProject', + buildSpec: codebuild.BuildSpec.fromObject({ + version: '0.2', + batch: { + 'fast-fail': true, + 'buildGraph': [ + { + identifier: 'linux_small', + env: { + computeType: 'BUILD_GENERAL1_SMALL', + image: 'aws/codebuild/standard:4.0', + type: 'LINUX_CONTAINER', + }, + }, + { + 'identifier': 'linux_medium', + 'env': { + computeType: 'BUILD_GENERAL1_MEDIUM', + image: 'aws/codebuild/standard:4.0', + type: 'LINUX_CONTAINER', + }, + 'depends-on': ['linux_small'], + }, + ], + }, + phases: { + build: { + commands: [ + 'echo "Hello, CodeBuild!"', + ], + }, + }, + }), + environmentVariables: { + zone: { + type: codebuild.BuildEnvironmentVariableType.PLAINTEXT, + value: 'defaultZone', + }, + }, + }); + const buildconfig = project.enableBatchBuilds(); + + if (buildconfig == null) { + throw new Error('Batch builds not enabled'); + } + + const startBuildBatch = new tasks.CodeBuildStartBuild(this, 'build-task', { + project, + environmentVariablesOverride: { + ZONE: { + type: codebuild.BuildEnvironmentVariableType.PLAINTEXT, + value: sfn.JsonPath.stringAt('$.envVariables.zone'), + }, + }, + }); + + const definition = new sfn.Pass(this, 'Start', { + result: sfn.Result.fromObject({ bar: 'SomeValue' }), + }).next(startBuildBatch); + + new sfn.StateMachine(this, 'StateMachine', { + definition, + }); + } +} + +const app = new cdk.App(); +const stack = new TestStack(app, 'StartBuildBatch'); +new IntegTest(app, 'StartBuildBatchinteg', { + testCases: [stack], +}); + +app.synth(); From f775485dceea11edc464c2f8a2c90db10beee10b Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Thu, 29 Feb 2024 23:26:51 +0900 Subject: [PATCH 03/18] test: update integ test --- .../StartBuildBatch.assets.json | 4 +- .../StartBuildBatch.template.json | 20 +++---- .../manifest.json | 2 +- .../tree.json | 30 +++++------ .../test/codebuild/integ.start-build-batch.ts | 54 +++++++++---------- .../aws-stepfunctions-tasks/lib/index.ts | 1 + 6 files changed, 49 insertions(+), 62 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json index eae29824b6d9d..a2f02b173228d 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json @@ -1,7 +1,7 @@ { "version": "36.0.0", "files": { - "385cfd090a9450cdd83f0613d8806bf6b8c6f2289254e0ce20583a0008a9498c": { + "8287e3621f92198786f7e941852291d2f93ef868bd62f5e957f82b9c42fbb8d7": { "source": { "path": "StartBuildBatch.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "385cfd090a9450cdd83f0613d8806bf6b8c6f2289254e0ce20583a0008a9498c.json", + "objectKey": "8287e3621f92198786f7e941852291d2f93ef868bd62f5e957f82b9c42fbb8d7.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json index 7a177e67ffabb..c309a1a7722e4 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json @@ -144,13 +144,6 @@ "EncryptionKey": "alias/aws/s3", "Environment": { "ComputeType": "BUILD_GENERAL1_SMALL", - "EnvironmentVariables": [ - { - "Name": "zone", - "Type": "PLAINTEXT", - "Value": "defaultZone" - } - ], "Image": "aws/codebuild/standard:1.0", "ImagePullCredentialsType": "CODEBUILD", "PrivilegedMode": false, @@ -164,7 +157,7 @@ ] }, "Source": { - "BuildSpec": "{\n \"version\": \"0.2\",\n \"batch\": {\n \"fast-fail\": true,\n \"buildGraph\": [\n {\n \"identifier\": \"linux_small\",\n \"env\": {\n \"computeType\": \"BUILD_GENERAL1_SMALL\",\n \"image\": \"aws/codebuild/standard:4.0\",\n \"type\": \"LINUX_CONTAINER\"\n }\n },\n {\n \"identifier\": \"linux_medium\",\n \"env\": {\n \"computeType\": \"BUILD_GENERAL1_MEDIUM\",\n \"image\": \"aws/codebuild/standard:4.0\",\n \"type\": \"LINUX_CONTAINER\"\n },\n \"depends-on\": [\n \"linux_small\"\n ]\n }\n ]\n },\n \"phases\": {\n \"build\": {\n \"commands\": [\n \"echo \\\"Hello, CodeBuild!\\\"\"\n ]\n }\n }\n}", + "BuildSpec": "version: 0.2\nenvironment:\n buildImage:\n type: LINUX_CONTAINER\n defaultComputeType: BUILD_GENERAL1_SMALL\n imageId: aws/codebuild/standard:5.0\n imagePullPrincipalType: CODEBUILD\n secretsManagerCredentials: null\n repository: null\ntimeout:\n amount: 1\n unit:\n label: hours\n isoLabel: H\n inMillis: 3600000\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", "Type": "NO_SOURCE" } } @@ -242,8 +235,9 @@ "Action": [ "codebuild:BatchGetBuilds", "codebuild:BatchGetReports", - "codebuild:StartBuild", - "codebuild:StopBuild" + "codebuild:ListBuildsForProject", + "codebuild:StartBuildBatch", + "codebuild:StopBuildBatch" ], "Effect": "Allow", "Resource": { @@ -271,15 +265,15 @@ "Fn::Join": [ "", [ - "{\"StartAt\":\"Start\",\"States\":{\"Start\":{\"Type\":\"Pass\",\"Result\":{\"bar\":\"SomeValue\"},\"Next\":\"build-task\"},\"build-task\":{\"End\":true,\"Type\":\"Task\",\"Resource\":\"arn:", + "{\"StartAt\":\"Start\",\"States\":{\"Start\":{\"Type\":\"Pass\",\"Result\":{\"bar\":\"SomeValue\"},\"Next\":\"buildTask\"},\"buildTask\":{\"End\":true,\"Type\":\"Task\",\"Resource\":\"arn:", { "Ref": "AWS::Partition" }, - ":states:::codebuild:startBuild\",\"Parameters\":{\"ProjectName\":\"", + ":states:::codebuild:startBuildBatch\",\"Parameters\":{\"ProjectName\":\"", { "Ref": "ProjectC78D97AD" }, - "\",\"EnvironmentVariablesOverride\":[{\"Name\":\"ZONE\",\"Type\":\"PLAINTEXT\",\"Value.$\":\"$.envVariables.zone\"}]}}}}" + "\",\"EnvironmentVariablesOverride\":[{\"Name\":\"test\",\"Type\":\"PLAINTEXT\",\"Value\":\"testValue\"}]}}}}" ] ] }, diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json index 595e7d7e0c73c..468ec3665bb87 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json @@ -18,7 +18,7 @@ "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}/385cfd090a9450cdd83f0613d8806bf6b8c6f2289254e0ce20583a0008a9498c.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/8287e3621f92198786f7e941852291d2f93ef868bd62f5e957f82b9c42fbb8d7.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json index 50872a1a15ccc..eed83b4056c13 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json @@ -206,14 +206,7 @@ "image": "aws/codebuild/standard:1.0", "imagePullCredentialsType": "CODEBUILD", "privilegedMode": false, - "computeType": "BUILD_GENERAL1_SMALL", - "environmentVariables": [ - { - "name": "zone", - "type": "PLAINTEXT", - "value": "defaultZone" - } - ] + "computeType": "BUILD_GENERAL1_SMALL" }, "name": "MyTestProject", "serviceRole": { @@ -224,7 +217,7 @@ }, "source": { "type": "NO_SOURCE", - "buildSpec": "{\n \"version\": \"0.2\",\n \"batch\": {\n \"fast-fail\": true,\n \"buildGraph\": [\n {\n \"identifier\": \"linux_small\",\n \"env\": {\n \"computeType\": \"BUILD_GENERAL1_SMALL\",\n \"image\": \"aws/codebuild/standard:4.0\",\n \"type\": \"LINUX_CONTAINER\"\n }\n },\n {\n \"identifier\": \"linux_medium\",\n \"env\": {\n \"computeType\": \"BUILD_GENERAL1_MEDIUM\",\n \"image\": \"aws/codebuild/standard:4.0\",\n \"type\": \"LINUX_CONTAINER\"\n },\n \"depends-on\": [\n \"linux_small\"\n ]\n }\n ]\n },\n \"phases\": {\n \"build\": {\n \"commands\": [\n \"echo \\\"Hello, CodeBuild!\\\"\"\n ]\n }\n }\n}" + "buildSpec": "version: 0.2\nenvironment:\n buildImage:\n type: LINUX_CONTAINER\n defaultComputeType: BUILD_GENERAL1_SMALL\n imageId: aws/codebuild/standard:5.0\n imagePullPrincipalType: CODEBUILD\n secretsManagerCredentials: null\n repository: null\ntimeout:\n amount: 1\n unit:\n label: hours\n isoLabel: H\n inMillis: 3600000\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" } } }, @@ -330,11 +323,11 @@ "version": "0.0.0" } }, - "build-task": { - "id": "build-task", - "path": "StartBuildBatch/build-task", + "buildTask": { + "id": "buildTask", + "path": "StartBuildBatch/buildTask", "constructInfo": { - "fqn": "aws-cdk-lib.aws_stepfunctions_tasks.CodeBuildStartBuild", + "fqn": "aws-cdk-lib.aws_stepfunctions_tasks.CodeBuildStartBuildBatch", "version": "0.0.0" } }, @@ -403,8 +396,9 @@ "Action": [ "codebuild:BatchGetBuilds", "codebuild:BatchGetReports", - "codebuild:StartBuild", - "codebuild:StopBuild" + "codebuild:ListBuildsForProject", + "codebuild:StartBuildBatch", + "codebuild:StopBuildBatch" ], "Effect": "Allow", "Resource": { @@ -452,15 +446,15 @@ "Fn::Join": [ "", [ - "{\"StartAt\":\"Start\",\"States\":{\"Start\":{\"Type\":\"Pass\",\"Result\":{\"bar\":\"SomeValue\"},\"Next\":\"build-task\"},\"build-task\":{\"End\":true,\"Type\":\"Task\",\"Resource\":\"arn:", + "{\"StartAt\":\"Start\",\"States\":{\"Start\":{\"Type\":\"Pass\",\"Result\":{\"bar\":\"SomeValue\"},\"Next\":\"buildTask\"},\"buildTask\":{\"End\":true,\"Type\":\"Task\",\"Resource\":\"arn:", { "Ref": "AWS::Partition" }, - ":states:::codebuild:startBuild\",\"Parameters\":{\"ProjectName\":\"", + ":states:::codebuild:startBuildBatch\",\"Parameters\":{\"ProjectName\":\"", { "Ref": "ProjectC78D97AD" }, - "\",\"EnvironmentVariablesOverride\":[{\"Name\":\"ZONE\",\"Type\":\"PLAINTEXT\",\"Value.$\":\"$.envVariables.zone\"}]}}}}" + "\",\"EnvironmentVariablesOverride\":[{\"Name\":\"test\",\"Type\":\"PLAINTEXT\",\"Value\":\"testValue\"}]}}}}" ] ] }, diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.ts index be907f60c3179..268e9123e1b2a 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.ts @@ -10,44 +10,42 @@ class TestStack extends cdk.Stack { const project = new codebuild.Project(this, 'Project', { projectName: 'MyTestProject', - buildSpec: codebuild.BuildSpec.fromObject({ - version: '0.2', + environment: { + buildImage: codebuild.LinuxBuildImage.STANDARD_5_0, + }, + timeout: cdk.Duration.hours(1), + buildSpec: codebuild.BuildSpec.fromObjectToYaml({ + version: 0.2, batch: { 'fast-fail': true, - 'buildGraph': [ + 'build-list': [ { identifier: 'linux_small', env: { - computeType: 'BUILD_GENERAL1_SMALL', - image: 'aws/codebuild/standard:4.0', - type: 'LINUX_CONTAINER', + 'compute-type': 'BUILD_GENERAL1_SMALL', + 'image': 'aws/codebuild/standard:5.0', + 'type': 'LINUX_CONTAINER', + 'variables': { + key1: 'value1', + }, }, + buildspec: 'version: 0.2\nphases:\n build:\n commands:\n - echo "Hello, from small!"', }, { - 'identifier': 'linux_medium', - 'env': { - computeType: 'BUILD_GENERAL1_MEDIUM', - image: 'aws/codebuild/standard:4.0', - type: 'LINUX_CONTAINER', + identifier: 'linux_medium', + env: { + 'compute-type': 'BUILD_GENERAL1_MEDIUM', + 'image': 'aws/codebuild/standard:4.0', + 'type': 'LINUX_CONTAINER', + 'variables': { + key2: 'value2', + }, }, - 'depends-on': ['linux_small'], + buildspec: 'version: 0.2\nphases:\n build:\n commands:\n - echo "Hello, from medium!"', }, ], }, - phases: { - build: { - commands: [ - 'echo "Hello, CodeBuild!"', - ], - }, - }, }), - environmentVariables: { - zone: { - type: codebuild.BuildEnvironmentVariableType.PLAINTEXT, - value: 'defaultZone', - }, - }, }); const buildconfig = project.enableBatchBuilds(); @@ -55,12 +53,12 @@ class TestStack extends cdk.Stack { throw new Error('Batch builds not enabled'); } - const startBuildBatch = new tasks.CodeBuildStartBuild(this, 'build-task', { + const startBuildBatch = new tasks.CodeBuildStartBuildBatch(this, 'buildTask', { project, environmentVariablesOverride: { - ZONE: { + test: { type: codebuild.BuildEnvironmentVariableType.PLAINTEXT, - value: sfn.JsonPath.stringAt('$.envVariables.zone'), + value: 'testValue', }, }, }); diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/index.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/index.ts index 575464d22dcf0..1021c7e9950a6 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/index.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/index.ts @@ -42,6 +42,7 @@ export * from './dynamodb/update-item'; export * from './dynamodb/delete-item'; export * from './dynamodb/shared-types'; export * from './codebuild/start-build'; +export * from './codebuild/start-build-batch'; export * from './athena/start-query-execution'; export * from './athena/stop-query-execution'; export * from './athena/get-query-execution'; From 6d7f05a2c1cfbe8cd72a36e403dc707120f38df1 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Thu, 29 Feb 2024 23:44:56 +0900 Subject: [PATCH 04/18] test: add unit test --- .../test/codebuild/start-build-batch.test.ts | 158 ++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts new file mode 100644 index 0000000000000..fa280a324371c --- /dev/null +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts @@ -0,0 +1,158 @@ +import * as codebuild from '../../../aws-codebuild'; +import * as sfn from '../../../aws-stepfunctions'; +import * as cdk from '../../../core'; +import { CodeBuildStartBuildBatch } from '../../lib'; + +let stack: cdk.Stack; +let codebuildProject: codebuild.Project; + +beforeEach(() => { + // GIVEN + stack = new cdk.Stack(); + + codebuildProject = new codebuild.Project(stack, 'Project', { + projectName: 'MyTestProject', + buildSpec: codebuild.BuildSpec.fromObjectToYaml({ + version: '0.2', + batch: { + 'fast-fail': true, + 'build-list': [ + { + identifier: 'id', + buildspec: 'version: 0.2\nphases:\n build:\n commands:\n - echo "Hello, CodeBuild!"', + }, + ], + }, + }), + }); + codebuildProject.enableBatchBuilds(); +}); + +test('only the required parameters', () => { + // WHEN + const task = new CodeBuildStartBuildBatch(stack, 'Task', { + project: codebuildProject, + }); + + // THEN + expect(stack.resolve(task.toStateJson())).toEqual({ + Type: 'Task', + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':states:::codebuild:startBuildBatch', + ], + ], + }, + End: true, + Parameters: { + ProjectName: { + Ref: 'ProjectC78D97AD', + }, + }, + }); +}); + +test('supports tokens', () => { + // WHEN + const task = new CodeBuildStartBuildBatch(stack, 'Task', { + project: codebuildProject, + integrationPattern: sfn.IntegrationPattern.RUN_JOB, + environmentVariablesOverride: { + ZONE: { + type: codebuild.BuildEnvironmentVariableType.PLAINTEXT, + value: sfn.JsonPath.stringAt('$.envVariables.zone'), + }, + }, + }); + + // THEN + expect(stack.resolve(task.toStateJson())).toEqual({ + Type: 'Task', + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':states:::codebuild:startBuildBatch.sync', + ], + ], + }, + End: true, + Parameters: { + ProjectName: { + Ref: 'ProjectC78D97AD', + }, + EnvironmentVariablesOverride: [ + { + 'Name': 'ZONE', + 'Type': codebuild.BuildEnvironmentVariableType.PLAINTEXT, + 'Value.$': '$.envVariables.zone', + }, + ], + }, + }); +}); + +test('with the all parameters', () => { + // WHEN + const task = new CodeBuildStartBuildBatch(stack, 'Task', { + project: codebuildProject, + integrationPattern: sfn.IntegrationPattern.RUN_JOB, + environmentVariablesOverride: { + env: { + type: codebuild.BuildEnvironmentVariableType.PLAINTEXT, + value: 'prod', + }, + }, + }); + + // THEN + expect(stack.resolve(task.toStateJson())).toEqual({ + Type: 'Task', + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':states:::codebuild:startBuildBatch.sync', + ], + ], + }, + End: true, + Parameters: { + ProjectName: { + Ref: 'ProjectC78D97AD', + }, + EnvironmentVariablesOverride: [ + { + Name: 'env', + Type: codebuild.BuildEnvironmentVariableType.PLAINTEXT, + Value: 'prod', + }, + ], + }, + }); +}); + +test('Task throws if WAIT_FOR_TASK_TOKEN is supplied as service integration pattern', () => { + expect(() => { + new CodeBuildStartBuildBatch(stack, 'Task', { + project: codebuildProject, + integrationPattern: sfn.IntegrationPattern.WAIT_FOR_TASK_TOKEN, + }); + }).toThrow( + /Unsupported service integration pattern. Supported Patterns: REQUEST_RESPONSE,RUN_JOB. Received: WAIT_FOR_TASK_TOKEN/, + ); +}); From f540b87bf6b07e52738718cdf2c900fabf1678cd Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Thu, 29 Feb 2024 23:51:56 +0900 Subject: [PATCH 05/18] test: update integ test --- .../StartBuildBatch.assets.json | 4 +- .../StartBuildBatch.template.json | 45 ++++++++++- ...faultTestDeployAssert142C169A.assets.json} | 2 +- ...ultTestDeployAssert142C169A.template.json} | 0 .../integ.json | 6 +- .../manifest.json | 20 ++--- .../tree.json | 75 +++++++++++++++---- .../test/codebuild/integ.start-build-batch.ts | 18 ++++- 8 files changed, 132 insertions(+), 38 deletions(-) rename packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/{StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets.json => StartBuildBatchIntegDefaultTestDeployAssert142C169A.assets.json} (87%) rename packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/{StartBuildBatchintegDefaultTestDeployAssert4AD576F9.template.json => StartBuildBatchIntegDefaultTestDeployAssert142C169A.template.json} (100%) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json index a2f02b173228d..7ad858a0bc342 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json @@ -1,7 +1,7 @@ { "version": "36.0.0", "files": { - "8287e3621f92198786f7e941852291d2f93ef868bd62f5e957f82b9c42fbb8d7": { + "4d3b6d934e181e57229f3f003946e06f28876e4f60dfe5334cceaebd5e821b7c": { "source": { "path": "StartBuildBatch.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "8287e3621f92198786f7e941852291d2f93ef868bd62f5e957f82b9c42fbb8d7.json", + "objectKey": "4d3b6d934e181e57229f3f003946e06f28876e4f60dfe5334cceaebd5e821b7c.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json index c309a1a7722e4..e9aa159b248eb 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json @@ -144,7 +144,7 @@ "EncryptionKey": "alias/aws/s3", "Environment": { "ComputeType": "BUILD_GENERAL1_SMALL", - "Image": "aws/codebuild/standard:1.0", + "Image": "aws/codebuild/standard:5.0", "ImagePullCredentialsType": "CODEBUILD", "PrivilegedMode": false, "Type": "LINUX_CONTAINER" @@ -157,9 +157,10 @@ ] }, "Source": { - "BuildSpec": "version: 0.2\nenvironment:\n buildImage:\n type: LINUX_CONTAINER\n defaultComputeType: BUILD_GENERAL1_SMALL\n imageId: aws/codebuild/standard:5.0\n imagePullPrincipalType: CODEBUILD\n secretsManagerCredentials: null\n repository: null\ntimeout:\n amount: 1\n unit:\n label: hours\n isoLabel: H\n inMillis: 3600000\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", + "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", "Type": "NO_SOURCE" - } + }, + "TimeoutInMinutes": 60 } }, "ProjectBatchServiceRoleF97A1CFB": { @@ -246,6 +247,34 @@ "Arn" ] } + }, + { + "Action": [ + "events:DescribeRule", + "events:PutRule", + "events:PutTargets" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":events:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":rule/StepFunctionsGetEventForCodeBuildStartBuildRule" + ] + ] + } } ], "Version": "2012-10-17" @@ -265,7 +294,7 @@ "Fn::Join": [ "", [ - "{\"StartAt\":\"Start\",\"States\":{\"Start\":{\"Type\":\"Pass\",\"Result\":{\"bar\":\"SomeValue\"},\"Next\":\"buildTask\"},\"buildTask\":{\"End\":true,\"Type\":\"Task\",\"Resource\":\"arn:", + "{\"StartAt\":\"Start\",\"States\":{\"Start\":{\"Type\":\"Pass\",\"Result\":{\"bar\":\"SomeValue\"},\"Next\":\"buildTask1\"},\"buildTask1\":{\"Next\":\"buildTask2\",\"Type\":\"Task\",\"Resource\":\"arn:", { "Ref": "AWS::Partition" }, @@ -273,6 +302,14 @@ { "Ref": "ProjectC78D97AD" }, + "\",\"EnvironmentVariablesOverride\":[{\"Name\":\"test\",\"Type\":\"PLAINTEXT\",\"Value\":\"testValue\"}]}},\"buildTask2\":{\"End\":true,\"Type\":\"Task\",\"Resource\":\"arn:", + { + "Ref": "AWS::Partition" + }, + ":states:::codebuild:startBuildBatch.sync\",\"Parameters\":{\"ProjectName\":\"", + { + "Ref": "ProjectC78D97AD" + }, "\",\"EnvironmentVariablesOverride\":[{\"Name\":\"test\",\"Type\":\"PLAINTEXT\",\"Value\":\"testValue\"}]}}}}" ] ] diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchIntegDefaultTestDeployAssert142C169A.assets.json similarity index 87% rename from packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchIntegDefaultTestDeployAssert142C169A.assets.json index 44af2929912e5..bb963bcd7c8ab 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchIntegDefaultTestDeployAssert142C169A.assets.json @@ -3,7 +3,7 @@ "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { - "path": "StartBuildBatchintegDefaultTestDeployAssert4AD576F9.template.json", + "path": "StartBuildBatchIntegDefaultTestDeployAssert142C169A.template.json", "packaging": "file" }, "destinations": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchintegDefaultTestDeployAssert4AD576F9.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchIntegDefaultTestDeployAssert142C169A.template.json similarity index 100% rename from packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchintegDefaultTestDeployAssert4AD576F9.template.json rename to packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatchIntegDefaultTestDeployAssert142C169A.template.json diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/integ.json index 2bf83d5028b93..fa32ffe5a59f1 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/integ.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/integ.json @@ -1,12 +1,12 @@ { "version": "36.0.0", "testCases": { - "StartBuildBatchinteg/DefaultTest": { + "StartBuildBatchInteg/DefaultTest": { "stacks": [ "StartBuildBatch" ], - "assertionStack": "StartBuildBatchinteg/DefaultTest/DeployAssert", - "assertionStackName": "StartBuildBatchintegDefaultTestDeployAssert4AD576F9" + "assertionStack": "StartBuildBatchInteg/DefaultTest/DeployAssert", + "assertionStackName": "StartBuildBatchIntegDefaultTestDeployAssert142C169A" } } } \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json index 468ec3665bb87..14abd443e97dd 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json @@ -18,7 +18,7 @@ "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}/8287e3621f92198786f7e941852291d2f93ef868bd62f5e957f82b9c42fbb8d7.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/4d3b6d934e181e57229f3f003946e06f28876e4f60dfe5334cceaebd5e821b7c.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -97,19 +97,19 @@ }, "displayName": "StartBuildBatch" }, - "StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets": { + "StartBuildBatchIntegDefaultTestDeployAssert142C169A.assets": { "type": "cdk:asset-manifest", "properties": { - "file": "StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets.json", + "file": "StartBuildBatchIntegDefaultTestDeployAssert142C169A.assets.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" } }, - "StartBuildBatchintegDefaultTestDeployAssert4AD576F9": { + "StartBuildBatchIntegDefaultTestDeployAssert142C169A": { "type": "aws:cloudformation:stack", "environment": "aws://unknown-account/unknown-region", "properties": { - "templateFile": "StartBuildBatchintegDefaultTestDeployAssert4AD576F9.template.json", + "templateFile": "StartBuildBatchIntegDefaultTestDeployAssert142C169A.template.json", "terminationProtection": false, "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", @@ -118,7 +118,7 @@ "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ - "StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets" + "StartBuildBatchIntegDefaultTestDeployAssert142C169A.assets" ], "lookupRole": { "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", @@ -127,23 +127,23 @@ } }, "dependencies": [ - "StartBuildBatchintegDefaultTestDeployAssert4AD576F9.assets" + "StartBuildBatchIntegDefaultTestDeployAssert142C169A.assets" ], "metadata": { - "/StartBuildBatchinteg/DefaultTest/DeployAssert/BootstrapVersion": [ + "/StartBuildBatchInteg/DefaultTest/DeployAssert/BootstrapVersion": [ { "type": "aws:cdk:logicalId", "data": "BootstrapVersion" } ], - "/StartBuildBatchinteg/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + "/StartBuildBatchInteg/DefaultTest/DeployAssert/CheckBootstrapVersion": [ { "type": "aws:cdk:logicalId", "data": "CheckBootstrapVersion" } ] }, - "displayName": "StartBuildBatchinteg/DefaultTest/DeployAssert" + "displayName": "StartBuildBatchInteg/DefaultTest/DeployAssert" }, "Tree": { "type": "cdk:tree", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json index eed83b4056c13..d616277ff8bc5 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json @@ -203,7 +203,7 @@ "encryptionKey": "alias/aws/s3", "environment": { "type": "LINUX_CONTAINER", - "image": "aws/codebuild/standard:1.0", + "image": "aws/codebuild/standard:5.0", "imagePullCredentialsType": "CODEBUILD", "privilegedMode": false, "computeType": "BUILD_GENERAL1_SMALL" @@ -217,8 +217,9 @@ }, "source": { "type": "NO_SOURCE", - "buildSpec": "version: 0.2\nenvironment:\n buildImage:\n type: LINUX_CONTAINER\n defaultComputeType: BUILD_GENERAL1_SMALL\n imageId: aws/codebuild/standard:5.0\n imagePullPrincipalType: CODEBUILD\n secretsManagerCredentials: null\n repository: null\ntimeout:\n amount: 1\n unit:\n label: hours\n isoLabel: H\n inMillis: 3600000\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" - } + "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" + }, + "timeoutInMinutes": 60 } }, "constructInfo": { @@ -323,9 +324,17 @@ "version": "0.0.0" } }, - "buildTask": { - "id": "buildTask", - "path": "StartBuildBatch/buildTask", + "buildTask1": { + "id": "buildTask1", + "path": "StartBuildBatch/buildTask1", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions_tasks.CodeBuildStartBuildBatch", + "version": "0.0.0" + } + }, + "buildTask2": { + "id": "buildTask2", + "path": "StartBuildBatch/buildTask2", "constructInfo": { "fqn": "aws-cdk-lib.aws_stepfunctions_tasks.CodeBuildStartBuildBatch", "version": "0.0.0" @@ -407,6 +416,34 @@ "Arn" ] } + }, + { + "Action": [ + "events:DescribeRule", + "events:PutRule", + "events:PutTargets" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":events:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":rule/StepFunctionsGetEventForCodeBuildStartBuildRule" + ] + ] + } } ], "Version": "2012-10-17" @@ -446,7 +483,7 @@ "Fn::Join": [ "", [ - "{\"StartAt\":\"Start\",\"States\":{\"Start\":{\"Type\":\"Pass\",\"Result\":{\"bar\":\"SomeValue\"},\"Next\":\"buildTask\"},\"buildTask\":{\"End\":true,\"Type\":\"Task\",\"Resource\":\"arn:", + "{\"StartAt\":\"Start\",\"States\":{\"Start\":{\"Type\":\"Pass\",\"Result\":{\"bar\":\"SomeValue\"},\"Next\":\"buildTask1\"},\"buildTask1\":{\"Next\":\"buildTask2\",\"Type\":\"Task\",\"Resource\":\"arn:", { "Ref": "AWS::Partition" }, @@ -454,6 +491,14 @@ { "Ref": "ProjectC78D97AD" }, + "\",\"EnvironmentVariablesOverride\":[{\"Name\":\"test\",\"Type\":\"PLAINTEXT\",\"Value\":\"testValue\"}]}},\"buildTask2\":{\"End\":true,\"Type\":\"Task\",\"Resource\":\"arn:", + { + "Ref": "AWS::Partition" + }, + ":states:::codebuild:startBuildBatch.sync\",\"Parameters\":{\"ProjectName\":\"", + { + "Ref": "ProjectC78D97AD" + }, "\",\"EnvironmentVariablesOverride\":[{\"Name\":\"test\",\"Type\":\"PLAINTEXT\",\"Value\":\"testValue\"}]}}}}" ] ] @@ -499,17 +544,17 @@ "version": "0.0.0" } }, - "StartBuildBatchinteg": { - "id": "StartBuildBatchinteg", - "path": "StartBuildBatchinteg", + "StartBuildBatchInteg": { + "id": "StartBuildBatchInteg", + "path": "StartBuildBatchInteg", "children": { "DefaultTest": { "id": "DefaultTest", - "path": "StartBuildBatchinteg/DefaultTest", + "path": "StartBuildBatchInteg/DefaultTest", "children": { "Default": { "id": "Default", - "path": "StartBuildBatchinteg/DefaultTest/Default", + "path": "StartBuildBatchInteg/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", "version": "10.3.0" @@ -517,11 +562,11 @@ }, "DeployAssert": { "id": "DeployAssert", - "path": "StartBuildBatchinteg/DefaultTest/DeployAssert", + "path": "StartBuildBatchInteg/DefaultTest/DeployAssert", "children": { "BootstrapVersion": { "id": "BootstrapVersion", - "path": "StartBuildBatchinteg/DefaultTest/DeployAssert/BootstrapVersion", + "path": "StartBuildBatchInteg/DefaultTest/DeployAssert/BootstrapVersion", "constructInfo": { "fqn": "aws-cdk-lib.CfnParameter", "version": "0.0.0" @@ -529,7 +574,7 @@ }, "CheckBootstrapVersion": { "id": "CheckBootstrapVersion", - "path": "StartBuildBatchinteg/DefaultTest/DeployAssert/CheckBootstrapVersion", + "path": "StartBuildBatchInteg/DefaultTest/DeployAssert/CheckBootstrapVersion", "constructInfo": { "fqn": "aws-cdk-lib.CfnRule", "version": "0.0.0" diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.ts index 268e9123e1b2a..9556b37f07af8 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.ts @@ -53,8 +53,20 @@ class TestStack extends cdk.Stack { throw new Error('Batch builds not enabled'); } - const startBuildBatch = new tasks.CodeBuildStartBuildBatch(this, 'buildTask', { + const startBuildBatch1 = new tasks.CodeBuildStartBuildBatch(this, 'buildTask1', { project, + integrationPattern: sfn.IntegrationPattern.REQUEST_RESPONSE, + environmentVariablesOverride: { + test: { + type: codebuild.BuildEnvironmentVariableType.PLAINTEXT, + value: 'testValue', + }, + }, + }); + + const startBuildBatch2 = new tasks.CodeBuildStartBuildBatch(this, 'buildTask2', { + project, + integrationPattern: sfn.IntegrationPattern.RUN_JOB, environmentVariablesOverride: { test: { type: codebuild.BuildEnvironmentVariableType.PLAINTEXT, @@ -65,7 +77,7 @@ class TestStack extends cdk.Stack { const definition = new sfn.Pass(this, 'Start', { result: sfn.Result.fromObject({ bar: 'SomeValue' }), - }).next(startBuildBatch); + }).next(startBuildBatch1).next(startBuildBatch2); new sfn.StateMachine(this, 'StateMachine', { definition, @@ -75,7 +87,7 @@ class TestStack extends cdk.Stack { const app = new cdk.App(); const stack = new TestStack(app, 'StartBuildBatch'); -new IntegTest(app, 'StartBuildBatchinteg', { +new IntegTest(app, 'StartBuildBatchInteg', { testCases: [stack], }); From b60243607d961aacbf4dfffda46b3c91bed2be70 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Fri, 1 Mar 2024 00:21:14 +0900 Subject: [PATCH 06/18] docs: update readme --- .../aws-stepfunctions-tasks/README.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md index c19d860f46892..cf9cf96d40a02 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md @@ -386,6 +386,31 @@ const task = new tasks.CodeBuildStartBuild(this, 'Task', { }); ``` +### StartBuildBatch + +[StartBuildBatch](https://docs.aws.amazon.com/codebuild/latest/APIReference/API_StartBuildBatch.html) starts a CodeBuild Project by Project Name. +It is necessary to enable the batch build feature in the CodeBuild project. + +```ts +declare const project: codebuild.Project; + +const buildconfig = project.enableBatchBuilds(); +if (buildconfig == null) { + throw new Error('Batch builds not enabled'); +} + +const task = = new tasks.CodeBuildStartBuildBatch(this, 'buildBatchTask', { + project, + integrationPattern: sfn.IntegrationPattern.REQUEST_RESPONSE, + environmentVariablesOverride: { + test: { + type: codebuild.BuildEnvironmentVariableType.PLAINTEXT, + value: 'testValue', + }, + }, +}); +``` + ## DynamoDB You can call DynamoDB APIs from a `Task` state. From 54b82b6250a120d75d4d852439cb4ea5cc76fd7f Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Fri, 1 Mar 2024 00:37:25 +0900 Subject: [PATCH 07/18] docs: udpate readme --- .../aws-stepfunctions-tasks/README.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md index cf9cf96d40a02..a4dac3fc3ef64 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md @@ -392,9 +392,22 @@ const task = new tasks.CodeBuildStartBuild(this, 'Task', { It is necessary to enable the batch build feature in the CodeBuild project. ```ts -declare const project: codebuild.Project; - +const project = new codebuild.Project(this, 'Project', { + projectName: 'MyTestProject', + buildSpec: codebuild.BuildSpec.fromObjectToYaml({ + version: 0.2, + batch: { + 'build-list': [ + { + identifier: 'id', + buildspec: 'version: 0.2\nphases:\n build:\n commands:\n - echo "Hello, from small!"', + }, + ], + }, + }), +}); const buildconfig = project.enableBatchBuilds(); + if (buildconfig == null) { throw new Error('Batch builds not enabled'); } From f907fdddf615460b4395fe721d77c312114909f9 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Fri, 1 Mar 2024 01:07:48 +0900 Subject: [PATCH 08/18] test: fix unit test --- .../lib/codebuild/start-build-batch.ts | 65 +++++++++++-------- .../test/codebuild/start-build-batch.test.ts | 61 ++++++++++++++++- 2 files changed, 97 insertions(+), 29 deletions(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts index 4a1fbf07656c4..77e1c6004031a 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts @@ -54,32 +54,46 @@ export class CodeBuildStartBuildBatch extends sfn.TaskStateBase { this.taskPolicies = this.configurePolicyStatements(); } + /** + * configure the necessary permissions for invoke the CodeBuild StartBuildBatch API + * + * @see https://docs.aws.amazon.com/step-functions/latest/dg/codebuild-iam.html#codebuild-iam-startbuildbatch + */ private configurePolicyStatements(): iam.PolicyStatement[] { - let policyStatements = [ - new iam.PolicyStatement({ - resources: [this.props.project.projectArn], - actions: [ - 'codebuild:StartBuildBatch', - 'codebuild:StopBuildBatch', - 'codebuild:BatchGetBuilds', - 'codebuild:BatchGetReports', - 'codebuild:ListBuildsForProject', - ], - }), - ]; + let policyStatements: iam.PolicyStatement[]; - if (this.integrationPattern === sfn.IntegrationPattern.RUN_JOB) { - policyStatements.push( - new iam.PolicyStatement({ - actions: ['events:PutTargets', 'events:PutRule', 'events:DescribeRule'], - resources: [ - cdk.Stack.of(this).formatArn({ - service: 'events', - resource: 'rule/StepFunctionsGetEventForCodeBuildStartBuildRule', - }), - ], - }), - ); + switch (this.integrationPattern) { + case sfn.IntegrationPattern.RUN_JOB: + policyStatements = [ + new iam.PolicyStatement({ + resources: [this.props.project.projectArn], + actions: [ + 'codebuild:StartBuildBatch', + 'codebuild:StopBuildBatch', + 'codebuild:BatchGetBuildBatches', + ], + }), + new iam.PolicyStatement({ + actions: ['events:PutTargets', 'events:PutRule', 'events:DescribeRule'], + resources: [ + cdk.Stack.of(this).formatArn({ + service: 'events', + resource: 'rule/StepFunctionsGetEventForCodeBuildStartBuildBatchRule', + }), + ], + }), + ]; + break; + case sfn.IntegrationPattern.REQUEST_RESPONSE: + policyStatements = [ + new iam.PolicyStatement({ + resources: ['*'], + actions: ['codebuild:StartBuildBatch'], + }), + ]; + break; + default: + throw new Error(`Unsupported integration pattern: ${this.integrationPattern}`); } return policyStatements; @@ -87,8 +101,7 @@ export class CodeBuildStartBuildBatch extends sfn.TaskStateBase { /** * Provides the CodeBuild StartBuild service integration task configuration - */ - /** + * * @internal */ protected _renderTask(): any { diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts index fa280a324371c..d9f3b6b68e3d6 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts @@ -1,3 +1,4 @@ +import { Template, Match } from '../../../assertions'; import * as codebuild from '../../../aws-codebuild'; import * as sfn from '../../../aws-stepfunctions'; import * as cdk from '../../../core'; @@ -33,6 +34,9 @@ test('only the required parameters', () => { const task = new CodeBuildStartBuildBatch(stack, 'Task', { project: codebuildProject, }); + new sfn.StateMachine(stack, 'StateMachine', { + definitionBody: sfn.DefinitionBody.fromChainable(task), + }); // THEN expect(stack.resolve(task.toStateJson())).toEqual({ @@ -56,13 +60,21 @@ test('only the required parameters', () => { }, }, }); + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { + PolicyDocument: { + Statement: [{ + Action: 'codebuild:StartBuildBatch', + Effect: 'Allow', + Resource: '*', + }], + }, + }); }); test('supports tokens', () => { // WHEN const task = new CodeBuildStartBuildBatch(stack, 'Task', { project: codebuildProject, - integrationPattern: sfn.IntegrationPattern.RUN_JOB, environmentVariablesOverride: { ZONE: { type: codebuild.BuildEnvironmentVariableType.PLAINTEXT, @@ -70,6 +82,9 @@ test('supports tokens', () => { }, }, }); + new sfn.StateMachine(stack, 'StateMachine', { + definitionBody: sfn.DefinitionBody.fromChainable(task), + }); // THEN expect(stack.resolve(task.toStateJson())).toEqual({ @@ -82,7 +97,7 @@ test('supports tokens', () => { { Ref: 'AWS::Partition', }, - ':states:::codebuild:startBuildBatch.sync', + ':states:::codebuild:startBuildBatch', ], ], }, @@ -114,6 +129,9 @@ test('with the all parameters', () => { }, }, }); + new sfn.StateMachine(stack, 'StateMachine', { + definitionBody: sfn.DefinitionBody.fromChainable(task), + }); // THEN expect(stack.resolve(task.toStateJson())).toEqual({ @@ -144,9 +162,46 @@ test('with the all parameters', () => { ], }, }); + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { + PolicyDocument: { + Statement: Match.arrayWith([ + { + Action: ['codebuild:StartBuildBatch', 'codebuild:StopBuildBatch', 'codebuild:BatchGetBuildBatches'], + Effect: 'Allow', + Resource: { + 'Fn::GetAtt': ['ProjectC78D97AD', 'Arn'], + }, + }, + { + Action: ['events:PutTargets', 'events:PutRule', 'events:DescribeRule'], + Effect: 'Allow', + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':events:', + { + Ref: 'AWS::Region', + }, + ':', + { + Ref: 'AWS::AccountId', + }, + ':rule/StepFunctionsGetEventForCodeBuildStartBuildBatchRule', + ], + ], + }, + }, + ]), + }, + }); }); -test('Task throws if WAIT_FOR_TASK_TOKEN is supplied as service integration pattern', () => { +test('throw error when WAIT_FOR_TASK_TOKEN is supplied as service integration pattern', () => { expect(() => { new CodeBuildStartBuildBatch(stack, 'Task', { project: codebuildProject, From 704cf023cc6c2d48f18e7edf8d154afd963c7806 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Fri, 1 Mar 2024 01:31:32 +0900 Subject: [PATCH 09/18] test: update integ test --- .../StartBuildBatch.assets.json | 4 ++-- .../StartBuildBatch.template.json | 6 ++---- .../integ.start-build-batch.js.snapshot/manifest.json | 2 +- .../codebuild/integ.start-build-batch.js.snapshot/tree.json | 6 ++---- .../lib/codebuild/start-build-batch.ts | 2 +- .../test/codebuild/start-build-batch.test.ts | 4 +++- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json index 7ad858a0bc342..fc26527706df7 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.assets.json @@ -1,7 +1,7 @@ { "version": "36.0.0", "files": { - "4d3b6d934e181e57229f3f003946e06f28876e4f60dfe5334cceaebd5e821b7c": { + "5a4a7364d62c5bab6b3ec3ccfa6d371f59724308214a3fd5da99da666d1c943a": { "source": { "path": "StartBuildBatch.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "4d3b6d934e181e57229f3f003946e06f28876e4f60dfe5334cceaebd5e821b7c.json", + "objectKey": "5a4a7364d62c5bab6b3ec3ccfa6d371f59724308214a3fd5da99da666d1c943a.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json index e9aa159b248eb..baa81c2db7b3a 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/StartBuildBatch.template.json @@ -234,9 +234,7 @@ "Statement": [ { "Action": [ - "codebuild:BatchGetBuilds", - "codebuild:BatchGetReports", - "codebuild:ListBuildsForProject", + "codebuild:BatchGetBuildBatches", "codebuild:StartBuildBatch", "codebuild:StopBuildBatch" ], @@ -271,7 +269,7 @@ { "Ref": "AWS::AccountId" }, - ":rule/StepFunctionsGetEventForCodeBuildStartBuildRule" + ":rule/StepFunctionsGetEventForCodeBuildStartBuildBatchRule" ] ] } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json index 14abd443e97dd..22303e0a7c37c 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/manifest.json @@ -18,7 +18,7 @@ "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}/4d3b6d934e181e57229f3f003946e06f28876e4f60dfe5334cceaebd5e821b7c.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/5a4a7364d62c5bab6b3ec3ccfa6d371f59724308214a3fd5da99da666d1c943a.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json index d616277ff8bc5..b9568a47cac9f 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/codebuild/integ.start-build-batch.js.snapshot/tree.json @@ -403,9 +403,7 @@ "Statement": [ { "Action": [ - "codebuild:BatchGetBuilds", - "codebuild:BatchGetReports", - "codebuild:ListBuildsForProject", + "codebuild:BatchGetBuildBatches", "codebuild:StartBuildBatch", "codebuild:StopBuildBatch" ], @@ -440,7 +438,7 @@ { "Ref": "AWS::AccountId" }, - ":rule/StepFunctionsGetEventForCodeBuildStartBuildRule" + ":rule/StepFunctionsGetEventForCodeBuildStartBuildBatchRule" ] ] } diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts index 77e1c6004031a..29779bcd75031 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts @@ -87,7 +87,7 @@ export class CodeBuildStartBuildBatch extends sfn.TaskStateBase { case sfn.IntegrationPattern.REQUEST_RESPONSE: policyStatements = [ new iam.PolicyStatement({ - resources: ['*'], + resources: [this.props.project.projectArn], actions: ['codebuild:StartBuildBatch'], }), ]; diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts index d9f3b6b68e3d6..6802ae56931d9 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts @@ -65,7 +65,9 @@ test('only the required parameters', () => { Statement: [{ Action: 'codebuild:StartBuildBatch', Effect: 'Allow', - Resource: '*', + Resource: { + 'Fn::GetAtt': ['ProjectC78D97AD', 'Arn'], + }, }], }, }); From 32e3f7a93ba53d1e743a8f79b0fb4446467291f3 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Fri, 1 Mar 2024 02:27:09 +0900 Subject: [PATCH 10/18] fix: readme --- packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md index a4dac3fc3ef64..b79ba00eb6c5c 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md @@ -392,6 +392,8 @@ const task = new tasks.CodeBuildStartBuild(this, 'Task', { It is necessary to enable the batch build feature in the CodeBuild project. ```ts +import * as codebuild from 'aws-cdk-lib/aws-codebuild'; + const project = new codebuild.Project(this, 'Project', { projectName: 'MyTestProject', buildSpec: codebuild.BuildSpec.fromObjectToYaml({ @@ -412,7 +414,7 @@ if (buildconfig == null) { throw new Error('Batch builds not enabled'); } -const task = = new tasks.CodeBuildStartBuildBatch(this, 'buildBatchTask', { +const task = new tasks.CodeBuildStartBuildBatch(this, 'buildBatchTask', { project, integrationPattern: sfn.IntegrationPattern.REQUEST_RESPONSE, environmentVariablesOverride: { From 5aab0634f83f1fc4a2c8c111e9f2f9d2b6d4ac73 Mon Sep 17 00:00:00 2001 From: kazuho cryer-shinozuka Date: Sun, 3 Mar 2024 07:09:45 +0900 Subject: [PATCH 11/18] =?UTF-8?q?start-build-batch.ts=20=E3=82=92=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Luca Pizzini --- .../aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts index 29779bcd75031..ca1048a678d50 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts @@ -13,6 +13,7 @@ export interface CodeBuildStartBuildBatchProps extends sfn.TaskStateBaseProps { * CodeBuild project to start */ readonly project: codebuild.IProject; + /** * A set of environment variables to be used for this build only. * From 791d6419f8a1135c130c71b33ed4787fbd15737c Mon Sep 17 00:00:00 2001 From: kazuho cryer-shinozuka Date: Sun, 3 Mar 2024 07:10:02 +0900 Subject: [PATCH 12/18] =?UTF-8?q?start-build-batch.ts=20=E3=82=92=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Luca Pizzini --- .../aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts index ca1048a678d50..e8b8b4d74cbbc 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts @@ -56,7 +56,7 @@ export class CodeBuildStartBuildBatch extends sfn.TaskStateBase { } /** - * configure the necessary permissions for invoke the CodeBuild StartBuildBatch API + * Configure the necessary permissions to invoke the CodeBuild StartBuildBatch API * * @see https://docs.aws.amazon.com/step-functions/latest/dg/codebuild-iam.html#codebuild-iam-startbuildbatch */ From 9c3d755701cffaa07c3b1a9cb7aea61c0870322d Mon Sep 17 00:00:00 2001 From: kazuho cryer-shinozuka Date: Sun, 3 Mar 2024 07:10:18 +0900 Subject: [PATCH 13/18] =?UTF-8?q?start-build-batch.ts=20=E3=82=92=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Luca Pizzini --- .../aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts index e8b8b4d74cbbc..c08c3299b9107 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/codebuild/start-build-batch.ts @@ -25,7 +25,7 @@ export interface CodeBuildStartBuildBatchProps extends sfn.TaskStateBaseProps { /** * Start a CodeBuild BatchBuild as a task * - * @see https://docs.aws.amazon.com/step-functions/latest/dg/connect-codebuild.html + * @see https://docs.aws.amazon.com/codebuild/latest/APIReference/API_StartBuildBatch.html */ export class CodeBuildStartBuildBatch extends sfn.TaskStateBase { private static readonly SUPPORTED_INTEGRATION_PATTERNS: sfn.IntegrationPattern[] = [ From 361399738a713449995bb4645c54658505c1bde0 Mon Sep 17 00:00:00 2001 From: kazuho cryer-shinozuka Date: Sun, 3 Mar 2024 07:11:32 +0900 Subject: [PATCH 14/18] =?UTF-8?q?README.md=20=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md index b79ba00eb6c5c..1dd8bb7efa508 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md @@ -388,7 +388,7 @@ const task = new tasks.CodeBuildStartBuild(this, 'Task', { ### StartBuildBatch -[StartBuildBatch](https://docs.aws.amazon.com/codebuild/latest/APIReference/API_StartBuildBatch.html) starts a CodeBuild Project by Project Name. +[StartBuildBatch](https://docs.aws.amazon.com/codebuild/latest/APIReference/API_StartBuildBatch.html) starts a batch CodeBuild for a project by project name. It is necessary to enable the batch build feature in the CodeBuild project. ```ts From cf94ac2541138e5a2963dc2b9d02a9e4d3710cc5 Mon Sep 17 00:00:00 2001 From: kazuho cryer-shinozuka Date: Sun, 3 Mar 2024 07:11:43 +0900 Subject: [PATCH 15/18] =?UTF-8?q?start-build-batch.test.ts=20=E3=82=92?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Luca Pizzini --- .../test/codebuild/start-build-batch.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts index 6802ae56931d9..15d1d3f71ded3 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/codebuild/start-build-batch.test.ts @@ -119,7 +119,7 @@ test('supports tokens', () => { }); }); -test('with the all parameters', () => { +test('with all the parameters', () => { // WHEN const task = new CodeBuildStartBuildBatch(stack, 'Task', { project: codebuildProject, From 7aafd342b47268a09c5d3b91bc2959071ddc8a1a Mon Sep 17 00:00:00 2001 From: kazuho cryer-shinozuka Date: Sun, 3 Mar 2024 11:43:15 +0900 Subject: [PATCH 16/18] Update packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md index 1dd8bb7efa508..3b96aa8237b05 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md @@ -408,11 +408,7 @@ const project = new codebuild.Project(this, 'Project', { }, }), }); -const buildconfig = project.enableBatchBuilds(); - -if (buildconfig == null) { - throw new Error('Batch builds not enabled'); -} +project.enableBatchBuilds(); const task = new tasks.CodeBuildStartBuildBatch(this, 'buildBatchTask', { project, From 5cad03de9fcad1391c59d3d27ed08ddb7f10ca7f Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Sun, 3 Mar 2024 22:54:19 +0900 Subject: [PATCH 17/18] docs: update readme --- packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md index 3b96aa8237b05..1abc6189279b0 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md @@ -422,6 +422,9 @@ const task = new tasks.CodeBuildStartBuildBatch(this, 'buildBatchTask', { }); ``` +**Note**: `enableBatchBuilds()` is not supported for imported projects. +If you are using an imported project, you must ensure that the project is already configured for batch builds. + ## DynamoDB You can call DynamoDB APIs from a `Task` state. From abd954e52e0f937d1a36c8c2f13c6a2cd8caec89 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Sun, 3 Mar 2024 23:17:30 +0900 Subject: [PATCH 18/18] docs: update README --- packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md index 1abc6189279b0..7d6d69da5df58 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md @@ -422,7 +422,7 @@ const task = new tasks.CodeBuildStartBuildBatch(this, 'buildBatchTask', { }); ``` -**Note**: `enableBatchBuilds()` is not supported for imported projects. +**Note**: `enableBatchBuilds()` will do nothing for imported projects. If you are using an imported project, you must ensure that the project is already configured for batch builds. ## DynamoDB