From 62ceaeee4aad61385e570bf1071d2501b62aabb6 Mon Sep 17 00:00:00 2001 From: Ayush Goyal Date: Thu, 14 Jan 2021 15:52:26 +0530 Subject: [PATCH 1/3] feat(stepfunctions-tasks): EcsRunTask now uses taskDefinition family instead of ARN --- .../aws-stepfunctions-tasks/README.md | 17 +++- .../lib/ecs/run-task.ts | 19 +++- .../test/ecs/integ.ec2-run-task.expected.json | 96 ++++++++++++++++--- .../ecs/integ.fargate-run-task.expected.json | 80 ++++++++++++++-- .../test/ecs/run-tasks.test.ts | 48 ++++++++-- 5 files changed, 229 insertions(+), 31 deletions(-) diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/README.md b/packages/@aws-cdk/aws-stepfunctions-tasks/README.md index 32044b4a23649..c6d03447bf7fd 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/README.md +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/README.md @@ -435,6 +435,8 @@ CPU and memory. Similarly, when you scale down the task count, Amazon ECS must d which tasks to terminate. You can apply task placement strategies and constraints to customize how Amazon ECS places and terminates tasks. Learn more about [task placement](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement.html) +The latest ACTIVE revision of the passed task definition is used for running the task. + The following example runs a job from a task definition on EC2 ```ts @@ -488,7 +490,8 @@ isolation by design. Learn more about [Fargate](https://aws.amazon.com/fargate/) The Fargate launch type allows you to run your containerized applications without the need to provision and manage the backend infrastructure. Just register your task definition and -Fargate launches the container for you. +Fargate launches the container for you. The latest ACTIVE revision of the passed +task definition is used for running the task. The following example runs a job from a task definition on Fargate @@ -527,6 +530,18 @@ const runTask = new tasks.EcsRunTask(stack, 'RunFargate', { }); ``` +You can set the `useTaskDefinitionFamily` prop to true if you want the task to be run using latest ACTIVE revision +of the task definition family. By default the task is ran using the + +```ts +const runTask = new tasks.EcsRunTask(stack, 'RunFargate', { + ... + taskDefinition, + useTaskDefinitionFamily: true, + ... +}); +``` + ## EMR Step Functions supports Amazon EMR through the service integration pattern. diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/ecs/run-task.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/ecs/run-task.ts index f80252cbb05f8..5cdf5253b7d95 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/ecs/run-task.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/ecs/run-task.ts @@ -279,7 +279,7 @@ export class EcsRunTask extends sfn.TaskStateBase implements ec2.IConnectable { Resource: integrationResourceArn('ecs', 'runTask', this.integrationPattern), Parameters: sfn.FieldUtils.renderObject({ Cluster: this.props.cluster.clusterArn, - TaskDefinition: this.props.taskDefinition.taskDefinitionArn, + TaskDefinition: this.props.taskDefinition.family, NetworkConfiguration: this.networkConfiguration, Overrides: renderOverrides(this.props.containerOverrides), ...this.props.launchTarget.bind(this, { taskDefinition: this.props.taskDefinition, cluster: this.props.cluster }).parameters, @@ -318,7 +318,7 @@ export class EcsRunTask extends sfn.TaskStateBase implements ec2.IConnectable { const policyStatements = [ new iam.PolicyStatement({ actions: ['ecs:RunTask'], - resources: [this.props.taskDefinition.taskDefinitionArn], + resources: [this.getTaskDefinitionFamilyArn()], }), new iam.PolicyStatement({ actions: ['ecs:StopTask', 'ecs:DescribeTasks'], @@ -348,6 +348,21 @@ export class EcsRunTask extends sfn.TaskStateBase implements ec2.IConnectable { return policyStatements; } + private getTaskDefinitionFamilyArn(): string { + let { resource, service, sep, resourceName } = cdk.Stack.of(this).parseArn(this.props.taskDefinition.taskDefinitionArn); + + if (resourceName) { + resourceName = resourceName.split(':')[0]; + } + + return cdk.Stack.of(this).formatArn({ + resource, + service, + sep, + resourceName, + }); + } + private taskExecutionRoles(): iam.IRole[] { // Need to be able to pass both Task and Execution role, apparently const ret = new Array(); diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-run-task.expected.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-run-task.expected.json index f9694026e0630..85302b0cb559c 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-run-task.expected.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-run-task.expected.json @@ -80,8 +80,6 @@ "ecs:Poll", "ecs:StartTelemetrySession" ], - "Effect": "Allow", - "Resource": "*", "Condition": { "ArnEquals": { "ecs:cluster": { @@ -91,7 +89,9 @@ ] } } - } + }, + "Effect": "Allow", + "Resource": "*" }, { "Action": [ @@ -268,8 +268,6 @@ "ecs:DescribeContainerInstances", "ecs:DescribeTasks" ], - "Effect": "Allow", - "Resource": "*", "Condition": { "ArnEquals": { "ecs:cluster": { @@ -279,7 +277,9 @@ ] } } - } + }, + "Effect": "Allow", + "Resource": "*" }, { "Action": [ @@ -330,14 +330,12 @@ "Code": { "ZipFile": "import boto3, json, os, time\n\necs = boto3.client('ecs')\nautoscaling = boto3.client('autoscaling')\n\n\ndef lambda_handler(event, context):\n print(json.dumps(event))\n cluster = os.environ['CLUSTER']\n snsTopicArn = event['Records'][0]['Sns']['TopicArn']\n lifecycle_event = json.loads(event['Records'][0]['Sns']['Message'])\n instance_id = lifecycle_event.get('EC2InstanceId')\n if not instance_id:\n print('Got event without EC2InstanceId: %s', json.dumps(event))\n return\n\n instance_arn = container_instance_arn(cluster, instance_id)\n print('Instance %s has container instance ARN %s' % (lifecycle_event['EC2InstanceId'], instance_arn))\n\n if not instance_arn:\n return\n\n while has_tasks(cluster, instance_arn):\n time.sleep(10)\n\n try:\n print('Terminating instance %s' % instance_id)\n autoscaling.complete_lifecycle_action(\n LifecycleActionResult='CONTINUE',\n **pick(lifecycle_event, 'LifecycleHookName', 'LifecycleActionToken', 'AutoScalingGroupName'))\n except Exception as e:\n # Lifecycle action may have already completed.\n print(str(e))\n\n\ndef container_instance_arn(cluster, instance_id):\n \"\"\"Turn an instance ID into a container instance ARN.\"\"\"\n arns = ecs.list_container_instances(cluster=cluster, filter='ec2InstanceId==' + instance_id)['containerInstanceArns']\n if not arns:\n return None\n return arns[0]\n\n\ndef has_tasks(cluster, instance_arn):\n \"\"\"Return True if the instance is running tasks for the given cluster.\"\"\"\n instances = ecs.describe_container_instances(cluster=cluster, containerInstances=[instance_arn])['containerInstances']\n if not instances:\n return False\n instance = instances[0]\n\n if instance['status'] == 'ACTIVE':\n # Start draining, then try again later\n set_container_instance_to_draining(cluster, instance_arn)\n return True\n\n tasks = instance['runningTasksCount'] + instance['pendingTasksCount']\n print('Instance %s has %s tasks' % (instance_arn, tasks))\n\n return tasks > 0\n\n\ndef set_container_instance_to_draining(cluster, instance_arn):\n ecs.update_container_instances_state(\n cluster=cluster,\n containerInstances=[instance_arn], status='DRAINING')\n\n\ndef pick(dct, *keys):\n \"\"\"Pick a subset of a dict.\"\"\"\n return {k: v for k, v in dct.items() if k in keys}\n" }, - "Handler": "index.lambda_handler", "Role": { "Fn::GetAtt": [ "Ec2ClusterDefaultAutoScalingGroupDrainECSHookFunctionServiceRole23116FA3", "Arn" ] }, - "Runtime": "python3.6", "Environment": { "Variables": { "CLUSTER": { @@ -345,6 +343,8 @@ } } }, + "Handler": "index.lambda_handler", + "Runtime": "python3.6", "Tags": [ { "Key": "Name", @@ -640,7 +640,77 @@ "Action": "ecs:RunTask", "Effect": "Allow", "Resource": { - "Ref": "TaskDef54694570" + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":", + { + "Fn::Select": [ + 2, + { + "Fn::Split": [ + ":", + { + "Ref": "TaskDef54694570" + } + ] + } + ] + }, + ":test-region:12345678:", + { + "Fn::Select": [ + 0, + { + "Fn::Split": [ + "/", + { + "Fn::Select": [ + 5, + { + "Fn::Split": [ + ":", + { + "Ref": "TaskDef54694570" + } + ] + } + ] + } + ] + } + ] + }, + "/", + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "/", + { + "Fn::Select": [ + 5, + { + "Fn::Split": [ + ":", + { + "Ref": "TaskDef54694570" + } + ] + } + ] + } + ] + } + ] + } + ] + ] } }, { @@ -724,11 +794,7 @@ "Arn" ] }, - "\",\"TaskDefinition\":\"", - { - "Ref": "TaskDef54694570" - }, - "\",\"Overrides\":{\"ContainerOverrides\":[{\"Name\":\"TheContainer\",\"Environment\":[{\"Name\":\"SOME_KEY\",\"Value.$\":\"$.SomeKey\"}]}]},\"LaunchType\":\"EC2\"}}}}" + "\",\"TaskDefinition\":\"awssfntasksecsec2integTaskDefFAFE2BE7\",\"Overrides\":{\"ContainerOverrides\":[{\"Name\":\"TheContainer\",\"Environment\":[{\"Name\":\"SOME_KEY\",\"Value.$\":\"$.SomeKey\"}]}]},\"LaunchType\":\"EC2\"}}}}" ] ] } @@ -752,4 +818,4 @@ } } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.fargate-run-task.expected.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.fargate-run-task.expected.json index 080638d46ddcb..07d117e426068 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.fargate-run-task.expected.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.fargate-run-task.expected.json @@ -189,7 +189,77 @@ "Action": "ecs:RunTask", "Effect": "Allow", "Resource": { - "Ref": "TaskDef54694570" + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":", + { + "Fn::Select": [ + 2, + { + "Fn::Split": [ + ":", + { + "Ref": "TaskDef54694570" + } + ] + } + ] + }, + ":test-region:12345678:", + { + "Fn::Select": [ + 0, + { + "Fn::Split": [ + "/", + { + "Fn::Select": [ + 5, + { + "Fn::Split": [ + ":", + { + "Ref": "TaskDef54694570" + } + ] + } + ] + } + ] + } + ] + }, + "/", + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "/", + { + "Fn::Select": [ + 5, + { + "Fn::Split": [ + ":", + { + "Ref": "TaskDef54694570" + } + ] + } + ] + } + ] + } + ] + } + ] + ] } }, { @@ -273,11 +343,7 @@ "Arn" ] }, - "\",\"TaskDefinition\":\"", - { - "Ref": "TaskDef54694570" - }, - "\",\"NetworkConfiguration\":{\"AwsvpcConfiguration\":{\"AssignPublicIp\":\"ENABLED\",\"Subnets\":[\"subnet-e19455ca\",\"subnet-e0c24797\",\"subnet-ccd77395\"],\"SecurityGroups\":[\"", + "\",\"TaskDefinition\":\"awssfntasksecsfargateintegTaskDefD0F4AD10\",\"NetworkConfiguration\":{\"AwsvpcConfiguration\":{\"AssignPublicIp\":\"ENABLED\",\"Subnets\":[\"subnet-e19455ca\",\"subnet-e0c24797\",\"subnet-ccd77395\"],\"SecurityGroups\":[\"", { "Fn::GetAtt": [ "FargateTaskSecurityGroup0BBB27CB", @@ -302,4 +368,4 @@ } } } -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/run-tasks.test.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/run-tasks.test.ts index a60a993967bee..48168165bef22 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/run-tasks.test.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/run-tasks.test.ts @@ -92,7 +92,7 @@ test('Running a Fargate Task', () => { }, }, PlatformVersion: '1.4.0', - TaskDefinition: { Ref: 'TD49C78F36' }, + TaskDefinition: 'TD', Overrides: { ContainerOverrides: [ { @@ -128,7 +128,25 @@ test('Running a Fargate Task', () => { { Action: 'ecs:RunTask', Effect: 'Allow', - Resource: { Ref: 'TD49C78F36' }, + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { 'Ref': 'AWS::Partition' }, + ':', + { 'Fn::Select': [2, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }, + ':', + { 'Ref': 'AWS::Region' }, + ':', + { 'Ref': 'AWS::AccountId' }, + ':', + { 'Fn::Select': [0, { 'Fn::Split': ['/', { 'Fn::Select': [5, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }] }] }, + '/', + { 'Fn::Select': [1, { 'Fn::Split': ['/', { 'Fn::Select': [5, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }] }] }, + ], + ], + }, }, { Action: ['ecs:StopTask', 'ecs:DescribeTasks'], @@ -196,7 +214,7 @@ test('Running an EC2 Task with bridge network', () => { Parameters: { Cluster: { 'Fn::GetAtt': ['ClusterEB0386A7', 'Arn'] }, LaunchType: 'EC2', - TaskDefinition: { Ref: 'TD49C78F36' }, + TaskDefinition: 'TD', Overrides: { ContainerOverrides: [ { @@ -232,7 +250,25 @@ test('Running an EC2 Task with bridge network', () => { { Action: 'ecs:RunTask', Effect: 'Allow', - Resource: { Ref: 'TD49C78F36' }, + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { 'Ref': 'AWS::Partition' }, + ':', + { 'Fn::Select': [2, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }, + ':', + { 'Ref': 'AWS::Region' }, + ':', + { 'Ref': 'AWS::AccountId' }, + ':', + { 'Fn::Select': [0, { 'Fn::Split': ['/', { 'Fn::Select': [5, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }] }] }, + '/', + { 'Fn::Select': [1, { 'Fn::Split': ['/', { 'Fn::Select': [5, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }] }] }, + ], + ], + }, }, { Action: ['ecs:StopTask', 'ecs:DescribeTasks'], @@ -297,7 +333,7 @@ test('Running an EC2 Task with placement strategies', () => { Parameters: { Cluster: { 'Fn::GetAtt': ['ClusterEB0386A7', 'Arn'] }, LaunchType: 'EC2', - TaskDefinition: { Ref: 'TD49C78F36' }, + TaskDefinition: 'TD', PlacementConstraints: [{ Type: 'memberOf', Expression: 'blieptuut' }], PlacementStrategy: [{ Field: 'instanceId', Type: 'spread' }, { Field: 'cpu', Type: 'binpack' }, { Type: 'random' }], }, @@ -348,7 +384,7 @@ test('Running an EC2 Task with overridden number values', () => { Parameters: { Cluster: { 'Fn::GetAtt': ['ClusterEB0386A7', 'Arn'] }, LaunchType: 'EC2', - TaskDefinition: { Ref: 'TD49C78F36' }, + TaskDefinition: 'TD', Overrides: { ContainerOverrides: [ { From e1ab8a956f7652a267fab38f21823556917623bf Mon Sep 17 00:00:00 2001 From: Ayush Goyal Date: Thu, 14 Jan 2021 15:55:25 +0530 Subject: [PATCH 2/3] udpate readme --- packages/@aws-cdk/aws-stepfunctions-tasks/README.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/README.md b/packages/@aws-cdk/aws-stepfunctions-tasks/README.md index c6d03447bf7fd..27affcbcf7c34 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/README.md +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/README.md @@ -530,18 +530,6 @@ const runTask = new tasks.EcsRunTask(stack, 'RunFargate', { }); ``` -You can set the `useTaskDefinitionFamily` prop to true if you want the task to be run using latest ACTIVE revision -of the task definition family. By default the task is ran using the - -```ts -const runTask = new tasks.EcsRunTask(stack, 'RunFargate', { - ... - taskDefinition, - useTaskDefinitionFamily: true, - ... -}); -``` - ## EMR Step Functions supports Amazon EMR through the service integration pattern. From a083fca45ae1160a676510076c0190c14d901e0e Mon Sep 17 00:00:00 2001 From: Ayush Goyal Date: Fri, 22 Jan 2021 08:28:57 +0530 Subject: [PATCH 3/3] update arn comps and doc --- .../aws-stepfunctions-tasks/README.md | 3 +- .../lib/ecs/run-task.ts | 16 +++---- .../test/ecs/integ.ec2-run-task.expected.json | 42 ++++++++++++++++++- .../ecs/integ.fargate-run-task.expected.json | 42 ++++++++++++++++++- .../test/ecs/run-tasks.test.ts | 12 +++--- 5 files changed, 97 insertions(+), 18 deletions(-) diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/README.md b/packages/@aws-cdk/aws-stepfunctions-tasks/README.md index 6266148258536..bcb8ca3e3cc68 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/README.md +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/README.md @@ -491,7 +491,8 @@ isolation by design. Learn more about [Fargate](https://aws.amazon.com/fargate/) The Fargate launch type allows you to run your containerized applications without the need to provision and manage the backend infrastructure. Just register your task definition and Fargate launches the container for you. The latest ACTIVE revision of the passed -task definition is used for running the task. +task definition is used for running the task. Learn more about +[Fargate Versioning](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_DescribeTaskDefinition.html) The following example runs a job from a task definition on Fargate diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/ecs/run-task.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/ecs/run-task.ts index 5cdf5253b7d95..60f0ede44be83 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/lib/ecs/run-task.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/lib/ecs/run-task.ts @@ -348,19 +348,21 @@ export class EcsRunTask extends sfn.TaskStateBase implements ec2.IConnectable { return policyStatements; } + /** + * Returns the ARN of the task definition family by removing the + * revision from the task definition ARN + * Before - arn:aws:ecs:us-west-2:123456789012:task-definition/hello_world:8 + * After - arn:aws:ecs:us-west-2:123456789012:task-definition/hello_world + */ private getTaskDefinitionFamilyArn(): string { - let { resource, service, sep, resourceName } = cdk.Stack.of(this).parseArn(this.props.taskDefinition.taskDefinitionArn); + const arnComponents = cdk.Stack.of(this).parseArn(this.props.taskDefinition.taskDefinitionArn); + let { resourceName } = arnComponents; if (resourceName) { resourceName = resourceName.split(':')[0]; } - return cdk.Stack.of(this).formatArn({ - resource, - service, - sep, - resourceName, - }); + return cdk.Stack.of(this).formatArn({ ...arnComponents, resourceName }); } private taskExecutionRoles(): iam.IRole[] { diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-run-task.expected.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-run-task.expected.json index 85302b0cb559c..97a2e05741145 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-run-task.expected.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.ec2-run-task.expected.json @@ -645,7 +645,17 @@ [ "arn:", { - "Ref": "AWS::Partition" + "Fn::Select": [ + 1, + { + "Fn::Split": [ + ":", + { + "Ref": "TaskDef54694570" + } + ] + } + ] }, ":", { @@ -661,7 +671,35 @@ } ] }, - ":test-region:12345678:", + ":", + { + "Fn::Select": [ + 3, + { + "Fn::Split": [ + ":", + { + "Ref": "TaskDef54694570" + } + ] + } + ] + }, + ":", + { + "Fn::Select": [ + 4, + { + "Fn::Split": [ + ":", + { + "Ref": "TaskDef54694570" + } + ] + } + ] + }, + ":", { "Fn::Select": [ 0, diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.fargate-run-task.expected.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.fargate-run-task.expected.json index 07d117e426068..a2d79417c61df 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.fargate-run-task.expected.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/integ.fargate-run-task.expected.json @@ -194,7 +194,17 @@ [ "arn:", { - "Ref": "AWS::Partition" + "Fn::Select": [ + 1, + { + "Fn::Split": [ + ":", + { + "Ref": "TaskDef54694570" + } + ] + } + ] }, ":", { @@ -210,7 +220,35 @@ } ] }, - ":test-region:12345678:", + ":", + { + "Fn::Select": [ + 3, + { + "Fn::Split": [ + ":", + { + "Ref": "TaskDef54694570" + } + ] + } + ] + }, + ":", + { + "Fn::Select": [ + 4, + { + "Fn::Split": [ + ":", + { + "Ref": "TaskDef54694570" + } + ] + } + ] + }, + ":", { "Fn::Select": [ 0, diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/run-tasks.test.ts b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/run-tasks.test.ts index 48168165bef22..ff2072b6b2ebf 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/run-tasks.test.ts +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/ecs/run-tasks.test.ts @@ -133,13 +133,13 @@ test('Running a Fargate Task', () => { '', [ 'arn:', - { 'Ref': 'AWS::Partition' }, + { 'Fn::Select': [1, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }, ':', { 'Fn::Select': [2, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }, ':', - { 'Ref': 'AWS::Region' }, + { 'Fn::Select': [3, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }, ':', - { 'Ref': 'AWS::AccountId' }, + { 'Fn::Select': [4, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }, ':', { 'Fn::Select': [0, { 'Fn::Split': ['/', { 'Fn::Select': [5, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }] }] }, '/', @@ -255,13 +255,13 @@ test('Running an EC2 Task with bridge network', () => { '', [ 'arn:', - { 'Ref': 'AWS::Partition' }, + { 'Fn::Select': [1, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }, ':', { 'Fn::Select': [2, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }, ':', - { 'Ref': 'AWS::Region' }, + { 'Fn::Select': [3, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }, ':', - { 'Ref': 'AWS::AccountId' }, + { 'Fn::Select': [4, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }, ':', { 'Fn::Select': [0, { 'Fn::Split': ['/', { 'Fn::Select': [5, { 'Fn::Split': [':', { 'Ref': 'TD49C78F36' }] }] }] }] }, '/',