diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/DistributedMapDefaultTestDeployAssertFD6CBCC4.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/DistributedMapDefaultTestDeployAssertFD6CBCC4.assets.json new file mode 100644 index 0000000000000..adbd9c5df34ee --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/DistributedMapDefaultTestDeployAssertFD6CBCC4.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "DistributedMapDefaultTestDeployAssertFD6CBCC4.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/test/integ.distributed-map-execution-type.js.snapshot/DistributedMapDefaultTestDeployAssertFD6CBCC4.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/DistributedMapDefaultTestDeployAssertFD6CBCC4.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/DistributedMapDefaultTestDeployAssertFD6CBCC4.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/test/integ.distributed-map-execution-type.js.snapshot/aws-stepfunctions-map-integ-execution-type.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/aws-stepfunctions-map-integ-execution-type.assets.json new file mode 100644 index 0000000000000..651319669d0e5 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/aws-stepfunctions-map-integ-execution-type.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.0", + "files": { + "8c406e521fb5a80b4e54baa2bcde59aa7f482947d4e2dda969ca2a13ccb94ebd": { + "source": { + "path": "aws-stepfunctions-map-integ-execution-type.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "8c406e521fb5a80b4e54baa2bcde59aa7f482947d4e2dda969ca2a13ccb94ebd.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/test/integ.distributed-map-execution-type.js.snapshot/aws-stepfunctions-map-integ-execution-type.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/aws-stepfunctions-map-integ-execution-type.template.json new file mode 100644 index 0000000000000..0837e865d97ab --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/aws-stepfunctions-map-integ-execution-type.template.json @@ -0,0 +1,113 @@ +{ + "Resources": { + "StateMachineRoleB840431D": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "states.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "StateMachine2E01A3A5": { + "Type": "AWS::StepFunctions::StateMachine", + "Properties": { + "DefinitionString": "{\"StartAt\":\"DistributedMap\",\"States\":{\"DistributedMap\":{\"Type\":\"Map\",\"End\":true,\"ItemProcessor\":{\"ProcessorConfig\":{\"Mode\":\"DISTRIBUTED\",\"ExecutionType\":\"EXPRESS\"},\"StartAt\":\"Pass\",\"States\":{\"Pass\":{\"Type\":\"Pass\",\"End\":true}}}}}}", + "RoleArn": { + "Fn::GetAtt": [ + "StateMachineRoleB840431D", + "Arn" + ] + } + }, + "DependsOn": [ + "StateMachineRoleB840431D" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "StateMachineDistributedMapPolicy57C9D8C2": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "states:StartExecution", + "Effect": "Allow", + "Resource": { + "Ref": "StateMachine2E01A3A5" + } + }, + { + "Action": [ + "states:DescribeExecution", + "states:StopExecution" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + { + "Ref": "StateMachine2E01A3A5" + }, + ":*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "StateMachineDistributedMapPolicy57C9D8C2", + "Roles": [ + { + "Ref": "StateMachineRoleB840431D" + } + ] + } + } + }, + "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/test/integ.distributed-map-execution-type.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/cdk.out new file mode 100644 index 0000000000000..1f0068d32659a --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.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/test/integ.distributed-map-execution-type.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/integ.json new file mode 100644 index 0000000000000..dfa3c19f70da4 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "36.0.0", + "testCases": { + "DistributedMap/DefaultTest": { + "stacks": [ + "aws-stepfunctions-map-integ-execution-type" + ], + "assertionStack": "DistributedMap/DefaultTest/DeployAssert", + "assertionStackName": "DistributedMapDefaultTestDeployAssertFD6CBCC4" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/manifest.json new file mode 100644 index 0000000000000..aead87cbe94bc --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/manifest.json @@ -0,0 +1,125 @@ +{ + "version": "36.0.0", + "artifacts": { + "aws-stepfunctions-map-integ-execution-type.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "aws-stepfunctions-map-integ-execution-type.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "aws-stepfunctions-map-integ-execution-type": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "aws-stepfunctions-map-integ-execution-type.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}/8c406e521fb5a80b4e54baa2bcde59aa7f482947d4e2dda969ca2a13ccb94ebd.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "aws-stepfunctions-map-integ-execution-type.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": [ + "aws-stepfunctions-map-integ-execution-type.assets" + ], + "metadata": { + "/aws-stepfunctions-map-integ-execution-type/StateMachine/Role/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StateMachineRoleB840431D" + } + ], + "/aws-stepfunctions-map-integ-execution-type/StateMachine/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StateMachine2E01A3A5" + } + ], + "/aws-stepfunctions-map-integ-execution-type/StateMachine/DistributedMapPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "StateMachineDistributedMapPolicy57C9D8C2" + } + ], + "/aws-stepfunctions-map-integ-execution-type/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-stepfunctions-map-integ-execution-type/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "aws-stepfunctions-map-integ-execution-type" + }, + "DistributedMapDefaultTestDeployAssertFD6CBCC4.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "DistributedMapDefaultTestDeployAssertFD6CBCC4.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "DistributedMapDefaultTestDeployAssertFD6CBCC4": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "DistributedMapDefaultTestDeployAssertFD6CBCC4.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": [ + "DistributedMapDefaultTestDeployAssertFD6CBCC4.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": [ + "DistributedMapDefaultTestDeployAssertFD6CBCC4.assets" + ], + "metadata": { + "/DistributedMap/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/DistributedMap/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "DistributedMap/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/test/integ.distributed-map-execution-type.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/tree.json new file mode 100644 index 0000000000000..a3fe95ba54397 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.js.snapshot/tree.json @@ -0,0 +1,249 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "aws-stepfunctions-map-integ-execution-type": { + "id": "aws-stepfunctions-map-integ-execution-type", + "path": "aws-stepfunctions-map-integ-execution-type", + "children": { + "DistributedMap": { + "id": "DistributedMap", + "path": "aws-stepfunctions-map-integ-execution-type/DistributedMap", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions.DistributedMap", + "version": "0.0.0" + } + }, + "Pass": { + "id": "Pass", + "path": "aws-stepfunctions-map-integ-execution-type/Pass", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions.Pass", + "version": "0.0.0" + } + }, + "StateMachine": { + "id": "StateMachine", + "path": "aws-stepfunctions-map-integ-execution-type/StateMachine", + "children": { + "Role": { + "id": "Role", + "path": "aws-stepfunctions-map-integ-execution-type/StateMachine/Role", + "children": { + "ImportRole": { + "id": "ImportRole", + "path": "aws-stepfunctions-map-integ-execution-type/StateMachine/Role/ImportRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-stepfunctions-map-integ-execution-type/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" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-stepfunctions-map-integ-execution-type/StateMachine/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::StepFunctions::StateMachine", + "aws:cdk:cloudformation:props": { + "definitionString": "{\"StartAt\":\"DistributedMap\",\"States\":{\"DistributedMap\":{\"Type\":\"Map\",\"End\":true,\"ItemProcessor\":{\"ProcessorConfig\":{\"Mode\":\"DISTRIBUTED\",\"ExecutionType\":\"EXPRESS\"},\"StartAt\":\"Pass\",\"States\":{\"Pass\":{\"Type\":\"Pass\",\"End\":true}}}}}}", + "roleArn": { + "Fn::GetAtt": [ + "StateMachineRoleB840431D", + "Arn" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions.CfnStateMachine", + "version": "0.0.0" + } + }, + "DistributedMapPolicy": { + "id": "DistributedMapPolicy", + "path": "aws-stepfunctions-map-integ-execution-type/StateMachine/DistributedMapPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-stepfunctions-map-integ-execution-type/StateMachine/DistributedMapPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": "states:StartExecution", + "Effect": "Allow", + "Resource": { + "Ref": "StateMachine2E01A3A5" + } + }, + { + "Action": [ + "states:DescribeExecution", + "states:StopExecution" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + { + "Ref": "StateMachine2E01A3A5" + }, + ":*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "StateMachineDistributedMapPolicy57C9D8C2", + "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_stepfunctions.StateMachine", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "aws-stepfunctions-map-integ-execution-type/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "aws-stepfunctions-map-integ-execution-type/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "DistributedMap": { + "id": "DistributedMap", + "path": "DistributedMap", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "DistributedMap/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "DistributedMap/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "DistributedMap/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "DistributedMap/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "DistributedMap/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/test/integ.distributed-map-execution-type.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.ts new file mode 100644 index 0000000000000..58503268d9bbb --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions/test/integ.distributed-map-execution-type.ts @@ -0,0 +1,32 @@ +import * as cdk from 'aws-cdk-lib/core'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import * as sfn from 'aws-cdk-lib/aws-stepfunctions'; + +class DistributedMapStack extends cdk.Stack { + readonly stateMachine: sfn.StateMachine; + + constructor(scope: cdk.App, id: string, props?: cdk.StackProps) { + super(scope, id, props); + + const distributedMap = new sfn.DistributedMap(this, 'DistributedMap', { + mapExecutionType: sfn.StateMachineType.EXPRESS, + }); + distributedMap.itemProcessor(new sfn.Pass(this, 'Pass'), { + mode: sfn.ProcessorMode.DISTRIBUTED, + executionType: sfn.ProcessorType.STANDARD, + }); + + this.stateMachine = new sfn.StateMachine(this, 'StateMachine', { + definition: distributedMap, + }); + } +} + +const app = new cdk.App(); +const stack = new DistributedMapStack(app, 'aws-stepfunctions-map-integ-execution-type'); + +new IntegTest(app, 'DistributedMap', { + testCases: [stack], +}); + +app.synth(); diff --git a/packages/aws-cdk-lib/aws-stepfunctions/README.md b/packages/aws-cdk-lib/aws-stepfunctions/README.md index 6f85c657e05c4..92ca936868184 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/README.md +++ b/packages/aws-cdk-lib/aws-stepfunctions/README.md @@ -605,6 +605,21 @@ const distributedMap = new sfn.DistributedMap(this, 'Distributed Map State', { distributedMap.itemProcessor(new sfn.Pass(this, 'Pass State')); ``` +If you want to specify the execution type for the ItemProcessor in the DistributedMap, you must set the `mapExecutionType` property in the `DistributedMap` class. When using the `DistributedMap` class, the `ProcessorConfig.executionType` property is ignored. + +In the following example, the execution type for the ItemProcessor in the DistributedMap is set to `EXPRESS` based on the value specified for `mapExecutionType`. + +```ts +const distributedMap = new sfn.DistributedMap(this, 'DistributedMap', { + mapExecutionType: sfn.StateMachineType.EXPRESS, // mapExecutionType property is applied. +}); + +distributedMap.itemProcessor(new sfn.Pass(this, 'Pass'), { + mode: sfn.ProcessorMode.DISTRIBUTED, + executionType: sfn.ProcessorType.STANDARD, // ProcessorConfig.executionType is ignored +}); +``` + ### Custom State It's possible that the high-level constructs for the states or `stepfunctions-tasks` do not have diff --git a/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts b/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts index 00c24e02165e8..83765c4802b8d 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions/lib/states/distributed-map.ts @@ -3,6 +3,7 @@ import { ItemBatcher } from './distributed-map/item-batcher'; import { IItemReader } from './distributed-map/item-reader'; import { ResultWriter } from './distributed-map/result-writer'; import { MapBase, MapBaseProps } from './map-base'; +import { Annotations } from '../../../core'; import { FieldUtils } from '../fields'; import { StateGraph } from '../state-graph'; import { StateMachineType } from '../state-machine'; @@ -19,6 +20,8 @@ export interface DistributedMapProps extends MapBaseProps { * * The execution type of the distributed map state * + * This property overwrites ProcessorConfig.executionType + * * @default StateMachineType.STANDARD */ readonly mapExecutionType?: StateMachineType; @@ -110,7 +113,7 @@ export class DistributedMap extends MapBase implements INextable { * Return whether the given object is a DistributedMap. */ public static isDistributedMap(x: any): x is DistributedMap { - return x !== null && typeof(x) === 'object' && DISTRIBUTED_MAP_SYMBOL in x; + return x !== null && typeof (x) === 'object' && DISTRIBUTED_MAP_SYMBOL in x; } private readonly mapExecutionType?: StateMachineType; @@ -234,9 +237,10 @@ export class DistributedMap extends MapBase implements INextable { */ public toStateJson(): object { let rendered: any = super.toStateJson(); - if (this.mapExecutionType) { - rendered.ItemProcessor.ProcessorConfig.ExecutionType = this.mapExecutionType; + if (rendered.ItemProcessor.ProcessorConfig.ExecutionType) { + Annotations.of(this).addWarningV2('@aws-cdk/aws-stepfunctions:propertyIgnored', 'Property \'ProcessorConfig.executionType\' is ignored, use the \'mapExecutionType\' in the \'DistributedMap\' class instead.'); } + rendered.ItemProcessor.ProcessorConfig.ExecutionType = this.mapExecutionType; return { ...rendered, diff --git a/packages/aws-cdk-lib/aws-stepfunctions/lib/types.ts b/packages/aws-cdk-lib/aws-stepfunctions/lib/types.ts index 0bdfd1f4c33db..688af6e3875eb 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/lib/types.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions/lib/types.ts @@ -220,14 +220,17 @@ export interface ProcessorConfig { /** * Specifies the execution mode for the Map workflow. * - * @default - ProcessorMode.INLINE + * @default - ProcessorMode.INLINE if using the `Map` class, ProcessorMode.DISTRIBUTED if using the `DistributedMap` class */ readonly mode?: ProcessorMode; /** * Specifies the execution type for the Map workflow. * - * You must provide this field if you specified `DISTRIBUTED` for the `mode` sub-field. + * If you use the `Map` class, you must provide this field if you specified `DISTRIBUTED` for the `mode` sub-field. + * + * If you use the `DistributedMap` class, this property is ignored. + * Use the `mapExecutionType` in the `DistributedMap` class instead. * * @default - no execution type */ diff --git a/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts b/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts index 56795af26cbd3..3a75dd9d237f2 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions/test/distributed-map.test.ts @@ -1,3 +1,4 @@ +import { Annotations, Match } from '../../assertions'; import * as s3 from '../../aws-s3'; import * as cdk from '../../core'; import * as stepfunctions from '../lib'; @@ -778,6 +779,86 @@ describe('Distributed Map State', () => { app.synth(); }); + + test('State Machine With Distributed Map State should use default mapExecutionType and ignore itemProcessor executionType', () => { + // GIVEN + const stack = new cdk.Stack(); + + //WHEN + const map = new stepfunctions.DistributedMap(stack, 'Map State', { + }); + map.itemProcessor(new stepfunctions.Pass(stack, 'Pass State'), { + mode: stepfunctions.ProcessorMode.DISTRIBUTED, + executionType: stepfunctions.ProcessorType.EXPRESS, + }); + + //THEN + expect(render(map)).toStrictEqual({ + StartAt: 'Map State', + States: { + 'Map State': { + Type: 'Map', + End: true, + ItemProcessor: { + ProcessorConfig: { + Mode: stepfunctions.ProcessorMode.DISTRIBUTED, + ExecutionType: stepfunctions.StateMachineType.STANDARD, + }, + StartAt: 'Pass State', + States: { + 'Pass State': { + Type: 'Pass', + End: true, + }, + }, + }, + }, + }, + }); + + Annotations.fromStack(stack).hasWarning('/Default/Map State', Match.stringLikeRegexp('Property \'ProcessorConfig.executionType\' is ignored, use the \'mapExecutionType\' in the \'DistributedMap\' class instead.')); + }); + + test('State Machine With Distributed Map State should use configured mapExecutionType and ignore itemProcessor executionType', () => { + // GIVEN + const stack = new cdk.Stack(); + + //WHEN + const map = new stepfunctions.DistributedMap(stack, 'Map State', { + mapExecutionType: stepfunctions.StateMachineType.EXPRESS, + }); + map.itemProcessor(new stepfunctions.Pass(stack, 'Pass State'), { + mode: stepfunctions.ProcessorMode.DISTRIBUTED, + executionType: stepfunctions.ProcessorType.STANDARD, + }); + + //THEN + expect(render(map)).toStrictEqual({ + StartAt: 'Map State', + States: { + 'Map State': { + Type: 'Map', + End: true, + ItemProcessor: { + ProcessorConfig: { + Mode: stepfunctions.ProcessorMode.DISTRIBUTED, + ExecutionType: stepfunctions.StateMachineType.EXPRESS, + }, + StartAt: 'Pass State', + States: { + 'Pass State': { + Type: 'Pass', + End: true, + }, + }, + }, + }, + }, + }); + + Annotations.fromStack(stack).hasWarning('/Default/Map State', Match.stringLikeRegexp('Property \'ProcessorConfig.executionType\' is ignored, use the \'mapExecutionType\' in the \'DistributedMap\' class instead.')); + + }); }); function render(sm: stepfunctions.IChainable) {