diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/aws-sdk/integ.call-aws-service-sfn.js.snapshot/aws-stepfunctions-tasks-call-aws-service-sfn-integ.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/aws-sdk/integ.call-aws-service-sfn.js.snapshot/aws-stepfunctions-tasks-call-aws-service-sfn-integ.template.json index 68f1484adf044..a1eac24c0fe13 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/aws-sdk/integ.call-aws-service-sfn.js.snapshot/aws-stepfunctions-tasks-call-aws-service-sfn-integ.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/aws-sdk/integ.call-aws-service-sfn.js.snapshot/aws-stepfunctions-tasks-call-aws-service-sfn-integ.template.json @@ -93,7 +93,37 @@ "Action": "states:StartExecution", "Effect": "Allow", "Resource": { - "Ref": "ChildStateMachine9133117F" + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":states:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":execution:", + { + "Fn::Select": [ + 6, + { + "Fn::Split": [ + ":", + { + "Ref": "ChildStateMachine9133117F" + } + ] + } + ] + } + ] + ] } } ], diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/cdk.out new file mode 100644 index 0000000000000..560dae10d018f --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"33.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5.assets.json new file mode 100644 index 0000000000000..649b91ee923bf --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5.assets.json @@ -0,0 +1,19 @@ +{ + "version": "33.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5.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/stepfunctions/integ.start-execution-alias.js.snapshot/cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5.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/stepfunctions/integ.start-execution-alias.js.snapshot/integ-sfn-start-execution-alias.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/integ-sfn-start-execution-alias.assets.json new file mode 100644 index 0000000000000..fb4aa5713e3b0 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/integ-sfn-start-execution-alias.assets.json @@ -0,0 +1,19 @@ +{ + "version": "33.0.0", + "files": { + "a73e09d00cfe8b80032fb71af866ab9072fe1625675aefe92ac4cc9324cc1a40": { + "source": { + "path": "integ-sfn-start-execution-alias.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "a73e09d00cfe8b80032fb71af866ab9072fe1625675aefe92ac4cc9324cc1a40.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/stepfunctions/integ.start-execution-alias.js.snapshot/integ-sfn-start-execution-alias.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/integ-sfn-start-execution-alias.template.json new file mode 100644 index 0000000000000..bccc5cd6ac0fc --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/integ-sfn-start-execution-alias.template.json @@ -0,0 +1,275 @@ +{ + "Resources": { + "ChildRole1E3E0EF5": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "states.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "ChildDAB30558": { + "Type": "AWS::StepFunctions::StateMachine", + "Properties": { + "DefinitionString": "{\"StartAt\":\"Pass\",\"States\":{\"Pass\":{\"Type\":\"Pass\",\"End\":true}}}", + "RoleArn": { + "Fn::GetAtt": [ + "ChildRole1E3E0EF5", + "Arn" + ] + } + }, + "DependsOn": [ + "ChildRole1E3E0EF5" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "MyStateMachineVersion": { + "Type": "AWS::StepFunctions::StateMachineVersion", + "Properties": { + "StateMachineArn": { + "Ref": "ChildDAB30558" + }, + "StateMachineRevisionId": { + "Fn::GetAtt": [ + "ChildDAB30558", + "StateMachineRevisionId" + ] + } + } + }, + "MyStateMachineAlias": { + "Type": "AWS::StepFunctions::StateMachineAlias", + "Properties": { + "Name": "alias", + "RoutingConfiguration": [ + { + "StateMachineVersionArn": { + "Fn::GetAtt": [ + "MyStateMachineVersion", + "Arn" + ] + }, + "Weight": 100 + } + ] + } + }, + "ParentRole5F0C366C": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "states.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "ParentRoleDefaultPolicy9BDC56DC": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "states:StartExecution", + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":states:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":execution:", + { + "Fn::Select": [ + 6, + { + "Fn::Split": [ + ":", + { + "Ref": "ChildDAB30558" + } + ] + } + ] + } + ] + ] + } + }, + { + "Action": [ + "states:DescribeExecution", + "states:StopExecution" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":states:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":execution:", + { + "Fn::Select": [ + 6, + { + "Fn::Split": [ + ":", + { + "Ref": "ChildDAB30558" + } + ] + } + ] + }, + "*" + ] + ] + } + }, + { + "Action": [ + "events:DescribeRule", + "events:PutRule", + "events:PutTargets" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":events:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":rule/StepFunctionsGetEventsForStepFunctionsExecutionRule" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "ParentRoleDefaultPolicy9BDC56DC", + "Roles": [ + { + "Ref": "ParentRole5F0C366C" + } + ] + } + }, + "Parent8B210403": { + "Type": "AWS::StepFunctions::StateMachine", + "Properties": { + "DefinitionString": { + "Fn::Join": [ + "", + [ + "{\"StartAt\":\"Task\",\"States\":{\"Task\":{\"End\":true,\"Type\":\"Task\",\"Resource\":\"arn:", + { + "Ref": "AWS::Partition" + }, + ":states:::states:startExecution.sync:2\",\"Parameters\":{\"Input\":{\"hello.$\":\"$.hello\"},\"StateMachineArn\":\"", + { + "Ref": "ChildDAB30558" + }, + "\"}}}}" + ] + ] + }, + "RoleArn": { + "Fn::GetAtt": [ + "ParentRole5F0C366C", + "Arn" + ] + } + }, + "DependsOn": [ + "ParentRoleDefaultPolicy9BDC56DC", + "ParentRole5F0C366C" + ], + "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/stepfunctions/integ.start-execution-alias.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/integ.json new file mode 100644 index 0000000000000..80a819cda8a05 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "33.0.0", + "testCases": { + "cdk-integ-sfn-start-execution-alias/DefaultTest": { + "stacks": [ + "integ-sfn-start-execution-alias" + ], + "assertionStack": "cdk-integ-sfn-start-execution-alias/DefaultTest/DeployAssert", + "assertionStackName": "cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/manifest.json new file mode 100644 index 0000000000000..8d3b5047b2388 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/manifest.json @@ -0,0 +1,147 @@ +{ + "version": "33.0.0", + "artifacts": { + "integ-sfn-start-execution-alias.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "integ-sfn-start-execution-alias.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "integ-sfn-start-execution-alias": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "integ-sfn-start-execution-alias.template.json", + "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}/a73e09d00cfe8b80032fb71af866ab9072fe1625675aefe92ac4cc9324cc1a40.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "integ-sfn-start-execution-alias.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": [ + "integ-sfn-start-execution-alias.assets" + ], + "metadata": { + "/integ-sfn-start-execution-alias/Child/Role/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ChildRole1E3E0EF5" + } + ], + "/integ-sfn-start-execution-alias/Child/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ChildDAB30558" + } + ], + "/integ-sfn-start-execution-alias/MyStateMachineVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "MyStateMachineVersion" + } + ], + "/integ-sfn-start-execution-alias/MyStateMachineAlias": [ + { + "type": "aws:cdk:logicalId", + "data": "MyStateMachineAlias" + } + ], + "/integ-sfn-start-execution-alias/Parent/Role/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ParentRole5F0C366C" + } + ], + "/integ-sfn-start-execution-alias/Parent/Role/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ParentRoleDefaultPolicy9BDC56DC" + } + ], + "/integ-sfn-start-execution-alias/Parent/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Parent8B210403" + } + ], + "/integ-sfn-start-execution-alias/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/integ-sfn-start-execution-alias/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "integ-sfn-start-execution-alias" + }, + "cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5.template.json", + "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": [ + "cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5.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": [ + "cdkintegsfnstartexecutionaliasDefaultTestDeployAssert466C4AD5.assets" + ], + "metadata": { + "/cdk-integ-sfn-start-execution-alias/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/cdk-integ-sfn-start-execution-alias/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "cdk-integ-sfn-start-execution-alias/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/stepfunctions/integ.start-execution-alias.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/tree.json new file mode 100644 index 0000000000000..030f833ff18ce --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.js.snapshot/tree.json @@ -0,0 +1,473 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "integ-sfn-start-execution-alias": { + "id": "integ-sfn-start-execution-alias", + "path": "integ-sfn-start-execution-alias", + "children": { + "Pass": { + "id": "Pass", + "path": "integ-sfn-start-execution-alias/Pass", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions.Pass", + "version": "0.0.0" + } + }, + "Child": { + "id": "Child", + "path": "integ-sfn-start-execution-alias/Child", + "children": { + "Role": { + "id": "Role", + "path": "integ-sfn-start-execution-alias/Child/Role", + "children": { + "ImportRole": { + "id": "ImportRole", + "path": "integ-sfn-start-execution-alias/Child/Role/ImportRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-sfn-start-execution-alias/Child/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": "integ-sfn-start-execution-alias/Child/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::StepFunctions::StateMachine", + "aws:cdk:cloudformation:props": { + "definitionString": "{\"StartAt\":\"Pass\",\"States\":{\"Pass\":{\"Type\":\"Pass\",\"End\":true}}}", + "roleArn": { + "Fn::GetAtt": [ + "ChildRole1E3E0EF5", + "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" + } + }, + "MyStateMachineVersion": { + "id": "MyStateMachineVersion", + "path": "integ-sfn-start-execution-alias/MyStateMachineVersion", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::StepFunctions::StateMachineVersion", + "aws:cdk:cloudformation:props": { + "stateMachineArn": { + "Ref": "ChildDAB30558" + }, + "stateMachineRevisionId": { + "Fn::GetAtt": [ + "ChildDAB30558", + "StateMachineRevisionId" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions.CfnStateMachineVersion", + "version": "0.0.0" + } + }, + "MyStateMachineAlias": { + "id": "MyStateMachineAlias", + "path": "integ-sfn-start-execution-alias/MyStateMachineAlias", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::StepFunctions::StateMachineAlias", + "aws:cdk:cloudformation:props": { + "name": "alias", + "routingConfiguration": [ + { + "stateMachineVersionArn": { + "Fn::GetAtt": [ + "MyStateMachineVersion", + "Arn" + ] + }, + "weight": 100 + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions.CfnStateMachineAlias", + "version": "0.0.0" + } + }, + "StartExecutionTask": { + "id": "StartExecutionTask", + "path": "integ-sfn-start-execution-alias/StartExecutionTask", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions_tasks.StepFunctionsStartExecution", + "version": "0.0.0" + } + }, + "Task": { + "id": "Task", + "path": "integ-sfn-start-execution-alias/Task", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_stepfunctions_tasks.StepFunctionsStartExecution", + "version": "0.0.0" + } + }, + "Parent": { + "id": "Parent", + "path": "integ-sfn-start-execution-alias/Parent", + "children": { + "Role": { + "id": "Role", + "path": "integ-sfn-start-execution-alias/Parent/Role", + "children": { + "ImportRole": { + "id": "ImportRole", + "path": "integ-sfn-start-execution-alias/Parent/Role/ImportRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-sfn-start-execution-alias/Parent/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": "integ-sfn-start-execution-alias/Parent/Role/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-sfn-start-execution-alias/Parent/Role/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": "states:StartExecution", + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":states:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":execution:", + { + "Fn::Select": [ + 6, + { + "Fn::Split": [ + ":", + { + "Ref": "ChildDAB30558" + } + ] + } + ] + } + ] + ] + } + }, + { + "Action": [ + "states:DescribeExecution", + "states:StopExecution" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":states:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":execution:", + { + "Fn::Select": [ + 6, + { + "Fn::Split": [ + ":", + { + "Ref": "ChildDAB30558" + } + ] + } + ] + }, + "*" + ] + ] + } + }, + { + "Action": [ + "events:DescribeRule", + "events:PutRule", + "events:PutTargets" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":events:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":rule/StepFunctionsGetEventsForStepFunctionsExecutionRule" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "ParentRoleDefaultPolicy9BDC56DC", + "roles": [ + { + "Ref": "ParentRole5F0C366C" + } + ] + } + }, + "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": "integ-sfn-start-execution-alias/Parent/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::StepFunctions::StateMachine", + "aws:cdk:cloudformation:props": { + "definitionString": { + "Fn::Join": [ + "", + [ + "{\"StartAt\":\"Task\",\"States\":{\"Task\":{\"End\":true,\"Type\":\"Task\",\"Resource\":\"arn:", + { + "Ref": "AWS::Partition" + }, + ":states:::states:startExecution.sync:2\",\"Parameters\":{\"Input\":{\"hello.$\":\"$.hello\"},\"StateMachineArn\":\"", + { + "Ref": "ChildDAB30558" + }, + "\"}}}}" + ] + ] + }, + "roleArn": { + "Fn::GetAtt": [ + "ParentRole5F0C366C", + "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": "integ-sfn-start-execution-alias/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "integ-sfn-start-execution-alias/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "cdk-integ-sfn-start-execution-alias": { + "id": "cdk-integ-sfn-start-execution-alias", + "path": "cdk-integ-sfn-start-execution-alias", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "cdk-integ-sfn-start-execution-alias/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "cdk-integ-sfn-start-execution-alias/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.69" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "cdk-integ-sfn-start-execution-alias/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "cdk-integ-sfn-start-execution-alias/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "cdk-integ-sfn-start-execution-alias/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.2.69" + } + } + }, + "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/stepfunctions/integ.start-execution-alias.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.ts new file mode 100644 index 0000000000000..a02ad3aee9bfd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution-alias.ts @@ -0,0 +1,51 @@ +import * as sfn from 'aws-cdk-lib/aws-stepfunctions'; +import * as cdk from 'aws-cdk-lib'; +import { StepFunctionsStartExecution } from 'aws-cdk-lib/aws-stepfunctions-tasks'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; + +const app = new cdk.App(); +const stack = new cdk.Stack(app, 'integ-sfn-start-execution-alias'); + +const child = new sfn.StateMachine(stack, 'Child', { + definition: new sfn.Pass(stack, 'Pass'), +}); + +const stateMachineVersion = new sfn.CfnStateMachineVersion(stack, 'MyStateMachineVersion', { + stateMachineRevisionId: child.stateMachineRevisionId, + stateMachineArn: child.stateMachineArn, +}); + +const stateMachineAlias = new sfn.CfnStateMachineAlias(stack, 'MyStateMachineAlias', { + name: 'alias', + routingConfiguration: [ + { + stateMachineVersionArn: stateMachineVersion.attrArn, + weight: 100, + }, + ], +}); + +new StepFunctionsStartExecution(stack, 'StartExecutionTask', { + stateMachine: child, + stateMachineArn: stateMachineAlias.attrArn, + input: sfn.TaskInput.fromObject({ + foo: 'bar', + }), + name: 'myExecutionTask', +}); + +new sfn.StateMachine(stack, 'Parent', { + definition: new StepFunctionsStartExecution(stack, 'Task', { + stateMachine: child, + input: sfn.TaskInput.fromObject({ + hello: sfn.JsonPath.stringAt('$.hello'), + }), + integrationPattern: sfn.IntegrationPattern.RUN_JOB, + }), +}); + +new IntegTest(app, 'cdk-integ-sfn-start-execution-alias', { + testCases: [stack], +}); + +app.synth(); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution.js.snapshot/integ-sfn-start-execution.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution.js.snapshot/integ-sfn-start-execution.template.json index ee059b66a05da..547767f9094b6 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution.js.snapshot/integ-sfn-start-execution.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/stepfunctions/integ.start-execution.js.snapshot/integ-sfn-start-execution.template.json @@ -60,7 +60,37 @@ "Action": "states:StartExecution", "Effect": "Allow", "Resource": { - "Ref": "ChildDAB30558" + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":states:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":execution:", + { + "Fn::Select": [ + 6, + { + "Fn::Split": [ + ":", + { + "Ref": "ChildDAB30558" + } + ] + } + ] + } + ] + ] } }, { diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md index 7cff3c209fb2f..ba3566a89ffe1 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/README.md @@ -1234,6 +1234,35 @@ This will add the payload `AWS_STEP_FUNCTIONS_STARTED_BY_EXECUTION_ID.$: $$.Exec `input`property for you, which will pass the execution ID from the context object to the execution input. It requires `input` to be an object or not be set at all. +You can specify the ARN of a [state machine alias or version](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-cd-aliasing-versioning.html) +using the `stateMachineArn` property. This allows to start the execution of a specific state machine alias or version. + +```ts +const child = new sfn.StateMachine(this, 'ChildStateMachine', { + definition: sfn.Chain.start(new sfn.Pass(this, 'PassState')), +}); + +const stateMachineVersion = new sfn.CfnStateMachineVersion(this, 'MyStateMachineVersion', { + stateMachineRevisionId: child.stateMachineRevisionId, + stateMachineArn: child.stateMachineArn, +}); + +const stateMachineAlias = new sfn.CfnStateMachineAlias(this, 'MyStateMachineAlias', { + name: 'alias', + routingConfiguration: [ + { + stateMachineVersionArn: stateMachineVersion.attrArn, + weight: 100, + }, + ], +}); + +const task = new tasks.StepFunctionsStartExecution(this, 'ChildTask', { + stateMachine: child, + stateMachineArn: stateMachineAlias.attrArn, +}); +``` + ### Invoke Activity You can invoke a [Step Functions Activity](https://docs.aws.amazon.com/step-functions/latest/dg/concepts-activities.html) which enables you to have diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/stepfunctions/start-execution.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/stepfunctions/start-execution.ts index 76735e06e5913..9e3f1f66643f3 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/stepfunctions/start-execution.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/stepfunctions/start-execution.ts @@ -42,6 +42,15 @@ export interface StepFunctionsStartExecutionProps extends sfn.TaskStateBaseProps * @default - false */ readonly associateWithParent?: boolean; + + /** + * The Step Functions state machine ARN to start the execution on. + * This allows you to specify a state machine version or alias ARN. + * If specified, it overrides the ARN of the stateMachine. + * + * @default - The ARN of StepFunctionsStartExecutionProps.stateMachine is used + */ + readonly stateMachineArn?: string; } /** @@ -60,10 +69,13 @@ export class StepFunctionsStartExecution extends sfn.TaskStateBase { protected readonly taskPolicies?: iam.PolicyStatement[]; private readonly integrationPattern: sfn.IntegrationPattern; + private readonly stateMachineArn: string; constructor(scope: Construct, id: string, private readonly props: StepFunctionsStartExecutionProps) { super(scope, id, props); + this.stateMachineArn = props.stateMachineArn ?? props.stateMachine.stateMachineArn; + this.integrationPattern = props.integrationPattern || sfn.IntegrationPattern.REQUEST_RESPONSE; validatePatternSupported(this.integrationPattern, StepFunctionsStartExecution.SUPPORTED_INTEGRATION_PATTERNS); @@ -100,7 +112,7 @@ export class StepFunctionsStartExecution extends sfn.TaskStateBase { Resource: `${integrationResourceArn('states', 'startExecution', this.integrationPattern)}${suffix}`, Parameters: sfn.FieldUtils.renderObject({ Input: input, - StateMachineArn: this.props.stateMachine.stateMachineArn, + StateMachineArn: this.stateMachineArn, Name: this.props.name, }), }; @@ -116,10 +128,19 @@ export class StepFunctionsStartExecution extends sfn.TaskStateBase { private createScopedAccessPolicy(): iam.PolicyStatement[] { const stack = Stack.of(this); + const resourceName = stack.splitArn(this.stateMachineArn, ArnFormat.COLON_RESOURCE_NAME).resourceName; + const policyStatements = [ new iam.PolicyStatement({ actions: ['states:StartExecution'], - resources: [this.props.stateMachine.stateMachineArn], + resources: [ + stack.formatArn({ + service: 'states', + resource: 'execution', + arnFormat: ArnFormat.COLON_RESOURCE_NAME, + resourceName, + }), + ], }), ]; @@ -134,7 +155,7 @@ export class StepFunctionsStartExecution extends sfn.TaskStateBase { service: 'states', resource: 'execution', arnFormat: ArnFormat.COLON_RESOURCE_NAME, - resourceName: `${stack.splitArn(this.props.stateMachine.stateMachineArn, ArnFormat.COLON_RESOURCE_NAME).resourceName}*`, + resourceName: `${resourceName}*`, }), ], }), diff --git a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/stepfunctions/start-execution.test.ts b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/stepfunctions/start-execution.test.ts index 67bdf340d9af4..dbe3147be39db 100644 --- a/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/stepfunctions/start-execution.test.ts +++ b/packages/aws-cdk-lib/aws-stepfunctions-tasks/test/stepfunctions/start-execution.test.ts @@ -92,7 +92,37 @@ test('Execute State Machine - Run Job', () => { Action: 'states:StartExecution', Effect: 'Allow', Resource: { - Ref: 'ChildStateMachine9133117F', + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':states:', + { + Ref: 'AWS::Region', + }, + ':', + { + Ref: 'AWS::AccountId', + }, + ':execution:', + { + 'Fn::Select': [ + 6, + { + 'Fn::Split': [ + ':', + { + Ref: 'ChildStateMachine9133117F', + }, + ], + }, + ], + }, + ], + ], }, }, { @@ -266,4 +296,208 @@ test('Execute State Machine - Associate With Parent - Incorrect Input Type', () input: sfn.TaskInput.fromText('{ "token.$": "$$.Task.Token" }'), }); }).toThrow('Could not enable `associateWithParent` because `input` is taken directly from a JSON path. Use `sfn.TaskInput.fromObject` instead.'); -}); \ No newline at end of file +}); + +test('Execute State Machine - Uses a specific state machine version', () => { + const stateMachineVersion = new sfn.CfnStateMachineVersion(stack, 'MyStateMachineVersion', { + stateMachineRevisionId: child.stateMachineRevisionId, + stateMachineArn: child.stateMachineArn, + }); + + const task = new StepFunctionsStartExecution(stack, 'MyExecutionVersion', { + stateMachine: child, + stateMachineArn: stateMachineVersion.attrArn, + input: sfn.TaskInput.fromObject({ + foo: 'bar', + }), + name: 'myExecutionVersion', + }); + + new sfn.StateMachine(stack, 'ParentStateMachine', { + definitionBody: sfn.DefinitionBody.fromChainable(task), + }); + + expect(stack.resolve(task.toStateJson())).toEqual({ + Type: 'Task', + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':states:::states:startExecution', + ], + ], + }, + End: true, + Parameters: { + Input: { + foo: 'bar', + }, + Name: 'myExecutionVersion', + StateMachineArn: { + 'Fn::GetAtt': [ + 'MyStateMachineVersion', + 'Arn', + ], + }, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { + PolicyDocument: { + Statement: [ + { + Action: 'states:StartExecution', + Effect: 'Allow', + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':states:', + { + Ref: 'AWS::Region', + }, + ':', + { + Ref: 'AWS::AccountId', + }, + ':execution:', + { + 'Fn::Select': [ + 6, + { + 'Fn::Split': [ + ':', + { + 'Fn::GetAtt': [ + 'MyStateMachineVersion', + 'Arn', + ], + }, + ], + }, + ], + }, + ], + ], + }, + }, + ], + }, + }); +}); + +test('Execute State Machine - Uses a specific state machine alias', () => { + const stateMachineAlias = new sfn.CfnStateMachineAlias(stack, 'MyStateMachineAlias', { + name: 'alias', + }); + + const task = new StepFunctionsStartExecution(stack, 'MyExecutionAlias', { + stateMachine: child, + stateMachineArn: stateMachineAlias.attrArn, + input: sfn.TaskInput.fromObject({ + foo: 'bar', + }), + name: 'myExecutionAlias', + }); + + new sfn.StateMachine(stack, 'ParentStateMachine', { + definitionBody: sfn.DefinitionBody.fromChainable(task), + }); + + expect(stack.resolve(task.toStateJson())).toEqual({ + Type: 'Task', + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':states:::states:startExecution', + ], + ], + }, + End: true, + Parameters: { + Input: { + foo: 'bar', + }, + Name: 'myExecutionAlias', + StateMachineArn: { + 'Fn::GetAtt': [ + 'MyStateMachineAlias', + 'Arn', + ], + }, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::IAM::Policy', { + PolicyDocument: { + Statement: [ + { + Action: 'states:StartExecution', + Effect: 'Allow', + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':states:', + { + Ref: 'AWS::Region', + }, + ':', + { + Ref: 'AWS::AccountId', + }, + ':execution:', + { + 'Fn::Select': [ + 6, + { + 'Fn::Split': [ + ':', + { + 'Fn::GetAtt': [ + 'MyStateMachineAlias', + 'Arn', + ], + }, + ], + }, + ], + }, + ], + ], + }, + }, + ], + }, + }); +}); + +test('Execute State Machine - stateMachineArn should be a valid ARN', () => { + expect(() => { + new StepFunctionsStartExecution(stack, 'MyExecutionAlias', { + stateMachine: child, + stateMachineArn: 'invalid ARN', + input: sfn.TaskInput.fromObject({ + foo: 'bar', + }), + name: 'myExecutionAlias', + }); + }).toThrow(/ARNs must start with "arn:" and have at least 6 components/); +});