From 2268a3aea83d5cb9f8d0ef207e4c228a1c013420 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Fri, 1 Dec 2023 00:54:01 +0900 Subject: [PATCH 01/13] fix(aws-ecs-patterns): Specified taskDefinition was not utilized in queueProcessingFargateService --- .../queue-processing-fargate-service.ts | 42 +- .../queue-processing-fargate-service.test.ts | 373 ++++++++++-------- 2 files changed, 247 insertions(+), 168 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts index 5d3ba07353b7c..25d93eb784a41 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts @@ -1,16 +1,24 @@ import { Construct } from 'constructs'; import * as ec2 from '../../../aws-ec2'; -import { FargateService, FargateTaskDefinition, HealthCheck } from '../../../aws-ecs'; +import { + FargateService, + FargateTaskDefinition, + HealthCheck, +} from '../../../aws-ecs'; import { FeatureFlags } from '../../../core'; import * as cxapi from '../../../cx-api'; import { FargateServiceBaseProps } from '../base/fargate-service-base'; -import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../base/queue-processing-service-base'; +import { + QueueProcessingServiceBase, + QueueProcessingServiceBaseProps, +} from '../base/queue-processing-service-base'; /** * The properties for the QueueProcessingFargateService service. */ -export interface QueueProcessingFargateServiceProps extends QueueProcessingServiceBaseProps, FargateServiceBaseProps { - +export interface QueueProcessingFargateServiceProps + extends QueueProcessingServiceBaseProps, + FargateServiceBaseProps { /** * Optional name for the container added * @@ -65,16 +73,22 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase { /** * Constructs a new instance of the QueueProcessingFargateService class. */ - constructor(scope: Construct, id: string, props: QueueProcessingFargateServiceProps) { + constructor( + scope: Construct, + id: string, + props: QueueProcessingFargateServiceProps, + ) { super(scope, id, props); // Create a Task Definition for the container to start - this.taskDefinition = new FargateTaskDefinition(this, 'QueueProcessingTaskDef', { - memoryLimitMiB: props.memoryLimitMiB || 512, - cpu: props.cpu || 256, - family: props.family, - runtimePlatform: props.runtimePlatform, - }); + this.taskDefinition = + props.taskDefinition ?? + new FargateTaskDefinition(this, 'QueueProcessingTaskDef', { + memoryLimitMiB: props.memoryLimitMiB || 512, + cpu: props.cpu || 256, + family: props.family, + runtimePlatform: props.runtimePlatform, + }); const containerName = props.containerName ?? 'QueueProcessingContainer'; @@ -88,7 +102,11 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase { }); // The desiredCount should be removed from the fargate service when the feature flag is removed. - const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? undefined : this.desiredCount; + const desiredCount = FeatureFlags.of(this).isEnabled( + cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, + ) + ? undefined + : this.desiredCount; // Create a Fargate service with the previously defined Task Definition and configure // autoscaling based on cpu utilization and number of messages visible in the SQS queue. diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts index 05a4755e5bbdc..d4c3b1b8cfe0e 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts @@ -15,13 +15,15 @@ test('test fargate queue worker service construct - with only required props', ( const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'VPC'); const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); - cluster.addAsgCapacityProvider(new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { - autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { - vpc, - instanceType: new ec2.InstanceType('t2.micro'), - machineImage: MachineImage.latestAmazonLinux(), + cluster.addAsgCapacityProvider( + new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { + autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { + vpc, + instanceType: new ec2.InstanceType('t2.micro'), + machineImage: MachineImage.latestAmazonLinux(), + }), }), - })); + ); // WHEN new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { @@ -38,10 +40,7 @@ test('test fargate queue worker service construct - with only required props', ( Template.fromStack(stack).hasResourceProperties('AWS::SQS::Queue', { RedrivePolicy: { deadLetterTargetArn: { - 'Fn::GetAtt': [ - 'ServiceEcsProcessingDeadLetterQueue4A89196E', - 'Arn', - ], + 'Fn::GetAtt': ['ServiceEcsProcessingDeadLetterQueue4A89196E', 'Arn'], }, maxReceiveCount: 3, }, @@ -64,10 +63,7 @@ test('test fargate queue worker service construct - with only required props', ( ], Effect: 'Allow', Resource: { - 'Fn::GetAtt': [ - 'ServiceEcsProcessingQueueC266885C', - 'Arn', - ], + 'Fn::GetAtt': ['ServiceEcsProcessingQueueC266885C', 'Arn'], }, }, ], @@ -82,10 +78,7 @@ test('test fargate queue worker service construct - with only required props', ( { Name: 'QUEUE_NAME', Value: { - 'Fn::GetAtt': [ - 'ServiceEcsProcessingQueueC266885C', - 'QueueName', - ], + 'Fn::GetAtt': ['ServiceEcsProcessingQueueC266885C', 'QueueName'], }, }, ], @@ -133,13 +126,15 @@ test('test fargate queue worker service construct - with optional props for queu const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'VPC'); const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); - cluster.addAsgCapacityProvider(new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { - autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { - vpc, - instanceType: new ec2.InstanceType('t2.micro'), - machineImage: MachineImage.latestAmazonLinux(), + cluster.addAsgCapacityProvider( + new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { + autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { + vpc, + instanceType: new ec2.InstanceType('t2.micro'), + machineImage: MachineImage.latestAmazonLinux(), + }), }), - })); + ); // WHEN new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { @@ -159,10 +154,7 @@ test('test fargate queue worker service construct - with optional props for queu Template.fromStack(stack).hasResourceProperties('AWS::SQS::Queue', { RedrivePolicy: { deadLetterTargetArn: { - 'Fn::GetAtt': [ - 'ServiceEcsProcessingDeadLetterQueue4A89196E', - 'Arn', - ], + 'Fn::GetAtt': ['ServiceEcsProcessingDeadLetterQueue4A89196E', 'Arn'], }, maxReceiveCount: 42, }, @@ -186,10 +178,7 @@ test('test fargate queue worker service construct - with optional props for queu ], Effect: 'Allow', Resource: { - 'Fn::GetAtt': [ - 'ServiceEcsProcessingQueueC266885C', - 'Arn', - ], + 'Fn::GetAtt': ['ServiceEcsProcessingQueueC266885C', 'Arn'], }, }, ], @@ -204,10 +193,7 @@ test('test fargate queue worker service construct - with optional props for queu { Name: 'QUEUE_NAME', Value: { - 'Fn::GetAtt': [ - 'ServiceEcsProcessingQueueC266885C', - 'QueueName', - ], + 'Fn::GetAtt': ['ServiceEcsProcessingQueueC266885C', 'QueueName'], }, }, ], @@ -283,10 +269,7 @@ test('test Fargate queue worker service construct - with ECS Exec', () => { ], Effect: 'Allow', Resource: { - 'Fn::GetAtt': [ - 'ServiceEcsProcessingQueueC266885C', - 'Arn', - ], + 'Fn::GetAtt': ['ServiceEcsProcessingQueueC266885C', 'Arn'], }, }, ], @@ -306,13 +289,15 @@ test('test Fargate queue worker service construct - without desiredCount specifi const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'VPC'); const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); - cluster.addAsgCapacityProvider(new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { - autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { - vpc, - instanceType: new ec2.InstanceType('t2.micro'), - machineImage: MachineImage.latestAmazonLinux(), + cluster.addAsgCapacityProvider( + new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { + autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { + vpc, + instanceType: new ec2.InstanceType('t2.micro'), + machineImage: MachineImage.latestAmazonLinux(), + }), }), - })); + ); const queue = new sqs.Queue(stack, 'fargate-test-queue', { queueName: 'fargate-test-sqs-queue', }); @@ -355,21 +340,22 @@ test('test Fargate queue worker service construct - without desiredCount specifi }, }); - Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalableTarget', { - MaxCapacity: 5, - MinCapacity: 2, - }); + Template.fromStack(stack).hasResourceProperties( + 'AWS::ApplicationAutoScaling::ScalableTarget', + { + MaxCapacity: 5, + MinCapacity: 2, + }, + ); - Template.fromStack(stack).hasResourceProperties('AWS::SQS::Queue', { QueueName: 'fargate-test-sqs-queue' }); + Template.fromStack(stack).hasResourceProperties('AWS::SQS::Queue', { + QueueName: 'fargate-test-sqs-queue', + }); Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', { ContainerDefinitions: [ Match.objectLike({ - Command: [ - '-c', - '4', - 'amazon.com', - ], + Command: ['-c', '4', 'amazon.com'], Environment: [ { Name: 'TEST_ENVIRONMENT_VARIABLE1', @@ -382,10 +368,7 @@ test('test Fargate queue worker service construct - without desiredCount specifi { Name: 'QUEUE_NAME', Value: { - 'Fn::GetAtt': [ - 'fargatetestqueue28B43841', - 'QueueName', - ], + 'Fn::GetAtt': ['fargatetestqueue28B43841', 'QueueName'], }, }, ], @@ -396,109 +379,118 @@ test('test Fargate queue worker service construct - without desiredCount specifi }); }); -testDeprecated('test Fargate queue worker service construct - with optional props', () => { - // GIVEN - const stack = new cdk.Stack(); - const vpc = new ec2.Vpc(stack, 'VPC'); - const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); - cluster.addAsgCapacityProvider(new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { - autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { - vpc, - instanceType: new ec2.InstanceType('t2.micro'), - machineImage: MachineImage.latestAmazonLinux(), - }), - })); - const queue = new sqs.Queue(stack, 'fargate-test-queue', { - queueName: 'fargate-test-sqs-queue', - }); +testDeprecated( + 'test Fargate queue worker service construct - with optional props', + () => { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'VPC'); + const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); + cluster.addAsgCapacityProvider( + new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { + autoScalingGroup: new AutoScalingGroup( + stack, + 'DefaultAutoScalingGroup', + { + vpc, + instanceType: new ec2.InstanceType('t2.micro'), + machineImage: MachineImage.latestAmazonLinux(), + }, + ), + }), + ); + const queue = new sqs.Queue(stack, 'fargate-test-queue', { + queueName: 'fargate-test-sqs-queue', + }); - // WHEN - new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { - cluster, - memoryLimitMiB: 512, - image: ecs.ContainerImage.fromRegistry('test'), - command: ['-c', '4', 'amazon.com'], - enableLogging: false, - environment: { - TEST_ENVIRONMENT_VARIABLE1: 'test environment variable 1 value', - TEST_ENVIRONMENT_VARIABLE2: 'test environment variable 2 value', - }, - queue, - maxScalingCapacity: 5, - minHealthyPercent: 60, - maxHealthyPercent: 150, - serviceName: 'fargate-test-service', - family: 'fargate-task-family', - platformVersion: ecs.FargatePlatformVersion.VERSION1_4, - circuitBreaker: { rollback: true }, - }); + // WHEN + new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { + cluster, + memoryLimitMiB: 512, + image: ecs.ContainerImage.fromRegistry('test'), + command: ['-c', '4', 'amazon.com'], + enableLogging: false, + environment: { + TEST_ENVIRONMENT_VARIABLE1: 'test environment variable 1 value', + TEST_ENVIRONMENT_VARIABLE2: 'test environment variable 2 value', + }, + queue, + maxScalingCapacity: 5, + minHealthyPercent: 60, + maxHealthyPercent: 150, + serviceName: 'fargate-test-service', + family: 'fargate-task-family', + platformVersion: ecs.FargatePlatformVersion.VERSION1_4, + circuitBreaker: { rollback: true }, + }); - // THEN - QueueWorker is of FARGATE launch type, an SQS queue is created and all optional properties are set. - Template.fromStack(stack).hasResourceProperties('AWS::ECS::Service', { - DeploymentConfiguration: { - MinimumHealthyPercent: 60, - MaximumPercent: 150, - DeploymentCircuitBreaker: { - Enable: true, - Rollback: true, + // THEN - QueueWorker is of FARGATE launch type, an SQS queue is created and all optional properties are set. + Template.fromStack(stack).hasResourceProperties('AWS::ECS::Service', { + DeploymentConfiguration: { + MinimumHealthyPercent: 60, + MaximumPercent: 150, + DeploymentCircuitBreaker: { + Enable: true, + Rollback: true, + }, }, - }, - LaunchType: 'FARGATE', - ServiceName: 'fargate-test-service', - PlatformVersion: ecs.FargatePlatformVersion.VERSION1_4, - DeploymentController: { - Type: 'ECS', - }, - }); + LaunchType: 'FARGATE', + ServiceName: 'fargate-test-service', + PlatformVersion: ecs.FargatePlatformVersion.VERSION1_4, + DeploymentController: { + Type: 'ECS', + }, + }); - Template.fromStack(stack).hasResourceProperties('AWS::SQS::Queue', { QueueName: 'fargate-test-sqs-queue' }); + Template.fromStack(stack).hasResourceProperties('AWS::SQS::Queue', { + QueueName: 'fargate-test-sqs-queue', + }); - Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', { - ContainerDefinitions: [ - Match.objectLike({ - Command: [ - '-c', - '4', - 'amazon.com', - ], - Environment: [ - { - Name: 'TEST_ENVIRONMENT_VARIABLE1', - Value: 'test environment variable 1 value', - }, - { - Name: 'TEST_ENVIRONMENT_VARIABLE2', - Value: 'test environment variable 2 value', - }, - { - Name: 'QUEUE_NAME', - Value: { - 'Fn::GetAtt': [ - 'fargatetestqueue28B43841', - 'QueueName', - ], - }, - }, + Template.fromStack(stack).hasResourceProperties( + 'AWS::ECS::TaskDefinition', + { + ContainerDefinitions: [ + Match.objectLike({ + Command: ['-c', '4', 'amazon.com'], + Environment: [ + { + Name: 'TEST_ENVIRONMENT_VARIABLE1', + Value: 'test environment variable 1 value', + }, + { + Name: 'TEST_ENVIRONMENT_VARIABLE2', + Value: 'test environment variable 2 value', + }, + { + Name: 'QUEUE_NAME', + Value: { + 'Fn::GetAtt': ['fargatetestqueue28B43841', 'QueueName'], + }, + }, + ], + Image: 'test', + }), ], - Image: 'test', - }), - ], - Family: 'fargate-task-family', - }); -}); + Family: 'fargate-task-family', + }, + ); + }, +); test('can set custom containerName', () => { // GIVEN const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'VPC'); const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); - cluster.addAsgCapacityProvider(new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { - autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { - vpc, - instanceType: new ec2.InstanceType('t2.micro'), - machineImage: MachineImage.latestAmazonLinux(), + cluster.addAsgCapacityProvider( + new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { + autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { + vpc, + instanceType: new ec2.InstanceType('t2.micro'), + machineImage: MachineImage.latestAmazonLinux(), + }), }), - })); + ); // WHEN new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { @@ -553,10 +545,7 @@ test('can set custom networking options', () => { AssignPublicIp: 'DISABLED', SecurityGroups: [ { - 'Fn::GetAtt': [ - 'MyCustomSGDE27C661', - 'GroupId', - ], + 'Fn::GetAtt': ['MyCustomSGDE27C661', 'GroupId'], }, ], Subnets: [ @@ -729,7 +718,11 @@ it('throws validation errors of the specific queue prop, when setting queue and visibilityTimeout: cdk.Duration.seconds(200), maxReceiveCount: 10, }); - }).toThrow(new Error('retentionPeriod, visibilityTimeout, maxReceiveCount can be set only when queue is not set. Specify them in the QueueProps of the queue')); + }).toThrow( + new Error( + 'retentionPeriod, visibilityTimeout, maxReceiveCount can be set only when queue is not set. Specify them in the QueueProps of the queue', + ), + ); // Setting only visibilityTimeout expect(() => { @@ -738,5 +731,73 @@ it('throws validation errors of the specific queue prop, when setting queue and queue: queue, visibilityTimeout: cdk.Duration.seconds(200), }); - }).toThrow(new Error('visibilityTimeout can be set only when queue is not set. Specify them in the QueueProps of the queue')); + }).toThrow( + new Error( + 'visibilityTimeout can be set only when queue is not set. Specify them in the QueueProps of the queue', + ), + ); +}); + +test('test Fargate queue worker service construct - with task definition', () => { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'VPC'); + const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); + cluster.addAsgCapacityProvider( + new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { + autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { + vpc, + instanceType: new ec2.InstanceType('t2.micro'), + machineImage: MachineImage.latestAmazonLinux(), + }), + }), + ); + + // WHEN + const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef', { + memoryLimitMiB: 1024, + cpu: 512, + ephemeralStorageGiB: 30, + }); + + new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { + vpc, + taskDefinition, + image: ecs.ContainerImage.fromRegistry('test'), + }); + + // THEN - The separately created TaskDefinition is used. Memory is 1024, cpu is 512, and ephemeralStorage is 30 + Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', { + ContainerDefinitions: [ + Match.objectLike({ + Environment: [ + { + Name: 'QUEUE_NAME', + Value: { + 'Fn::GetAtt': ['ServiceEcsProcessingQueueC266885C', 'QueueName'], + }, + }, + ], + LogConfiguration: { + LogDriver: 'awslogs', + Options: { + 'awslogs-group': { + Ref: 'TaskDefQueueProcessingContainerLogGroupBC6BD4C2', + }, + 'awslogs-stream-prefix': 'Service', + 'awslogs-region': { + Ref: 'AWS::Region', + }, + }, + }, + Image: 'test', + }), + ], + Family: 'TaskDef', + Memory: '1024', + Cpu: '512', + EphemeralStorage: { + SizeInGiB: 30, + }, + }); }); From 7539cfe6f9e162573cf7a29d3da86f6db23b9fda Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Sat, 2 Dec 2023 12:30:09 +0900 Subject: [PATCH 02/13] refactor: format --- .../queue-processing-fargate-service.ts | 27 +- .../queue-processing-fargate-service.test.ts | 311 +++++++++--------- 2 files changed, 162 insertions(+), 176 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts index 25d93eb784a41..da15f700694cb 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts @@ -1,24 +1,15 @@ import { Construct } from 'constructs'; import * as ec2 from '../../../aws-ec2'; -import { - FargateService, - FargateTaskDefinition, - HealthCheck, -} from '../../../aws-ecs'; +import { FargateService, FargateTaskDefinition, HealthCheck } from '../../../aws-ecs'; import { FeatureFlags } from '../../../core'; import * as cxapi from '../../../cx-api'; import { FargateServiceBaseProps } from '../base/fargate-service-base'; -import { - QueueProcessingServiceBase, - QueueProcessingServiceBaseProps, -} from '../base/queue-processing-service-base'; +import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../base/queue-processing-service-base'; /** * The properties for the QueueProcessingFargateService service. */ -export interface QueueProcessingFargateServiceProps - extends QueueProcessingServiceBaseProps, - FargateServiceBaseProps { +export interface QueueProcessingFargateServiceProps extends QueueProcessingServiceBaseProps, FargateServiceBaseProps { /** * Optional name for the container added * @@ -73,11 +64,7 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase { /** * Constructs a new instance of the QueueProcessingFargateService class. */ - constructor( - scope: Construct, - id: string, - props: QueueProcessingFargateServiceProps, - ) { + constructor(scope: Construct, id: string, props: QueueProcessingFargateServiceProps) { super(scope, id, props); // Create a Task Definition for the container to start @@ -102,11 +89,7 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase { }); // The desiredCount should be removed from the fargate service when the feature flag is removed. - const desiredCount = FeatureFlags.of(this).isEnabled( - cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT, - ) - ? undefined - : this.desiredCount; + const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? undefined : this.desiredCount; // Create a Fargate service with the previously defined Task Definition and configure // autoscaling based on cpu utilization and number of messages visible in the SQS queue. diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts index d4c3b1b8cfe0e..7213b3df453dd 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts @@ -15,15 +15,13 @@ test('test fargate queue worker service construct - with only required props', ( const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'VPC'); const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); - cluster.addAsgCapacityProvider( - new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { - autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { - vpc, - instanceType: new ec2.InstanceType('t2.micro'), - machineImage: MachineImage.latestAmazonLinux(), - }), + cluster.addAsgCapacityProvider(new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { + autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { + vpc, + instanceType: new ec2.InstanceType('t2.micro'), + machineImage: MachineImage.latestAmazonLinux(), }), - ); + })); // WHEN new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { @@ -40,7 +38,10 @@ test('test fargate queue worker service construct - with only required props', ( Template.fromStack(stack).hasResourceProperties('AWS::SQS::Queue', { RedrivePolicy: { deadLetterTargetArn: { - 'Fn::GetAtt': ['ServiceEcsProcessingDeadLetterQueue4A89196E', 'Arn'], + 'Fn::GetAtt': [ + 'ServiceEcsProcessingDeadLetterQueue4A89196E', + 'Arn', + ], }, maxReceiveCount: 3, }, @@ -63,7 +64,10 @@ test('test fargate queue worker service construct - with only required props', ( ], Effect: 'Allow', Resource: { - 'Fn::GetAtt': ['ServiceEcsProcessingQueueC266885C', 'Arn'], + 'Fn::GetAtt': [ + 'ServiceEcsProcessingQueueC266885C', + 'Arn', + ], }, }, ], @@ -78,7 +82,10 @@ test('test fargate queue worker service construct - with only required props', ( { Name: 'QUEUE_NAME', Value: { - 'Fn::GetAtt': ['ServiceEcsProcessingQueueC266885C', 'QueueName'], + 'Fn::GetAtt': [ + 'ServiceEcsProcessingQueueC266885C', + 'QueueName', + ], }, }, ], @@ -126,15 +133,13 @@ test('test fargate queue worker service construct - with optional props for queu const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'VPC'); const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); - cluster.addAsgCapacityProvider( - new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { - autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { - vpc, - instanceType: new ec2.InstanceType('t2.micro'), - machineImage: MachineImage.latestAmazonLinux(), - }), + cluster.addAsgCapacityProvider(new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { + autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { + vpc, + instanceType: new ec2.InstanceType('t2.micro'), + machineImage: MachineImage.latestAmazonLinux(), }), - ); + })); // WHEN new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { @@ -154,7 +159,10 @@ test('test fargate queue worker service construct - with optional props for queu Template.fromStack(stack).hasResourceProperties('AWS::SQS::Queue', { RedrivePolicy: { deadLetterTargetArn: { - 'Fn::GetAtt': ['ServiceEcsProcessingDeadLetterQueue4A89196E', 'Arn'], + 'Fn::GetAtt': [ + 'ServiceEcsProcessingDeadLetterQueue4A89196E', + 'Arn', + ], }, maxReceiveCount: 42, }, @@ -178,7 +186,10 @@ test('test fargate queue worker service construct - with optional props for queu ], Effect: 'Allow', Resource: { - 'Fn::GetAtt': ['ServiceEcsProcessingQueueC266885C', 'Arn'], + 'Fn::GetAtt': [ + 'ServiceEcsProcessingQueueC266885C', + 'Arn', + ], }, }, ], @@ -193,7 +204,10 @@ test('test fargate queue worker service construct - with optional props for queu { Name: 'QUEUE_NAME', Value: { - 'Fn::GetAtt': ['ServiceEcsProcessingQueueC266885C', 'QueueName'], + 'Fn::GetAtt': [ + 'ServiceEcsProcessingQueueC266885C', + 'QueueName', + ], }, }, ], @@ -269,7 +283,10 @@ test('test Fargate queue worker service construct - with ECS Exec', () => { ], Effect: 'Allow', Resource: { - 'Fn::GetAtt': ['ServiceEcsProcessingQueueC266885C', 'Arn'], + 'Fn::GetAtt': [ + 'ServiceEcsProcessingQueueC266885C', + 'Arn', + ], }, }, ], @@ -289,15 +306,13 @@ test('test Fargate queue worker service construct - without desiredCount specifi const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'VPC'); const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); - cluster.addAsgCapacityProvider( - new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { - autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { - vpc, - instanceType: new ec2.InstanceType('t2.micro'), - machineImage: MachineImage.latestAmazonLinux(), - }), + cluster.addAsgCapacityProvider(new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { + autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { + vpc, + instanceType: new ec2.InstanceType('t2.micro'), + machineImage: MachineImage.latestAmazonLinux(), }), - ); + })); const queue = new sqs.Queue(stack, 'fargate-test-queue', { queueName: 'fargate-test-sqs-queue', }); @@ -340,22 +355,21 @@ test('test Fargate queue worker service construct - without desiredCount specifi }, }); - Template.fromStack(stack).hasResourceProperties( - 'AWS::ApplicationAutoScaling::ScalableTarget', - { - MaxCapacity: 5, - MinCapacity: 2, - }, - ); - - Template.fromStack(stack).hasResourceProperties('AWS::SQS::Queue', { - QueueName: 'fargate-test-sqs-queue', + Template.fromStack(stack).hasResourceProperties('AWS::ApplicationAutoScaling::ScalableTarget', { + MaxCapacity: 5, + MinCapacity: 2, }); + Template.fromStack(stack).hasResourceProperties('AWS::SQS::Queue', { QueueName: 'fargate-test-sqs-queue' }); + Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', { ContainerDefinitions: [ Match.objectLike({ - Command: ['-c', '4', 'amazon.com'], + Command: [ + '-c', + '4', + 'amazon.com', + ], Environment: [ { Name: 'TEST_ENVIRONMENT_VARIABLE1', @@ -368,7 +382,10 @@ test('test Fargate queue worker service construct - without desiredCount specifi { Name: 'QUEUE_NAME', Value: { - 'Fn::GetAtt': ['fargatetestqueue28B43841', 'QueueName'], + 'Fn::GetAtt': [ + 'fargatetestqueue28B43841', + 'QueueName', + ], }, }, ], @@ -379,118 +396,109 @@ test('test Fargate queue worker service construct - without desiredCount specifi }); }); -testDeprecated( - 'test Fargate queue worker service construct - with optional props', - () => { - // GIVEN - const stack = new cdk.Stack(); - const vpc = new ec2.Vpc(stack, 'VPC'); - const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); - cluster.addAsgCapacityProvider( - new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { - autoScalingGroup: new AutoScalingGroup( - stack, - 'DefaultAutoScalingGroup', - { - vpc, - instanceType: new ec2.InstanceType('t2.micro'), - machineImage: MachineImage.latestAmazonLinux(), - }, - ), - }), - ); - const queue = new sqs.Queue(stack, 'fargate-test-queue', { - queueName: 'fargate-test-sqs-queue', - }); +testDeprecated('test Fargate queue worker service construct - with optional props', () => { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'VPC'); + const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); + cluster.addAsgCapacityProvider(new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { + autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { + vpc, + instanceType: new ec2.InstanceType('t2.micro'), + machineImage: MachineImage.latestAmazonLinux(), + }), + })); + const queue = new sqs.Queue(stack, 'fargate-test-queue', { + queueName: 'fargate-test-sqs-queue', + }); - // WHEN - new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { - cluster, - memoryLimitMiB: 512, - image: ecs.ContainerImage.fromRegistry('test'), - command: ['-c', '4', 'amazon.com'], - enableLogging: false, - environment: { - TEST_ENVIRONMENT_VARIABLE1: 'test environment variable 1 value', - TEST_ENVIRONMENT_VARIABLE2: 'test environment variable 2 value', - }, - queue, - maxScalingCapacity: 5, - minHealthyPercent: 60, - maxHealthyPercent: 150, - serviceName: 'fargate-test-service', - family: 'fargate-task-family', - platformVersion: ecs.FargatePlatformVersion.VERSION1_4, - circuitBreaker: { rollback: true }, - }); + // WHEN + new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { + cluster, + memoryLimitMiB: 512, + image: ecs.ContainerImage.fromRegistry('test'), + command: ['-c', '4', 'amazon.com'], + enableLogging: false, + environment: { + TEST_ENVIRONMENT_VARIABLE1: 'test environment variable 1 value', + TEST_ENVIRONMENT_VARIABLE2: 'test environment variable 2 value', + }, + queue, + maxScalingCapacity: 5, + minHealthyPercent: 60, + maxHealthyPercent: 150, + serviceName: 'fargate-test-service', + family: 'fargate-task-family', + platformVersion: ecs.FargatePlatformVersion.VERSION1_4, + circuitBreaker: { rollback: true }, + }); - // THEN - QueueWorker is of FARGATE launch type, an SQS queue is created and all optional properties are set. - Template.fromStack(stack).hasResourceProperties('AWS::ECS::Service', { - DeploymentConfiguration: { - MinimumHealthyPercent: 60, - MaximumPercent: 150, - DeploymentCircuitBreaker: { - Enable: true, - Rollback: true, - }, - }, - LaunchType: 'FARGATE', - ServiceName: 'fargate-test-service', - PlatformVersion: ecs.FargatePlatformVersion.VERSION1_4, - DeploymentController: { - Type: 'ECS', + // THEN - QueueWorker is of FARGATE launch type, an SQS queue is created and all optional properties are set. + Template.fromStack(stack).hasResourceProperties('AWS::ECS::Service', { + DeploymentConfiguration: { + MinimumHealthyPercent: 60, + MaximumPercent: 150, + DeploymentCircuitBreaker: { + Enable: true, + Rollback: true, }, - }); + }, + LaunchType: 'FARGATE', + ServiceName: 'fargate-test-service', + PlatformVersion: ecs.FargatePlatformVersion.VERSION1_4, + DeploymentController: { + Type: 'ECS', + }, + }); - Template.fromStack(stack).hasResourceProperties('AWS::SQS::Queue', { - QueueName: 'fargate-test-sqs-queue', - }); + Template.fromStack(stack).hasResourceProperties('AWS::SQS::Queue', { QueueName: 'fargate-test-sqs-queue' }); - Template.fromStack(stack).hasResourceProperties( - 'AWS::ECS::TaskDefinition', - { - ContainerDefinitions: [ - Match.objectLike({ - Command: ['-c', '4', 'amazon.com'], - Environment: [ - { - Name: 'TEST_ENVIRONMENT_VARIABLE1', - Value: 'test environment variable 1 value', - }, - { - Name: 'TEST_ENVIRONMENT_VARIABLE2', - Value: 'test environment variable 2 value', - }, - { - Name: 'QUEUE_NAME', - Value: { - 'Fn::GetAtt': ['fargatetestqueue28B43841', 'QueueName'], - }, - }, - ], - Image: 'test', - }), + Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', { + ContainerDefinitions: [ + Match.objectLike({ + Command: [ + '-c', + '4', + 'amazon.com', ], - Family: 'fargate-task-family', - }, - ); - }, -); + Environment: [ + { + Name: 'TEST_ENVIRONMENT_VARIABLE1', + Value: 'test environment variable 1 value', + }, + { + Name: 'TEST_ENVIRONMENT_VARIABLE2', + Value: 'test environment variable 2 value', + }, + { + Name: 'QUEUE_NAME', + Value: { + 'Fn::GetAtt': [ + 'fargatetestqueue28B43841', + 'QueueName', + ], + }, + }, + ], + Image: 'test', + }), + ], + Family: 'fargate-task-family', + }); +}); test('can set custom containerName', () => { // GIVEN const stack = new cdk.Stack(); const vpc = new ec2.Vpc(stack, 'VPC'); const cluster = new ecs.Cluster(stack, 'Cluster', { vpc }); - cluster.addAsgCapacityProvider( - new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { - autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { - vpc, - instanceType: new ec2.InstanceType('t2.micro'), - machineImage: MachineImage.latestAmazonLinux(), - }), + cluster.addAsgCapacityProvider(new AsgCapacityProvider(stack, 'DefaultAutoScalingGroupProvider', { + autoScalingGroup: new AutoScalingGroup(stack, 'DefaultAutoScalingGroup', { + vpc, + instanceType: new ec2.InstanceType('t2.micro'), + machineImage: MachineImage.latestAmazonLinux(), }), - ); + })); // WHEN new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { @@ -545,7 +553,10 @@ test('can set custom networking options', () => { AssignPublicIp: 'DISABLED', SecurityGroups: [ { - 'Fn::GetAtt': ['MyCustomSGDE27C661', 'GroupId'], + 'Fn::GetAtt': [ + 'MyCustomSGDE27C661', + 'GroupId', + ], }, ], Subnets: [ @@ -718,11 +729,7 @@ it('throws validation errors of the specific queue prop, when setting queue and visibilityTimeout: cdk.Duration.seconds(200), maxReceiveCount: 10, }); - }).toThrow( - new Error( - 'retentionPeriod, visibilityTimeout, maxReceiveCount can be set only when queue is not set. Specify them in the QueueProps of the queue', - ), - ); + }).toThrow(new Error('retentionPeriod, visibilityTimeout, maxReceiveCount can be set only when queue is not set. Specify them in the QueueProps of the queue')); // Setting only visibilityTimeout expect(() => { @@ -731,11 +738,7 @@ it('throws validation errors of the specific queue prop, when setting queue and queue: queue, visibilityTimeout: cdk.Duration.seconds(200), }); - }).toThrow( - new Error( - 'visibilityTimeout can be set only when queue is not set. Specify them in the QueueProps of the queue', - ), - ); + }).toThrow(new Error('visibilityTimeout can be set only when queue is not set. Specify them in the QueueProps of the queue')); }); test('test Fargate queue worker service construct - with task definition', () => { @@ -800,4 +803,4 @@ test('test Fargate queue worker service construct - with task definition', () => SizeInGiB: 30, }, }); -}); +}); \ No newline at end of file From 066ce764bed2e7a660ef76bd77dfc0cf05664150 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Sat, 9 Dec 2023 00:48:29 +0900 Subject: [PATCH 03/13] test: integ test --- .../lib/base/queue-processing-service-base.ts | 3 +- .../queue-processing-fargate-service.ts | 36 +++++++++++-------- .../queue-processing-fargate-service.test.ts | 26 +++----------- 3 files changed, 27 insertions(+), 38 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts index 385caafdc0ca2..e3e4884d4a631 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts @@ -38,8 +38,9 @@ export interface QueueProcessingServiceBaseProps { /** * The image used to start a container. + * Image or taskDefinition must be specified, but not both. */ - readonly image: ContainerImage; + readonly image?: ContainerImage; /** * The command that is passed to the container. diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts index da15f700694cb..7eb5886c6e3ee 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts @@ -11,7 +11,8 @@ import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../ */ export interface QueueProcessingFargateServiceProps extends QueueProcessingServiceBaseProps, FargateServiceBaseProps { /** - * Optional name for the container added + * Optional name for the container added. + * This name is not used when `taskDefinition` is provided. * * @default - QueueProcessingContainer */ @@ -67,26 +68,31 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase { constructor(scope: Construct, id: string, props: QueueProcessingFargateServiceProps) { super(scope, id, props); - // Create a Task Definition for the container to start - this.taskDefinition = - props.taskDefinition ?? - new FargateTaskDefinition(this, 'QueueProcessingTaskDef', { + if (props.taskDefinition != null && props.image != null) { + throw new Error('You must specify only one of TaskDefinition or Image'); + } else if (props.taskDefinition != null) { + this.taskDefinition = props.taskDefinition; + } else if (props.image != null) { + // Create a Task Definition for the container to start + this.taskDefinition = new FargateTaskDefinition(this, 'QueueProcessingTaskDef', { memoryLimitMiB: props.memoryLimitMiB || 512, cpu: props.cpu || 256, family: props.family, runtimePlatform: props.runtimePlatform, }); - const containerName = props.containerName ?? 'QueueProcessingContainer'; - - this.taskDefinition.addContainer(containerName, { - image: props.image, - command: props.command, - environment: this.environment, - secrets: this.secrets, - logging: this.logDriver, - healthCheck: props.healthCheck, - }); + const containerName = props.containerName ?? 'QueueProcessingContainer'; + this.taskDefinition.addContainer(containerName, { + image: props.image, + command: props.command, + environment: this.environment, + secrets: this.secrets, + logging: this.logDriver, + healthCheck: props.healthCheck, + }); + } else { + throw new Error('You must specify one of: taskDefinition or image'); + } // The desiredCount should be removed from the fargate service when the feature flag is removed. const desiredCount = FeatureFlags.of(this).isEnabled(cxapi.ECS_REMOVE_DEFAULT_DESIRED_COUNT) ? undefined : this.desiredCount; diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts index 7213b3df453dd..b95a132862274 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts @@ -762,37 +762,19 @@ test('test Fargate queue worker service construct - with task definition', () => cpu: 512, ephemeralStorageGiB: 30, }); + taskDefinition.addContainer('QueueProcessingContainer', { + image: ecs.ContainerImage.fromRegistry('test'), + }); new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { vpc, taskDefinition, - image: ecs.ContainerImage.fromRegistry('test'), }); // THEN - The separately created TaskDefinition is used. Memory is 1024, cpu is 512, and ephemeralStorage is 30 Template.fromStack(stack).hasResourceProperties('AWS::ECS::TaskDefinition', { ContainerDefinitions: [ Match.objectLike({ - Environment: [ - { - Name: 'QUEUE_NAME', - Value: { - 'Fn::GetAtt': ['ServiceEcsProcessingQueueC266885C', 'QueueName'], - }, - }, - ], - LogConfiguration: { - LogDriver: 'awslogs', - Options: { - 'awslogs-group': { - Ref: 'TaskDefQueueProcessingContainerLogGroupBC6BD4C2', - }, - 'awslogs-stream-prefix': 'Service', - 'awslogs-region': { - Ref: 'AWS::Region', - }, - }, - }, Image: 'test', }), ], @@ -803,4 +785,4 @@ test('test Fargate queue worker service construct - with task definition', () => SizeInGiB: 30, }, }); -}); \ No newline at end of file +}); From d3f83a2531f909b40343e3638810d8355058ebec Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Sat, 9 Dec 2023 22:29:53 +0900 Subject: [PATCH 04/13] test(ecs-patterns): add integ test snapshot --- .../Dockerfile | 10 + .../index.py | 22 + .../aws-ecs-patterns-queue.assets.json | 32 + .../aws-ecs-patterns-queue.template.json | 927 ++++++++++ .../cdk.out | 1 + .../integ.json | 12 + .../manifest.json | 371 ++++ ...efaultTestDeployAssert406F467D.assets.json | 19 + ...aultTestDeployAssert406F467D.template.json | 36 + .../tree.json | 1600 +++++++++++++++++ ...cessing-fargate-service-task-definition.ts | 35 + 11 files changed, 3065 insertions(+) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/asset.95cefedd43575452a70cdeeeceb0f1c5728fd58c9ff8e81e760c3dac33c46417/Dockerfile create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/asset.95cefedd43575452a70cdeeeceb0f1c5728fd58c9ff8e81e760c3dac33c46417/index.py create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/aws-ecs-patterns-queue.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/aws-ecs-patterns-queue.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/asset.95cefedd43575452a70cdeeeceb0f1c5728fd58c9ff8e81e760c3dac33c46417/Dockerfile b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/asset.95cefedd43575452a70cdeeeceb0f1c5728fd58c9ff8e81e760c3dac33c46417/Dockerfile new file mode 100644 index 0000000000000..919fabfc3f637 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/asset.95cefedd43575452a70cdeeeceb0f1c5728fd58c9ff8e81e760c3dac33c46417/Dockerfile @@ -0,0 +1,10 @@ +FROM public.ecr.aws/lambda/python:3.6 + +RUN pip3 install boto3 + +ENV QUEUE_NAME $QUEUE_NAME + +WORKDIR /src +ADD . /src + +CMD python3 index.py diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/asset.95cefedd43575452a70cdeeeceb0f1c5728fd58c9ff8e81e760c3dac33c46417/index.py b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/asset.95cefedd43575452a70cdeeeceb0f1c5728fd58c9ff8e81e760c3dac33c46417/index.py new file mode 100644 index 0000000000000..8b53f5149cb24 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/asset.95cefedd43575452a70cdeeeceb0f1c5728fd58c9ff8e81e760c3dac33c46417/index.py @@ -0,0 +1,22 @@ +#!/usr/bin/python +import os +import boto3 + +QUEUE_NAME = os.environ.get('QUEUE_NAME') +print('QUEUE_NAME ' + QUEUE_NAME) + +if __name__ == '__main__': + client = boto3.client('sqs') + queue_url = client.get_queue_url(QueueName=QUEUE_NAME)['QueueUrl'] + print('queue_url ' + queue_url) + while True: + response = client.receive_message( + QueueUrl=queue_url, + WaitTimeSeconds=10, + ) + if response and 'Messages' in response: + for msg in response['Messages']: + print(msg['Body']) + entries = [{'Id': x['MessageId'], 'ReceiptHandle': x['ReceiptHandle']} for x in response['Messages']] + client.delete_message_batch(QueueUrl=queue_url, Entries=entries) + diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/aws-ecs-patterns-queue.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/aws-ecs-patterns-queue.assets.json new file mode 100644 index 0000000000000..454d0550721ef --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/aws-ecs-patterns-queue.assets.json @@ -0,0 +1,32 @@ +{ + "version": "35.0.0", + "files": { + "7bb9af94727d4a18ae0929321b0ef2f29cd6f89d6653d9676483f8edc1cf3edc": { + "source": { + "path": "aws-ecs-patterns-queue.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "7bb9af94727d4a18ae0929321b0ef2f29cd6f89d6653d9676483f8edc1cf3edc.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": { + "95cefedd43575452a70cdeeeceb0f1c5728fd58c9ff8e81e760c3dac33c46417": { + "source": { + "directory": "asset.95cefedd43575452a70cdeeeceb0f1c5728fd58c9ff8e81e760c3dac33c46417" + }, + "destinations": { + "current_account-current_region": { + "repositoryName": "cdk-hnb659fds-container-assets-${AWS::AccountId}-${AWS::Region}", + "imageTag": "95cefedd43575452a70cdeeeceb0f1c5728fd58c9ff8e81e760c3dac33c46417", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-image-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/aws-ecs-patterns-queue.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/aws-ecs-patterns-queue.template.json new file mode 100644 index 0000000000000..a5af9e6dea707 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/aws-ecs-patterns-queue.template.json @@ -0,0 +1,927 @@ +{ + "Resources": { + "VPCB9E5F0B4": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": [ + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC" + } + ] + } + }, + "VPCPublicSubnet1SubnetB4246D30": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.0.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPublicSubnet1RouteTableFEE4B781": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPublicSubnet1RouteTableAssociation0B0896DC": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + }, + "SubnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + } + } + }, + "VPCPublicSubnet1DefaultRoute91CEF279": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "RouteTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + } + }, + "DependsOn": [ + "VPCVPCGW99B986DC" + ] + }, + "VPCPublicSubnet1EIP6AD938E8": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC/PublicSubnet1" + } + ] + } + }, + "VPCPublicSubnet1NATGatewayE0556630": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC/PublicSubnet1" + } + ] + }, + "DependsOn": [ + "VPCPublicSubnet1DefaultRoute91CEF279", + "VPCPublicSubnet1RouteTableAssociation0B0896DC" + ] + }, + "VPCPublicSubnet2Subnet74179F39": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.64.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPublicSubnet2RouteTable6F1A15F1": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPublicSubnet2RouteTableAssociation5A808732": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + }, + "SubnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + } + } + }, + "VPCPublicSubnet2DefaultRouteB7481BBA": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "RouteTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + } + }, + "DependsOn": [ + "VPCVPCGW99B986DC" + ] + }, + "VPCPublicSubnet2EIP4947BC00": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC/PublicSubnet2" + } + ] + } + }, + "VPCPublicSubnet2NATGateway3C070193": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + }, + "Tags": [ + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC/PublicSubnet2" + } + ] + }, + "DependsOn": [ + "VPCPublicSubnet2DefaultRouteB7481BBA", + "VPCPublicSubnet2RouteTableAssociation5A808732" + ] + }, + "VPCPrivateSubnet1Subnet8BCA10E0": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.128.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC/PrivateSubnet1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPrivateSubnet1RouteTableBE8A6027": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC/PrivateSubnet1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPrivateSubnet1RouteTableAssociation347902D1": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + }, + "SubnetId": { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + } + } + }, + "VPCPrivateSubnet1DefaultRouteAE1D6490": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VPCPublicSubnet1NATGatewayE0556630" + }, + "RouteTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + } + } + }, + "VPCPrivateSubnet2SubnetCFCDAA7A": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.192.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC/PrivateSubnet2" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPrivateSubnet2RouteTable0A19E10E": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC/PrivateSubnet2" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPrivateSubnet2RouteTableAssociation0C73D413": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + }, + "SubnetId": { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + } + }, + "VPCPrivateSubnet2DefaultRouteF4F5CFD2": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VPCPublicSubnet2NATGateway3C070193" + }, + "RouteTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + } + } + }, + "VPCIGWB7E252D3": { + "Type": "AWS::EC2::InternetGateway", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "aws-ecs-patterns-queue/VPC" + } + ] + } + }, + "VPCVPCGW99B986DC": { + "Type": "AWS::EC2::VPCGatewayAttachment", + "Properties": { + "InternetGatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "TaskDefTaskRole1EDB4A67": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ecs-tasks.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "TaskDefTaskRoleDefaultPolicyA592CB18": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "sqs:ChangeMessageVisibility", + "sqs:DeleteMessage", + "sqs:GetQueueAttributes", + "sqs:GetQueueUrl", + "sqs:ReceiveMessage" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "QueueProcessingServiceEcsProcessingQueue552F0B37", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "TaskDefTaskRoleDefaultPolicyA592CB18", + "Roles": [ + { + "Ref": "TaskDefTaskRole1EDB4A67" + } + ] + } + }, + "TaskDef54694570": { + "Type": "AWS::ECS::TaskDefinition", + "Properties": { + "ContainerDefinitions": [ + { + "Essential": true, + "Image": { + "Fn::Sub": "${AWS::AccountId}.dkr.ecr.${AWS::Region}.${AWS::URLSuffix}/cdk-hnb659fds-container-assets-${AWS::AccountId}-${AWS::Region}:95cefedd43575452a70cdeeeceb0f1c5728fd58c9ff8e81e760c3dac33c46417" + }, + "LogConfiguration": { + "LogDriver": "awslogs", + "Options": { + "awslogs-group": { + "Ref": "TaskDefTheContainerLogGroupD94C8EF5" + }, + "awslogs-stream-prefix": "QueueProcessingFargateService", + "awslogs-region": { + "Ref": "AWS::Region" + } + } + }, + "Name": "TheContainer" + } + ], + "Cpu": "512", + "EphemeralStorage": { + "SizeInGiB": 30 + }, + "ExecutionRoleArn": { + "Fn::GetAtt": [ + "TaskDefExecutionRoleB4775C97", + "Arn" + ] + }, + "Family": "awsecspatternsqueueTaskDefD9E658F3", + "Memory": "1024", + "NetworkMode": "awsvpc", + "RequiresCompatibilities": [ + "FARGATE" + ], + "TaskRoleArn": { + "Fn::GetAtt": [ + "TaskDefTaskRole1EDB4A67", + "Arn" + ] + } + } + }, + "TaskDefTheContainerLogGroupD94C8EF5": { + "Type": "AWS::Logs::LogGroup", + "UpdateReplacePolicy": "Retain", + "DeletionPolicy": "Retain" + }, + "TaskDefExecutionRoleB4775C97": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ecs-tasks.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "TaskDefExecutionRoleDefaultPolicy0DBB737A": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "ecr:BatchCheckLayerAvailability", + "ecr:BatchGetImage", + "ecr:GetDownloadUrlForLayer" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":ecr:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":repository/", + { + "Fn::Sub": "cdk-hnb659fds-container-assets-${AWS::AccountId}-${AWS::Region}" + } + ] + ] + } + }, + { + "Action": "ecr:GetAuthorizationToken", + "Effect": "Allow", + "Resource": "*" + }, + { + "Action": [ + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "TaskDefTheContainerLogGroupD94C8EF5", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "TaskDefExecutionRoleDefaultPolicy0DBB737A", + "Roles": [ + { + "Ref": "TaskDefExecutionRoleB4775C97" + } + ] + } + }, + "QueueProcessingServiceEcsProcessingDeadLetterQueueD47A7C6B": { + "Type": "AWS::SQS::Queue", + "Properties": { + "MessageRetentionPeriod": 1209600 + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "QueueProcessingServiceEcsProcessingQueue552F0B37": { + "Type": "AWS::SQS::Queue", + "Properties": { + "RedrivePolicy": { + "deadLetterTargetArn": { + "Fn::GetAtt": [ + "QueueProcessingServiceEcsProcessingDeadLetterQueueD47A7C6B", + "Arn" + ] + }, + "maxReceiveCount": 3 + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "QueueProcessingServiceQueueProcessingFargateService0340DB9F": { + "Type": "AWS::ECS::Service", + "Properties": { + "Cluster": { + "Ref": "EcsDefaultClusterMnL3mNNYNVPC9C1EC7A3" + }, + "DeploymentConfiguration": { + "Alarms": { + "AlarmNames": [], + "Enable": false, + "Rollback": false + }, + "MaximumPercent": 200, + "MinimumHealthyPercent": 50 + }, + "EnableECSManagedTags": false, + "LaunchType": "FARGATE", + "NetworkConfiguration": { + "AwsvpcConfiguration": { + "AssignPublicIp": "DISABLED", + "SecurityGroups": [ + { + "Fn::GetAtt": [ + "QueueProcessingServiceQueueProcessingFargateServiceSecurityGroup8FDF413D", + "GroupId" + ] + } + ], + "Subnets": [ + { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + }, + { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + ] + } + }, + "TaskDefinition": { + "Ref": "TaskDef54694570" + } + }, + "DependsOn": [ + "TaskDefTaskRoleDefaultPolicyA592CB18", + "TaskDefTaskRole1EDB4A67" + ] + }, + "QueueProcessingServiceQueueProcessingFargateServiceSecurityGroup8FDF413D": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/SecurityGroup", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + }, + "DependsOn": [ + "TaskDefTaskRoleDefaultPolicyA592CB18", + "TaskDefTaskRole1EDB4A67" + ] + }, + "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetA9D54444": { + "Type": "AWS::ApplicationAutoScaling::ScalableTarget", + "Properties": { + "MaxCapacity": 2, + "MinCapacity": 1, + "ResourceId": { + "Fn::Join": [ + "", + [ + "service/", + { + "Ref": "EcsDefaultClusterMnL3mNNYNVPC9C1EC7A3" + }, + "/", + { + "Fn::GetAtt": [ + "QueueProcessingServiceQueueProcessingFargateService0340DB9F", + "Name" + ] + } + ] + ] + }, + "RoleARN": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::", + { + "Ref": "AWS::AccountId" + }, + ":role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService" + ] + ] + }, + "ScalableDimension": "ecs:service:DesiredCount", + "ServiceNamespace": "ecs" + }, + "DependsOn": [ + "TaskDefTaskRoleDefaultPolicyA592CB18", + "TaskDefTaskRole1EDB4A67" + ] + }, + "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetCpuScaling330150E9": { + "Type": "AWS::ApplicationAutoScaling::ScalingPolicy", + "Properties": { + "PolicyName": "awsecspatternsqueueQueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetCpuScaling374CE648", + "PolicyType": "TargetTrackingScaling", + "ScalingTargetId": { + "Ref": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetA9D54444" + }, + "TargetTrackingScalingPolicyConfiguration": { + "PredefinedMetricSpecification": { + "PredefinedMetricType": "ECSServiceAverageCPUUtilization" + }, + "TargetValue": 50 + } + }, + "DependsOn": [ + "TaskDefTaskRoleDefaultPolicyA592CB18", + "TaskDefTaskRole1EDB4A67" + ] + }, + "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingLowerPolicy332E2644": { + "Type": "AWS::ApplicationAutoScaling::ScalingPolicy", + "Properties": { + "PolicyName": "awsecspatternsqueueQueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingLowerPolicy74582401", + "PolicyType": "StepScaling", + "ScalingTargetId": { + "Ref": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetA9D54444" + }, + "StepScalingPolicyConfiguration": { + "AdjustmentType": "ChangeInCapacity", + "MetricAggregationType": "Maximum", + "StepAdjustments": [ + { + "MetricIntervalUpperBound": 0, + "ScalingAdjustment": -1 + } + ] + } + }, + "DependsOn": [ + "TaskDefTaskRoleDefaultPolicyA592CB18", + "TaskDefTaskRole1EDB4A67" + ] + }, + "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingLowerAlarm20C30A06": { + "Type": "AWS::CloudWatch::Alarm", + "Properties": { + "AlarmActions": [ + { + "Ref": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingLowerPolicy332E2644" + } + ], + "AlarmDescription": "Lower threshold scaling alarm", + "ComparisonOperator": "LessThanOrEqualToThreshold", + "Dimensions": [ + { + "Name": "QueueName", + "Value": { + "Fn::GetAtt": [ + "QueueProcessingServiceEcsProcessingQueue552F0B37", + "QueueName" + ] + } + } + ], + "EvaluationPeriods": 1, + "MetricName": "ApproximateNumberOfMessagesVisible", + "Namespace": "AWS/SQS", + "Period": 300, + "Statistic": "Maximum", + "Threshold": 0 + }, + "DependsOn": [ + "TaskDefTaskRoleDefaultPolicyA592CB18", + "TaskDefTaskRole1EDB4A67" + ] + }, + "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingUpperPolicy84DD739A": { + "Type": "AWS::ApplicationAutoScaling::ScalingPolicy", + "Properties": { + "PolicyName": "awsecspatternsqueueQueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingUpperPolicy23C5F983", + "PolicyType": "StepScaling", + "ScalingTargetId": { + "Ref": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetA9D54444" + }, + "StepScalingPolicyConfiguration": { + "AdjustmentType": "ChangeInCapacity", + "MetricAggregationType": "Maximum", + "StepAdjustments": [ + { + "MetricIntervalLowerBound": 0, + "MetricIntervalUpperBound": 400, + "ScalingAdjustment": 1 + }, + { + "MetricIntervalLowerBound": 400, + "ScalingAdjustment": 5 + } + ] + } + }, + "DependsOn": [ + "TaskDefTaskRoleDefaultPolicyA592CB18", + "TaskDefTaskRole1EDB4A67" + ] + }, + "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingUpperAlarm2660BEDF": { + "Type": "AWS::CloudWatch::Alarm", + "Properties": { + "AlarmActions": [ + { + "Ref": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingUpperPolicy84DD739A" + } + ], + "AlarmDescription": "Upper threshold scaling alarm", + "ComparisonOperator": "GreaterThanOrEqualToThreshold", + "Dimensions": [ + { + "Name": "QueueName", + "Value": { + "Fn::GetAtt": [ + "QueueProcessingServiceEcsProcessingQueue552F0B37", + "QueueName" + ] + } + } + ], + "EvaluationPeriods": 1, + "MetricName": "ApproximateNumberOfMessagesVisible", + "Namespace": "AWS/SQS", + "Period": 300, + "Statistic": "Maximum", + "Threshold": 100 + }, + "DependsOn": [ + "TaskDefTaskRoleDefaultPolicyA592CB18", + "TaskDefTaskRole1EDB4A67" + ] + }, + "EcsDefaultClusterMnL3mNNYNVPC9C1EC7A3": { + "Type": "AWS::ECS::Cluster" + } + }, + "Outputs": { + "QueueProcessingServiceSQSDeadLetterQueueE9058015": { + "Value": { + "Fn::GetAtt": [ + "QueueProcessingServiceEcsProcessingDeadLetterQueueD47A7C6B", + "QueueName" + ] + } + }, + "QueueProcessingServiceSQSDeadLetterQueueArnF7C6D3A8": { + "Value": { + "Fn::GetAtt": [ + "QueueProcessingServiceEcsProcessingDeadLetterQueueD47A7C6B", + "Arn" + ] + } + }, + "QueueProcessingServiceSQSQueue1AD9CD9C": { + "Value": { + "Fn::GetAtt": [ + "QueueProcessingServiceEcsProcessingQueue552F0B37", + "QueueName" + ] + } + }, + "QueueProcessingServiceSQSQueueArn8C4AE4AE": { + "Value": { + "Fn::GetAtt": [ + "QueueProcessingServiceEcsProcessingQueue552F0B37", + "Arn" + ] + } + } + }, + "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-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c5cb2e5de6344 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"35.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/integ.json new file mode 100644 index 0000000000000..b12f5a9bd497e --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "35.0.0", + "testCases": { + "taskDefinitionQueueProcessingFargateServiceTest/DefaultTest": { + "stacks": [ + "aws-ecs-patterns-queue" + ], + "assertionStack": "taskDefinitionQueueProcessingFargateServiceTest/DefaultTest/DeployAssert", + "assertionStackName": "taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/manifest.json new file mode 100644 index 0000000000000..42b2310f5959c --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/manifest.json @@ -0,0 +1,371 @@ +{ + "version": "35.0.0", + "artifacts": { + "aws-ecs-patterns-queue.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "aws-ecs-patterns-queue.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "aws-ecs-patterns-queue": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "aws-ecs-patterns-queue.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}/7bb9af94727d4a18ae0929321b0ef2f29cd6f89d6653d9676483f8edc1cf3edc.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "aws-ecs-patterns-queue.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-ecs-patterns-queue.assets" + ], + "metadata": { + "/aws-ecs-patterns-queue/VPC/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCB9E5F0B4" + } + ], + "/aws-ecs-patterns-queue/VPC/PublicSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1SubnetB4246D30" + } + ], + "/aws-ecs-patterns-queue/VPC/PublicSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1RouteTableFEE4B781" + } + ], + "/aws-ecs-patterns-queue/VPC/PublicSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1RouteTableAssociation0B0896DC" + } + ], + "/aws-ecs-patterns-queue/VPC/PublicSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1DefaultRoute91CEF279" + } + ], + "/aws-ecs-patterns-queue/VPC/PublicSubnet1/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1EIP6AD938E8" + } + ], + "/aws-ecs-patterns-queue/VPC/PublicSubnet1/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1NATGatewayE0556630" + } + ], + "/aws-ecs-patterns-queue/VPC/PublicSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2Subnet74179F39" + } + ], + "/aws-ecs-patterns-queue/VPC/PublicSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2RouteTable6F1A15F1" + } + ], + "/aws-ecs-patterns-queue/VPC/PublicSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2RouteTableAssociation5A808732" + } + ], + "/aws-ecs-patterns-queue/VPC/PublicSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2DefaultRouteB7481BBA" + } + ], + "/aws-ecs-patterns-queue/VPC/PublicSubnet2/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2EIP4947BC00" + } + ], + "/aws-ecs-patterns-queue/VPC/PublicSubnet2/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2NATGateway3C070193" + } + ], + "/aws-ecs-patterns-queue/VPC/PrivateSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1Subnet8BCA10E0" + } + ], + "/aws-ecs-patterns-queue/VPC/PrivateSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1RouteTableBE8A6027" + } + ], + "/aws-ecs-patterns-queue/VPC/PrivateSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1RouteTableAssociation347902D1" + } + ], + "/aws-ecs-patterns-queue/VPC/PrivateSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1DefaultRouteAE1D6490" + } + ], + "/aws-ecs-patterns-queue/VPC/PrivateSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + ], + "/aws-ecs-patterns-queue/VPC/PrivateSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2RouteTable0A19E10E" + } + ], + "/aws-ecs-patterns-queue/VPC/PrivateSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2RouteTableAssociation0C73D413" + } + ], + "/aws-ecs-patterns-queue/VPC/PrivateSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2DefaultRouteF4F5CFD2" + } + ], + "/aws-ecs-patterns-queue/VPC/IGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCIGWB7E252D3" + } + ], + "/aws-ecs-patterns-queue/VPC/VPCGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCVPCGW99B986DC" + } + ], + "/aws-ecs-patterns-queue/TaskDef/TaskRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "TaskDefTaskRole1EDB4A67" + } + ], + "/aws-ecs-patterns-queue/TaskDef/TaskRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "TaskDefTaskRoleDefaultPolicyA592CB18" + } + ], + "/aws-ecs-patterns-queue/TaskDef/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "TaskDef54694570" + } + ], + "/aws-ecs-patterns-queue/TaskDef/TheContainer/LogGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "TaskDefTheContainerLogGroupD94C8EF5" + } + ], + "/aws-ecs-patterns-queue/TaskDef/ExecutionRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "TaskDefExecutionRoleB4775C97" + } + ], + "/aws-ecs-patterns-queue/TaskDef/ExecutionRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "TaskDefExecutionRoleDefaultPolicy0DBB737A" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/EcsProcessingDeadLetterQueue/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceEcsProcessingDeadLetterQueueD47A7C6B" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/EcsProcessingQueue/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceEcsProcessingQueue552F0B37" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/SQSDeadLetterQueue": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceSQSDeadLetterQueueE9058015" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/SQSDeadLetterQueueArn": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceSQSDeadLetterQueueArnF7C6D3A8" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/SQSQueue": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceSQSQueue1AD9CD9C" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/SQSQueueArn": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceSQSQueueArn8C4AE4AE" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/Service": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceQueueProcessingFargateService0340DB9F" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/SecurityGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceQueueProcessingFargateServiceSecurityGroup8FDF413D" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetA9D54444" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/CpuScaling/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetCpuScaling330150E9" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/QueueMessagesVisibleScaling/LowerPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingLowerPolicy332E2644" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/QueueMessagesVisibleScaling/LowerAlarm/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingLowerAlarm20C30A06" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/QueueMessagesVisibleScaling/UpperPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingUpperPolicy84DD739A" + } + ], + "/aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/QueueMessagesVisibleScaling/UpperAlarm/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingUpperAlarm2660BEDF" + } + ], + "/aws-ecs-patterns-queue/EcsDefaultClusterMnL3mNNYNVPC/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "EcsDefaultClusterMnL3mNNYNVPC9C1EC7A3" + } + ], + "/aws-ecs-patterns-queue/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-ecs-patterns-queue/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "aws-ecs-patterns-queue" + }, + "taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.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": [ + "taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.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": [ + "taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.assets" + ], + "metadata": { + "/taskDefinitionQueueProcessingFargateServiceTest/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/taskDefinitionQueueProcessingFargateServiceTest/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "taskDefinitionQueueProcessingFargateServiceTest/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-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.assets.json new file mode 100644 index 0000000000000..2e718fe2e5943 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.assets.json @@ -0,0 +1,19 @@ +{ + "version": "35.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.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-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/taskDefinitionQueueProcessingFargateServiceTestDefaultTestDeployAssert406F467D.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-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/tree.json new file mode 100644 index 0000000000000..ef3e857462320 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.js.snapshot/tree.json @@ -0,0 +1,1600 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "aws-ecs-patterns-queue": { + "id": "aws-ecs-patterns-queue", + "path": "aws-ecs-patterns-queue", + "children": { + "VPC": { + "id": "VPC", + "path": "aws-ecs-patterns-queue/VPC", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/VPC/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPC", + "aws:cdk:cloudformation:props": { + "cidrBlock": "10.0.0.0/16", + "enableDnsHostnames": true, + "enableDnsSupport": true, + "instanceTenancy": "default", + "tags": [ + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPC", + "version": "0.0.0" + } + }, + "PublicSubnet1": { + "id": "PublicSubnet1", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.0.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + }, + "subnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "routeTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet1/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet1/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "allocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId" + ] + }, + "subnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + }, + "tags": [ + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PublicSubnet2": { + "id": "PublicSubnet2", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.64.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + }, + "subnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "routeTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet2/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "aws-ecs-patterns-queue/VPC/PublicSubnet2/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "allocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId" + ] + }, + "subnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + }, + "tags": [ + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet1": { + "id": "PrivateSubnet1", + "path": "aws-ecs-patterns-queue/VPC/PrivateSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "aws-ecs-patterns-queue/VPC/PrivateSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.128.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC/PrivateSubnet1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "aws-ecs-patterns-queue/VPC/PrivateSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "aws-ecs-patterns-queue/VPC/PrivateSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC/PrivateSubnet1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "aws-ecs-patterns-queue/VPC/PrivateSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + }, + "subnetId": { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "aws-ecs-patterns-queue/VPC/PrivateSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VPCPublicSubnet1NATGatewayE0556630" + }, + "routeTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet2": { + "id": "PrivateSubnet2", + "path": "aws-ecs-patterns-queue/VPC/PrivateSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "aws-ecs-patterns-queue/VPC/PrivateSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.192.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC/PrivateSubnet2" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "aws-ecs-patterns-queue/VPC/PrivateSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "aws-ecs-patterns-queue/VPC/PrivateSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC/PrivateSubnet2" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "aws-ecs-patterns-queue/VPC/PrivateSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + }, + "subnetId": { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "aws-ecs-patterns-queue/VPC/PrivateSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VPCPublicSubnet2NATGateway3C070193" + }, + "routeTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "IGW": { + "id": "IGW", + "path": "aws-ecs-patterns-queue/VPC/IGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::InternetGateway", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "aws-ecs-patterns-queue/VPC" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnInternetGateway", + "version": "0.0.0" + } + }, + "VPCGW": { + "id": "VPCGW", + "path": "aws-ecs-patterns-queue/VPC/VPCGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCGatewayAttachment", + "aws:cdk:cloudformation:props": { + "internetGatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPCGatewayAttachment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.Vpc", + "version": "0.0.0" + } + }, + "TaskDef": { + "id": "TaskDef", + "path": "aws-ecs-patterns-queue/TaskDef", + "children": { + "TaskRole": { + "id": "TaskRole", + "path": "aws-ecs-patterns-queue/TaskDef/TaskRole", + "children": { + "ImportTaskRole": { + "id": "ImportTaskRole", + "path": "aws-ecs-patterns-queue/TaskDef/TaskRole/ImportTaskRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/TaskDef/TaskRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ecs-tasks.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "aws-ecs-patterns-queue/TaskDef/TaskRole/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/TaskDef/TaskRole/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": [ + "sqs:ChangeMessageVisibility", + "sqs:DeleteMessage", + "sqs:GetQueueAttributes", + "sqs:GetQueueUrl", + "sqs:ReceiveMessage" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "QueueProcessingServiceEcsProcessingQueue552F0B37", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "TaskDefTaskRoleDefaultPolicyA592CB18", + "roles": [ + { + "Ref": "TaskDefTaskRole1EDB4A67" + } + ] + } + }, + "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": "aws-ecs-patterns-queue/TaskDef/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ECS::TaskDefinition", + "aws:cdk:cloudformation:props": { + "containerDefinitions": [ + { + "essential": true, + "image": { + "Fn::Sub": "${AWS::AccountId}.dkr.ecr.${AWS::Region}.${AWS::URLSuffix}/cdk-hnb659fds-container-assets-${AWS::AccountId}-${AWS::Region}:95cefedd43575452a70cdeeeceb0f1c5728fd58c9ff8e81e760c3dac33c46417" + }, + "name": "TheContainer", + "logConfiguration": { + "logDriver": "awslogs", + "options": { + "awslogs-group": { + "Ref": "TaskDefTheContainerLogGroupD94C8EF5" + }, + "awslogs-stream-prefix": "QueueProcessingFargateService", + "awslogs-region": { + "Ref": "AWS::Region" + } + } + } + } + ], + "cpu": "512", + "ephemeralStorage": { + "sizeInGiB": 30 + }, + "executionRoleArn": { + "Fn::GetAtt": [ + "TaskDefExecutionRoleB4775C97", + "Arn" + ] + }, + "family": "awsecspatternsqueueTaskDefD9E658F3", + "memory": "1024", + "networkMode": "awsvpc", + "requiresCompatibilities": [ + "FARGATE" + ], + "taskRoleArn": { + "Fn::GetAtt": [ + "TaskDefTaskRole1EDB4A67", + "Arn" + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ecs.CfnTaskDefinition", + "version": "0.0.0" + } + }, + "TheContainer": { + "id": "TheContainer", + "path": "aws-ecs-patterns-queue/TaskDef/TheContainer", + "children": { + "AssetImage": { + "id": "AssetImage", + "path": "aws-ecs-patterns-queue/TaskDef/TheContainer/AssetImage", + "children": { + "Staging": { + "id": "Staging", + "path": "aws-ecs-patterns-queue/TaskDef/TheContainer/AssetImage/Staging", + "constructInfo": { + "fqn": "aws-cdk-lib.AssetStaging", + "version": "0.0.0" + } + }, + "Repository": { + "id": "Repository", + "path": "aws-ecs-patterns-queue/TaskDef/TheContainer/AssetImage/Repository", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ecr.RepositoryBase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ecr_assets.DockerImageAsset", + "version": "0.0.0" + } + }, + "LogGroup": { + "id": "LogGroup", + "path": "aws-ecs-patterns-queue/TaskDef/TheContainer/LogGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/TaskDef/TheContainer/LogGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Logs::LogGroup", + "aws:cdk:cloudformation:props": {} + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_logs.CfnLogGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_logs.LogGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ecs.ContainerDefinition", + "version": "0.0.0" + } + }, + "ExecutionRole": { + "id": "ExecutionRole", + "path": "aws-ecs-patterns-queue/TaskDef/ExecutionRole", + "children": { + "ImportExecutionRole": { + "id": "ImportExecutionRole", + "path": "aws-ecs-patterns-queue/TaskDef/ExecutionRole/ImportExecutionRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/TaskDef/ExecutionRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ecs-tasks.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "aws-ecs-patterns-queue/TaskDef/ExecutionRole/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/TaskDef/ExecutionRole/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": [ + "ecr:BatchCheckLayerAvailability", + "ecr:BatchGetImage", + "ecr:GetDownloadUrlForLayer" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":ecr:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":repository/", + { + "Fn::Sub": "cdk-hnb659fds-container-assets-${AWS::AccountId}-${AWS::Region}" + } + ] + ] + } + }, + { + "Action": "ecr:GetAuthorizationToken", + "Effect": "Allow", + "Resource": "*" + }, + { + "Action": [ + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "TaskDefTheContainerLogGroupD94C8EF5", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "TaskDefExecutionRoleDefaultPolicy0DBB737A", + "roles": [ + { + "Ref": "TaskDefExecutionRoleB4775C97" + } + ] + } + }, + "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_ecs.FargateTaskDefinition", + "version": "0.0.0" + } + }, + "QueueProcessingService": { + "id": "QueueProcessingService", + "path": "aws-ecs-patterns-queue/QueueProcessingService", + "children": { + "EcsProcessingDeadLetterQueue": { + "id": "EcsProcessingDeadLetterQueue", + "path": "aws-ecs-patterns-queue/QueueProcessingService/EcsProcessingDeadLetterQueue", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/QueueProcessingService/EcsProcessingDeadLetterQueue/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::SQS::Queue", + "aws:cdk:cloudformation:props": { + "messageRetentionPeriod": 1209600 + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_sqs.CfnQueue", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_sqs.Queue", + "version": "0.0.0" + } + }, + "EcsProcessingQueue": { + "id": "EcsProcessingQueue", + "path": "aws-ecs-patterns-queue/QueueProcessingService/EcsProcessingQueue", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/QueueProcessingService/EcsProcessingQueue/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::SQS::Queue", + "aws:cdk:cloudformation:props": { + "redrivePolicy": { + "deadLetterTargetArn": { + "Fn::GetAtt": [ + "QueueProcessingServiceEcsProcessingDeadLetterQueueD47A7C6B", + "Arn" + ] + }, + "maxReceiveCount": 3 + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_sqs.CfnQueue", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_sqs.Queue", + "version": "0.0.0" + } + }, + "SQSDeadLetterQueue": { + "id": "SQSDeadLetterQueue", + "path": "aws-ecs-patterns-queue/QueueProcessingService/SQSDeadLetterQueue", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "SQSDeadLetterQueueArn": { + "id": "SQSDeadLetterQueueArn", + "path": "aws-ecs-patterns-queue/QueueProcessingService/SQSDeadLetterQueueArn", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "SQSQueue": { + "id": "SQSQueue", + "path": "aws-ecs-patterns-queue/QueueProcessingService/SQSQueue", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "SQSQueueArn": { + "id": "SQSQueueArn", + "path": "aws-ecs-patterns-queue/QueueProcessingService/SQSQueueArn", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + }, + "QueueProcessingFargateService": { + "id": "QueueProcessingFargateService", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService", + "children": { + "Service": { + "id": "Service", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/Service", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ECS::Service", + "aws:cdk:cloudformation:props": { + "cluster": { + "Ref": "EcsDefaultClusterMnL3mNNYNVPC9C1EC7A3" + }, + "deploymentConfiguration": { + "maximumPercent": 200, + "minimumHealthyPercent": 50, + "alarms": { + "alarmNames": [], + "enable": false, + "rollback": false + } + }, + "enableEcsManagedTags": false, + "launchType": "FARGATE", + "networkConfiguration": { + "awsvpcConfiguration": { + "assignPublicIp": "DISABLED", + "subnets": [ + { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + }, + { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + ], + "securityGroups": [ + { + "Fn::GetAtt": [ + "QueueProcessingServiceQueueProcessingFargateServiceSecurityGroup8FDF413D", + "GroupId" + ] + } + ] + } + }, + "taskDefinition": { + "Ref": "TaskDef54694570" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ecs.CfnService", + "version": "0.0.0" + } + }, + "SecurityGroup": { + "id": "SecurityGroup", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/SecurityGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/SecurityGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/SecurityGroup", + "securityGroupEgress": [ + { + "cidrIp": "0.0.0.0/0", + "description": "Allow all outbound traffic by default", + "ipProtocol": "-1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", + "version": "0.0.0" + } + }, + "ScalingRole": { + "id": "ScalingRole", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/ScalingRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "TaskCount": { + "id": "TaskCount", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount", + "children": { + "Target": { + "id": "Target", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApplicationAutoScaling::ScalableTarget", + "aws:cdk:cloudformation:props": { + "maxCapacity": 2, + "minCapacity": 1, + "resourceId": { + "Fn::Join": [ + "", + [ + "service/", + { + "Ref": "EcsDefaultClusterMnL3mNNYNVPC9C1EC7A3" + }, + "/", + { + "Fn::GetAtt": [ + "QueueProcessingServiceQueueProcessingFargateService0340DB9F", + "Name" + ] + } + ] + ] + }, + "roleArn": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::", + { + "Ref": "AWS::AccountId" + }, + ":role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService" + ] + ] + }, + "scalableDimension": "ecs:service:DesiredCount", + "serviceNamespace": "ecs" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_applicationautoscaling.CfnScalableTarget", + "version": "0.0.0" + } + }, + "CpuScaling": { + "id": "CpuScaling", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/CpuScaling", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/CpuScaling/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApplicationAutoScaling::ScalingPolicy", + "aws:cdk:cloudformation:props": { + "policyName": "awsecspatternsqueueQueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetCpuScaling374CE648", + "policyType": "TargetTrackingScaling", + "scalingTargetId": { + "Ref": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetA9D54444" + }, + "targetTrackingScalingPolicyConfiguration": { + "predefinedMetricSpecification": { + "predefinedMetricType": "ECSServiceAverageCPUUtilization" + }, + "targetValue": 50 + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_applicationautoscaling.CfnScalingPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_applicationautoscaling.TargetTrackingScalingPolicy", + "version": "0.0.0" + } + }, + "QueueMessagesVisibleScaling": { + "id": "QueueMessagesVisibleScaling", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/QueueMessagesVisibleScaling", + "children": { + "LowerPolicy": { + "id": "LowerPolicy", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/QueueMessagesVisibleScaling/LowerPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/QueueMessagesVisibleScaling/LowerPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApplicationAutoScaling::ScalingPolicy", + "aws:cdk:cloudformation:props": { + "policyName": "awsecspatternsqueueQueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingLowerPolicy74582401", + "policyType": "StepScaling", + "scalingTargetId": { + "Ref": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetA9D54444" + }, + "stepScalingPolicyConfiguration": { + "adjustmentType": "ChangeInCapacity", + "metricAggregationType": "Maximum", + "stepAdjustments": [ + { + "metricIntervalUpperBound": 0, + "scalingAdjustment": -1 + } + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_applicationautoscaling.CfnScalingPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_applicationautoscaling.StepScalingAction", + "version": "0.0.0" + } + }, + "LowerAlarm": { + "id": "LowerAlarm", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/QueueMessagesVisibleScaling/LowerAlarm", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/QueueMessagesVisibleScaling/LowerAlarm/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudWatch::Alarm", + "aws:cdk:cloudformation:props": { + "alarmActions": [ + { + "Ref": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingLowerPolicy332E2644" + } + ], + "alarmDescription": "Lower threshold scaling alarm", + "comparisonOperator": "LessThanOrEqualToThreshold", + "dimensions": [ + { + "name": "QueueName", + "value": { + "Fn::GetAtt": [ + "QueueProcessingServiceEcsProcessingQueue552F0B37", + "QueueName" + ] + } + } + ], + "evaluationPeriods": 1, + "metricName": "ApproximateNumberOfMessagesVisible", + "namespace": "AWS/SQS", + "period": 300, + "statistic": "Maximum", + "threshold": 0 + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudwatch.CfnAlarm", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudwatch.Alarm", + "version": "0.0.0" + } + }, + "UpperPolicy": { + "id": "UpperPolicy", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/QueueMessagesVisibleScaling/UpperPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/QueueMessagesVisibleScaling/UpperPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApplicationAutoScaling::ScalingPolicy", + "aws:cdk:cloudformation:props": { + "policyName": "awsecspatternsqueueQueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingUpperPolicy23C5F983", + "policyType": "StepScaling", + "scalingTargetId": { + "Ref": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetA9D54444" + }, + "stepScalingPolicyConfiguration": { + "adjustmentType": "ChangeInCapacity", + "metricAggregationType": "Maximum", + "stepAdjustments": [ + { + "metricIntervalLowerBound": 0, + "metricIntervalUpperBound": 400, + "scalingAdjustment": 1 + }, + { + "metricIntervalLowerBound": 400, + "scalingAdjustment": 5 + } + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_applicationautoscaling.CfnScalingPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_applicationautoscaling.StepScalingAction", + "version": "0.0.0" + } + }, + "UpperAlarm": { + "id": "UpperAlarm", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/QueueMessagesVisibleScaling/UpperAlarm", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/QueueProcessingService/QueueProcessingFargateService/TaskCount/Target/QueueMessagesVisibleScaling/UpperAlarm/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::CloudWatch::Alarm", + "aws:cdk:cloudformation:props": { + "alarmActions": [ + { + "Ref": "QueueProcessingServiceQueueProcessingFargateServiceTaskCountTargetQueueMessagesVisibleScalingUpperPolicy84DD739A" + } + ], + "alarmDescription": "Upper threshold scaling alarm", + "comparisonOperator": "GreaterThanOrEqualToThreshold", + "dimensions": [ + { + "name": "QueueName", + "value": { + "Fn::GetAtt": [ + "QueueProcessingServiceEcsProcessingQueue552F0B37", + "QueueName" + ] + } + } + ], + "evaluationPeriods": 1, + "metricName": "ApproximateNumberOfMessagesVisible", + "namespace": "AWS/SQS", + "period": 300, + "statistic": "Maximum", + "threshold": 100 + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudwatch.CfnAlarm", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_cloudwatch.Alarm", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_applicationautoscaling.StepScalingPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_applicationautoscaling.ScalableTarget", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ecs.ScalableTaskCount", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ecs.FargateService", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ecs_patterns.QueueProcessingFargateService", + "version": "0.0.0" + } + }, + "EcsDefaultClusterMnL3mNNYNVPC": { + "id": "EcsDefaultClusterMnL3mNNYNVPC", + "path": "aws-ecs-patterns-queue/EcsDefaultClusterMnL3mNNYNVPC", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-ecs-patterns-queue/EcsDefaultClusterMnL3mNNYNVPC/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ECS::Cluster", + "aws:cdk:cloudformation:props": {} + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ecs.CfnCluster", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ecs.Cluster", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "aws-ecs-patterns-queue/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "aws-ecs-patterns-queue/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "taskDefinitionQueueProcessingFargateServiceTest": { + "id": "taskDefinitionQueueProcessingFargateServiceTest", + "path": "taskDefinitionQueueProcessingFargateServiceTest", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "taskDefinitionQueueProcessingFargateServiceTest/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "taskDefinitionQueueProcessingFargateServiceTest/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "taskDefinitionQueueProcessingFargateServiceTest/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "taskDefinitionQueueProcessingFargateServiceTest/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "taskDefinitionQueueProcessingFargateServiceTest/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-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.ts new file mode 100644 index 0000000000000..422c409311809 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ecs-patterns/test/fargate/integ.queue-processing-fargate-service-task-definition.ts @@ -0,0 +1,35 @@ +import * as path from 'path'; +import * as ec2 from 'aws-cdk-lib/aws-ec2'; +import * as ecs from 'aws-cdk-lib/aws-ecs'; +import { App, Stack } from 'aws-cdk-lib'; +import * as integ from '@aws-cdk/integ-tests-alpha'; +import { QueueProcessingFargateService } from 'aws-cdk-lib/aws-ecs-patterns'; + +const app = new App(); +const stack = new Stack(app, 'aws-ecs-patterns-queue'); +const vpc = new ec2.Vpc(stack, 'VPC', { + restrictDefaultSecurityGroup: false, + maxAzs: 2, +}); + +const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef', { + memoryLimitMiB: 1024, + cpu: 512, + ephemeralStorageGiB: 30, +}); + +taskDefinition.addContainer('TheContainer', { + image: new ecs.AssetImage(path.join(__dirname, '..', 'sqs-reader')), + logging: new ecs.AwsLogDriver({ streamPrefix: 'QueueProcessingFargateService' }), +}); + +new QueueProcessingFargateService(stack, 'QueueProcessingService', { + vpc, + taskDefinition, +}); + +new integ.IntegTest(app, 'taskDefinitionQueueProcessingFargateServiceTest', { + testCases: [stack], +}); + +app.synth(); From 1c65716cae49cd698f4b716f5ea80ccebe8fd915 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Sun, 10 Dec 2023 12:33:41 +0900 Subject: [PATCH 05/13] fix(ecs-patterns): linter --- .../lib/base/queue-processing-service-base.ts | 8 +------- .../lib/ecs/queue-processing-ecs-service.ts | 8 +++++++- .../lib/fargate/queue-processing-fargate-service.ts | 12 ++++++++++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts index e3e4884d4a631..02d6c75ae1891 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts @@ -2,7 +2,7 @@ import { Construct } from 'constructs'; import { ScalingInterval } from '../../../aws-applicationautoscaling'; import { IVpc } from '../../../aws-ec2'; import { - AwsLogDriver, BaseService, CapacityProviderStrategy, Cluster, ContainerImage, DeploymentController, DeploymentCircuitBreaker, + AwsLogDriver, BaseService, CapacityProviderStrategy, Cluster, DeploymentController, DeploymentCircuitBreaker, ICluster, LogDriver, PropagatedTagSource, Secret, } from '../../../aws-ecs'; import { IQueue, Queue } from '../../../aws-sqs'; @@ -36,12 +36,6 @@ export interface QueueProcessingServiceBaseProps { */ readonly vpc?: IVpc; - /** - * The image used to start a container. - * Image or taskDefinition must be specified, but not both. - */ - readonly image?: ContainerImage; - /** * The command that is passed to the container. * diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts index fa53d91f0898d..8a9b8983455a2 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts @@ -1,5 +1,5 @@ import { Construct } from 'constructs'; -import { Ec2Service, Ec2TaskDefinition, PlacementConstraint, PlacementStrategy } from '../../../aws-ecs'; +import { ContainerImage, Ec2Service, Ec2TaskDefinition, PlacementConstraint, PlacementStrategy } from '../../../aws-ecs'; import { FeatureFlags } from '../../../core'; import * as cxapi from '../../../cx-api'; import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../base/queue-processing-service-base'; @@ -8,6 +8,12 @@ import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../ * The properties for the QueueProcessingEc2Service service. */ export interface QueueProcessingEc2ServiceProps extends QueueProcessingServiceBaseProps { + /** + * The image used to start a container. + * + */ + readonly image: ContainerImage; + /** * The number of cpu units used by the task. * diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts index 7eb5886c6e3ee..adac20f8e5551 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts @@ -1,6 +1,6 @@ import { Construct } from 'constructs'; import * as ec2 from '../../../aws-ec2'; -import { FargateService, FargateTaskDefinition, HealthCheck } from '../../../aws-ecs'; +import { ContainerImage, FargateService, FargateTaskDefinition, HealthCheck } from '../../../aws-ecs'; import { FeatureFlags } from '../../../core'; import * as cxapi from '../../../cx-api'; import { FargateServiceBaseProps } from '../base/fargate-service-base'; @@ -10,6 +10,14 @@ import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../ * The properties for the QueueProcessingFargateService service. */ export interface QueueProcessingFargateServiceProps extends QueueProcessingServiceBaseProps, FargateServiceBaseProps { + /** + * The image used to start a container. + * Image or taskDefinition must be specified, but not both. + * + * @default - none + */ + readonly image?: ContainerImage; + /** * Optional name for the container added. * This name is not used when `taskDefinition` is provided. @@ -65,7 +73,7 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase { /** * Constructs a new instance of the QueueProcessingFargateService class. */ - constructor(scope: Construct, id: string, props: QueueProcessingFargateServiceProps) { + constructor(scope: Construct, id: string, props: QueueProcessingFargateServiceProps = {}) { super(scope, id, props); if (props.taskDefinition != null && props.image != null) { From b2645c596ca4f32a864aeb18f512fa2a687c4843 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Sun, 10 Dec 2023 21:51:39 +0900 Subject: [PATCH 06/13] refactor(ecs-patterns): Removed breaking changes in image definition in queue-processing-service-base.ts --- .../lib/base/queue-processing-service-base.ts | 15 ++++++++++++++- .../fargate/queue-processing-fargate-service.ts | 8 -------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts index 02d6c75ae1891..54d6463b6655e 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts @@ -2,7 +2,7 @@ import { Construct } from 'constructs'; import { ScalingInterval } from '../../../aws-applicationautoscaling'; import { IVpc } from '../../../aws-ec2'; import { - AwsLogDriver, BaseService, CapacityProviderStrategy, Cluster, DeploymentController, DeploymentCircuitBreaker, + AwsLogDriver, BaseService, CapacityProviderStrategy, Cluster, ContainerImage, DeploymentController, DeploymentCircuitBreaker, ICluster, LogDriver, PropagatedTagSource, Secret, } from '../../../aws-ecs'; import { IQueue, Queue } from '../../../aws-sqs'; @@ -36,6 +36,19 @@ export interface QueueProcessingServiceBaseProps { */ readonly vpc?: IVpc; + /** + * The image used to start a container. + * + * For QueueProcessingFargateService: + * Either 'image' or 'taskDefinition' must be specified, but not both. + * + * For QueueProcessingEc2Service: + * 'image' is required and must be specified. + * + * @default - none + */ + readonly image?: ContainerImage; + /** * The command that is passed to the container. * diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts index adac20f8e5551..0e5632b424e54 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts @@ -10,14 +10,6 @@ import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../ * The properties for the QueueProcessingFargateService service. */ export interface QueueProcessingFargateServiceProps extends QueueProcessingServiceBaseProps, FargateServiceBaseProps { - /** - * The image used to start a container. - * Image or taskDefinition must be specified, but not both. - * - * @default - none - */ - readonly image?: ContainerImage; - /** * Optional name for the container added. * This name is not used when `taskDefinition` is provided. From 9907ed701589ba061e50cc23abbb7d9031f49c0b Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Sun, 10 Dec 2023 22:17:27 +0900 Subject: [PATCH 07/13] fix: build --- .../lib/ecs/queue-processing-ecs-service.ts | 16 ++++++++-------- .../fargate/queue-processing-fargate-service.ts | 2 +- .../queue-processing-fargate-service.test.ts | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts index 8a9b8983455a2..3ba1664c34b42 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts @@ -1,5 +1,5 @@ import { Construct } from 'constructs'; -import { ContainerImage, Ec2Service, Ec2TaskDefinition, PlacementConstraint, PlacementStrategy } from '../../../aws-ecs'; +import { Ec2Service, Ec2TaskDefinition, PlacementConstraint, PlacementStrategy } from '../../../aws-ecs'; import { FeatureFlags } from '../../../core'; import * as cxapi from '../../../cx-api'; import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../base/queue-processing-service-base'; @@ -8,12 +8,6 @@ import { QueueProcessingServiceBase, QueueProcessingServiceBaseProps } from '../ * The properties for the QueueProcessingEc2Service service. */ export interface QueueProcessingEc2ServiceProps extends QueueProcessingServiceBaseProps { - /** - * The image used to start a container. - * - */ - readonly image: ContainerImage; - /** * The number of cpu units used by the task. * @@ -109,9 +103,15 @@ export class QueueProcessingEc2Service extends QueueProcessingServiceBase { /** * Constructs a new instance of the QueueProcessingEc2Service class. */ - constructor(scope: Construct, id: string, props: QueueProcessingEc2ServiceProps) { + constructor(scope: Construct, id: string, props: QueueProcessingEc2ServiceProps = {}) { super(scope, id, props); + // In the queueProcessingFargateService, props.image is optional, which is why image is optional in the queue-processing-service-base.ts. + // However, in the queueProcessingEcsService, image is mandatory, so null checks have been introduced. + if (props.image == null) { + throw new Error('Cannot create a QueueProcessingEc2Service with props.image is undefined'); + } + const containerName = props.containerName ?? 'QueueProcessingContainer'; // Create a Task Definition for the container to start diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts index 0e5632b424e54..68e61462fced5 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts @@ -1,6 +1,6 @@ import { Construct } from 'constructs'; import * as ec2 from '../../../aws-ec2'; -import { ContainerImage, FargateService, FargateTaskDefinition, HealthCheck } from '../../../aws-ecs'; +import { FargateService, FargateTaskDefinition, HealthCheck } from '../../../aws-ecs'; import { FeatureFlags } from '../../../core'; import * as cxapi from '../../../cx-api'; import { FargateServiceBaseProps } from '../base/fargate-service-base'; diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts index b95a132862274..c21fb0ac370e1 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts @@ -781,6 +781,7 @@ test('test Fargate queue worker service construct - with task definition', () => Family: 'TaskDef', Memory: '1024', Cpu: '512', + Test: {}, EphemeralStorage: { SizeInGiB: 30, }, From d516b15a6c24919d1c2a24625181eeecf5a97cc9 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Sun, 10 Dec 2023 22:57:41 +0900 Subject: [PATCH 08/13] fix: queue-processing-fargate-service.test.ts --- .../test/fargate/queue-processing-fargate-service.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts index c21fb0ac370e1..c0fe1ffc86bef 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts @@ -781,9 +781,11 @@ test('test Fargate queue worker service construct - with task definition', () => Family: 'TaskDef', Memory: '1024', Cpu: '512', - Test: {}, EphemeralStorage: { SizeInGiB: 30, }, + NetworkMode: 'awsvpc', + RequiresCompatibilities: ['FARGATE'], + TaskRoleArn: { 'Fn::GetAtt': ['TaskDefTaskRole1EDB4A67', 'Arn'] }, }); }); From a5de76b20682fc464cf7fb6f0b8fd85a8cba2447 Mon Sep 17 00:00:00 2001 From: kazuho cryer-shinozuka Date: Mon, 11 Dec 2023 23:23:11 +0900 Subject: [PATCH 09/13] Update packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts Co-authored-by: Luca Pizzini --- .../lib/fargate/queue-processing-fargate-service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts index 68e61462fced5..f2f26d5e8669d 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/fargate/queue-processing-fargate-service.ts @@ -68,11 +68,11 @@ export class QueueProcessingFargateService extends QueueProcessingServiceBase { constructor(scope: Construct, id: string, props: QueueProcessingFargateServiceProps = {}) { super(scope, id, props); - if (props.taskDefinition != null && props.image != null) { - throw new Error('You must specify only one of TaskDefinition or Image'); - } else if (props.taskDefinition != null) { + if (props.taskDefinition && props.image) { + throw new Error('You must specify only one of taskDefinition or image'); + } else if (props.taskDefinition) { this.taskDefinition = props.taskDefinition; - } else if (props.image != null) { + } else if (props.image) { // Create a Task Definition for the container to start this.taskDefinition = new FargateTaskDefinition(this, 'QueueProcessingTaskDef', { memoryLimitMiB: props.memoryLimitMiB || 512, From 0c999c921f13aeb014769c50b5b763f8c32b948e Mon Sep 17 00:00:00 2001 From: kazuho cryer-shinozuka Date: Mon, 11 Dec 2023 23:23:55 +0900 Subject: [PATCH 10/13] Update packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts Co-authored-by: Luca Pizzini --- .../lib/ecs/queue-processing-ecs-service.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts index 3ba1664c34b42..8ddce9b40419d 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/ecs/queue-processing-ecs-service.ts @@ -106,10 +106,8 @@ export class QueueProcessingEc2Service extends QueueProcessingServiceBase { constructor(scope: Construct, id: string, props: QueueProcessingEc2ServiceProps = {}) { super(scope, id, props); - // In the queueProcessingFargateService, props.image is optional, which is why image is optional in the queue-processing-service-base.ts. - // However, in the queueProcessingEcsService, image is mandatory, so null checks have been introduced. - if (props.image == null) { - throw new Error('Cannot create a QueueProcessingEc2Service with props.image is undefined'); + if (!props.image) { + throw new Error('image must be specified for EC2 queue processing service'); } const containerName = props.containerName ?? 'QueueProcessingContainer'; From 0d602835a99a4315b96e070191221155d4a2e769 Mon Sep 17 00:00:00 2001 From: kazuho cryer-shinozuka Date: Mon, 11 Dec 2023 23:24:08 +0900 Subject: [PATCH 11/13] Update packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts Co-authored-by: Luca Pizzini --- .../lib/base/queue-processing-service-base.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts index 54d6463b6655e..486a2315b1778 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts @@ -39,13 +39,10 @@ export interface QueueProcessingServiceBaseProps { /** * The image used to start a container. * - * For QueueProcessingFargateService: - * Either 'image' or 'taskDefinition' must be specified, but not both. + * For `QueueProcessingFargateService`, either `image` or `taskDefinition` must be specified, but not both. + * For QueueProcessingEc2Service, `image` is required. * - * For QueueProcessingEc2Service: - * 'image' is required and must be specified. - * - * @default - none + * @default - the image of the task definition is used for Fargate, required otherwise */ readonly image?: ContainerImage; From 296c1366ffba4a1cf64daabc89dfcc7e48da8ad4 Mon Sep 17 00:00:00 2001 From: Kazuho CryerShinozuka Date: Mon, 11 Dec 2023 23:44:21 +0900 Subject: [PATCH 12/13] test: add test --- .../ec2/queue-processing-ecs-service.test.ts | 13 +++++++ .../queue-processing-fargate-service.test.ts | 37 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/queue-processing-ecs-service.test.ts b/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/queue-processing-ecs-service.test.ts index 7be7e67aa95c5..66844caceb3bd 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/queue-processing-ecs-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/test/ec2/queue-processing-ecs-service.test.ts @@ -568,3 +568,16 @@ it('throws validation errors of the specific queue prop, when setting queue and }); }).toThrow(new Error('visibilityTimeout can be set only when queue is not set. Specify them in the QueueProps of the queue')); }); + +test('throws if image is undefined', () => { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'VPC'); + // WHEN + expect(() => { + new ecsPatterns.QueueProcessingEc2Service(stack, 'Service', { + cluster: new ecs.Cluster(stack, 'Cluster', { vpc }), + memoryLimitMiB: 512, + }); + }).toThrow(new Error('image must be specified for EC2 queue processing service')); +}); \ No newline at end of file diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts index c0fe1ffc86bef..3af988aa0bdc1 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/test/fargate/queue-processing-fargate-service.test.ts @@ -789,3 +789,40 @@ test('test Fargate queue worker service construct - with task definition', () => TaskRoleArn: { 'Fn::GetAtt': ['TaskDefTaskRole1EDB4A67', 'Arn'] }, }); }); + +test('test Fargate queue worker service construct - with task definition and image', () => { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'VPC'); + + // WHEN + const taskDefinition = new ecs.FargateTaskDefinition(stack, 'TaskDef', { + memoryLimitMiB: 1024, + cpu: 512, + ephemeralStorageGiB: 30, + }); + taskDefinition.addContainer('QueueProcessingContainer', { + image: ecs.ContainerImage.fromRegistry('test'), + }); + + expect(() => { + new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { + vpc, + taskDefinition, + image: ecs.ContainerImage.fromRegistry('test'), + }); + }).toThrow(new Error('You must specify only one of taskDefinition or image')); +}); + +test('test Fargate queue worker service construct - with no taskDefinition or image', () => { + // GIVEN + const stack = new cdk.Stack(); + const vpc = new ec2.Vpc(stack, 'VPC'); + + expect(() => { + new ecsPatterns.QueueProcessingFargateService(stack, 'Service', { + vpc, + }); + }).toThrow(new Error('You must specify one of: taskDefinition or image')); +}); + From 7a29244fbbc0407811adae2934d359b878a2c0d2 Mon Sep 17 00:00:00 2001 From: kazuho cryer-shinozuka Date: Tue, 12 Dec 2023 01:09:02 +0900 Subject: [PATCH 13/13] Update packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts Co-authored-by: Luca Pizzini --- .../aws-ecs-patterns/lib/base/queue-processing-service-base.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts index 486a2315b1778..0393b391076e7 100644 --- a/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts +++ b/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/queue-processing-service-base.ts @@ -40,7 +40,7 @@ export interface QueueProcessingServiceBaseProps { * The image used to start a container. * * For `QueueProcessingFargateService`, either `image` or `taskDefinition` must be specified, but not both. - * For QueueProcessingEc2Service, `image` is required. + * For `QueueProcessingEc2Service`, `image` is required. * * @default - the image of the task definition is used for Fargate, required otherwise */