Describe the bug
I am trying to set up a Fargate task that processes items from an SQS queue and stumbled onto the QueueProcessingFargateService construct which appears to do just that. However, after configuring the construct, I am getting the following error when running cdk deploy:
"Invalid request provided: Create TaskDefinition: Container list cannot be empty. (Service: AmazonECS; Status Code: 400; Error Code: ClientException; Request ID: 00000000-0000-0000-0000-000000000000; Proxy: null)"
Expected Behavior
The CDK stack deploys successfully.
Current Behavior
The CDK stack fails to deploy.
> cdk@0.0.0 cdk
> cdk deploy --require-approval never
✨ Synthesis time: 4.1s
ProjectStack: start: Building db6c89048d09ecd82cfbaeaa88cd73a91eb853fb29d321a61d90014df27f3740:************-*********
ProjectStack: success: Built db6c89048d09ecd82cfbaeaa88cd73a91eb853fb29d321a61d90014df27f3740:************-*********
ProjectStack: start: Publishing db6c89048d09ecd82cfbaeaa88cd73a91eb853fb29d321a61d90014df27f3740:************-*********
ProjectStack: success: Published db6c89048d09ecd82cfbaeaa88cd73a91eb853fb29d321a61d90014df27f3740:************-*********
ProjectStack: deploying... [1/1]
ProjectStack: creating CloudFormation changeset...
ProjectStack | 0/18 | 2:54:13 PM | UPDATE_IN_PROGRESS | AWS::CloudFormation::Stack | ProjectStack User Initiated
ProjectStack | 0/18 | 2:54:19 PM | UPDATE_IN_PROGRESS | AWS::IAM::Policy | QueueProcessingService/QueueProcessingTaskDef/TaskRole/DefaultPolicy (QueueProcessingServiceQueueProcessingTaskDefTaskRoleDefaultPolicy0AD99632)
ProjectStack | 0/18 | 2:54:19 PM | UPDATE_IN_PROGRESS | AWS::IAM::Policy | QueueProcessingService/QueueProcessingTaskDef/ExecutionRole/DefaultPolicy (QueueProcessingServiceQueueProcessingTaskDefExecutionRoleDefaultPolicyC4BA62EF)
ProjectStack | 0/18 | 2:54:19 PM | UPDATE_IN_PROGRESS | AWS::ECS::TaskDefinition | TaskDefinition (TaskDefinitionB36D86D9) Requested update requires the creation of a new physical resource; hence creating one.
ProjectStack | 0/18 | 2:54:19 PM | UPDATE_IN_PROGRESS | AWS::ECS::TaskDefinition | QueueProcessingService/QueueProcessingTaskDef (QueueProcessingServiceQueueProcessingTaskDefAEA09787) Requested update requires the creation of a new physical resource; hence creating one.
ProjectStack | 0/18 | 2:54:20 PM | UPDATE_FAILED | AWS::ECS::TaskDefinition | TaskDefinition (TaskDefinitionB36D86D9) Resource handler returned message: "Invalid request provided: Create TaskDefinition: Container list cannot be empty. (Service: AmazonECS; Status Code: 400; Error Code: ClientException; Request ID: 00000000-0000-0000-0000-000000000000; Proxy: null)" (RequestToken: 00000000-0000-0000-0000-000000000000, HandlerErrorCode: InvalidRequest)
ProjectStack | 0/18 | 2:54:21 PM | UPDATE_FAILED | AWS::IAM::Policy | QueueProcessingService/QueueProcessingTaskDef/TaskRole/DefaultPolicy (QueueProcessingServiceQueueProcessingTaskDefTaskRoleDefaultPolicy0AD99632) Resource update cancelled
ProjectStack | 0/18 | 2:54:21 PM | UPDATE_FAILED | AWS::IAM::Policy | QueueProcessingService/QueueProcessingTaskDef/ExecutionRole/DefaultPolicy (QueueProcessingServiceQueueProcessingTaskDefExecutionRoleDefaultPolicyC4BA62EF) Resource update cancelled
ProjectStack | 0/18 | 2:54:21 PM | UPDATE_FAILED | AWS::ECS::TaskDefinition | QueueProcessingService/QueueProcessingTaskDef (QueueProcessingServiceQueueProcessingTaskDefAEA09787) Resource creation cancelled
ProjectStack | 0/18 | 2:54:21 PM | UPDATE_ROLLBACK_IN_P | AWS::CloudFormation::Stack | ProjectStack The following resource(s) failed to update: [QueueProcessingServiceQueueProcessingTaskDefExecutionRoleDefaultPolicyC4BA62EF, QueueProcessingServiceQueueProcessingTaskDefTaskRoleDefaultPolicy0AD99632, QueueProcessingServiceQueueProcessingTaskDefAEA09787, TaskDefinitionB36D86D9].
ProjectStack | 1/18 | 2:54:25 PM | UPDATE_COMPLETE | AWS::ECS::TaskDefinition | TaskDefinition (TaskDefinitionB36D86D9)
ProjectStack | 1/18 | 2:54:25 PM | UPDATE_IN_PROGRESS | AWS::IAM::Policy | QueueProcessingService/QueueProcessingTaskDef/ExecutionRole/DefaultPolicy (QueueProcessingServiceQueueProcessingTaskDefExecutionRoleDefaultPolicyC4BA62EF)
ProjectStack | 2/18 | 2:54:25 PM | UPDATE_COMPLETE | AWS::ECS::TaskDefinition | QueueProcessingService/QueueProcessingTaskDef (QueueProcessingServiceQueueProcessingTaskDefAEA09787)
ProjectStack | 2/18 | 2:54:25 PM | UPDATE_IN_PROGRESS | AWS::IAM::Policy | QueueProcessingService/QueueProcessingTaskDef/TaskRole/DefaultPolicy (QueueProcessingServiceQueueProcessingTaskDefTaskRoleDefaultPolicy0AD99632)
ProjectStack | 3/18 | 2:54:41 PM | UPDATE_COMPLETE | AWS::IAM::Policy | QueueProcessingService/QueueProcessingTaskDef/ExecutionRole/DefaultPolicy (QueueProcessingServiceQueueProcessingTaskDefExecutionRoleDefaultPolicyC4BA62EF)
ProjectStack | 4/18 | 2:54:41 PM | UPDATE_COMPLETE | AWS::IAM::Policy | QueueProcessingService/QueueProcessingTaskDef/TaskRole/DefaultPolicy (QueueProcessingServiceQueueProcessingTaskDefTaskRoleDefaultPolicy0AD99632)
ProjectStack | 5/18 | 2:54:44 PM | UPDATE_ROLLBACK_COMP | AWS::CloudFormation::Stack | ProjectStack
ProjectStack | 5/18 | 2:54:45 PM | DELETE_IN_PROGRESS | AWS::ECS::TaskDefinition | QueueProcessingService/QueueProcessingTaskDef (QueueProcessingServiceQueueProcessingTaskDefAEA09787)
ProjectStack | 4/18 | 2:54:45 PM | DELETE_COMPLETE | AWS::ECS::TaskDefinition | TaskDefinition (TaskDefinitionB36D86D9)
ProjectStack | 3/18 | 2:54:46 PM | DELETE_COMPLETE | AWS::ECS::TaskDefinition | QueueProcessingService/QueueProcessingTaskDef (QueueProcessingServiceQueueProcessingTaskDefAEA09787)
ProjectStack | 4/18 | 2:54:46 PM | UPDATE_ROLLBACK_COMP | AWS::CloudFormation::Stack | ProjectStack
Failed resources:
ProjectStack | 2:54:20 PM | UPDATE_FAILED | AWS::ECS::TaskDefinition | TaskDefinition (TaskDefinitionB36D86D9) Resource handler returned message: "Invalid request provided: Create TaskDefinition: Container list cannot be empty. (Service: AmazonECS; Status Code: 400; Error Code: ClientException; Request ID: 00000000-0000-0000-0000-000000000000; Proxy: null)" (RequestToken: 00000000-0000-0000-0000-000000000000, HandlerErrorCode: InvalidRequest)
❌ ProjectStack failed: Error: The stack named ProjectStack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Invalid request provided: Create TaskDefinition: Container list cannot be empty. (Service: AmazonECS; Status Code: 400; Error Code: ClientException; Request ID: 00000000-0000-0000-0000-000000000000; Proxy: null)" (RequestToken: 00000000-0000-0000-0000-000000000000, HandlerErrorCode: InvalidRequest)
at FullCloudFormationDeployment.monitorDeployment (/home/circleci/project/cdk/node_modules/aws-cdk/lib/index.js:467:10232)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.deployStack2 [as deployStack] (/home/circleci/project/cdk/node_modules/aws-cdk/lib/index.js:470:179911)
at async /home/circleci/project/cdk/node_modules/aws-cdk/lib/index.js:470:163159
❌ Deployment failed: Error: The stack named ProjectStack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Invalid request provided: Create TaskDefinition: Container list cannot be empty. (Service: AmazonECS; Status Code: 400; Error Code: ClientException; Request ID: 00000000-0000-0000-0000-000000000000; Proxy: null)" (RequestToken: 00000000-0000-0000-0000-000000000000, HandlerErrorCode: InvalidRequest)
at FullCloudFormationDeployment.monitorDeployment (/home/circleci/project/cdk/node_modules/aws-cdk/lib/index.js:467:10232)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.deployStack2 [as deployStack] (/home/circleci/project/cdk/node_modules/aws-cdk/lib/index.js:470:179911)
at async /home/circleci/project/cdk/node_modules/aws-cdk/lib/index.js:470:163159
The stack named ProjectStack failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Invalid request provided: Create TaskDefinition: Container list cannot be empty. (Service: AmazonECS; Status Code: 400; Error Code: ClientException; Request ID: 00000000-0000-0000-0000-000000000000; Proxy: null)" (RequestToken: 00000000-0000-0000-0000-000000000000, HandlerErrorCode: InvalidRequest)
Exited with code exit status 1
Reproduction Steps
import { App, Duration, Stack, StackProps } from 'aws-cdk-lib';
import { DockerImageAsset } from 'aws-cdk-lib/aws-ecr-assets';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as ecs from 'aws-cdk-lib/aws-ecs';
import { QueueProcessingFargateService } from 'aws-cdk-lib/aws-ecs-patterns';
import { LogGroup } from 'aws-cdk-lib/aws-logs';
import * as path from 'node:path';
import { config } from '../config';
export class FargateServiceStack extends Stack {
constructor(scope: App, id: string, props?: StackProps) {
super(scope, id, props);
const asset = new DockerImageAsset(this, 'TestDockerImage', {
directory: path.join(__dirname, '..', '..', 'images', 'test'),
});
const vpc = ec2.Vpc.fromLookup(this, 'Vpc', {
vpcName: config.vpcName,
});
const cluster = new ecs.Cluster(this, 'EcsCluster', {
vpc,
clusterName: config.clusterName,
});
const logGroup = new LogGroup(this, 'LogGroup', {
logGroupName: config.logGroupName,
});
const logDriver = new ecs.AwsLogDriver({
logGroup,
streamPrefix: config.streamPrefix,
});
const taskDefinition = new ecs.FargateTaskDefinition(this, 'TaskDefinition', {
cpu: 256,
memoryLimitMiB: 512,
runtimePlatform: {
cpuArchitecture: ecs.CpuArchitecture.ARM64,
},
});
new QueueProcessingFargateService(this, 'QueueProcessingAiService', {
cluster,
logDriver,
taskDefinition,
image: ecs.ContainerImage.fromDockerImageAsset(asset),
enableLogging: true,
maxScalingCapacity: 5,
minScalingCapacity: 0,
platformVersion: ecs.FargatePlatformVersion.VERSION1_4,
serviceName: config.serviceName,
visibilityTimeout: Duration.minutes(1),
});
}
}
Possible Solution
Maybe I just misconfigured the construct? 🤷
Is there some kind of underlying change needed to support ecs.ContainerImage.fromDockerImageAsset(asset) vs ecs.ContainerImage.fromRegistry('test')?
Additional Information/Context
No response
CDK CLI Version
2.99.0 (build 0aa1096)
Framework Version
No response
Node.js Version
18.18.0
OS
ubuntu-2204:2023.02.1
Language
Typescript
Language Version
5.2.2
Other information
No response
Describe the bug
I am trying to set up a Fargate task that processes items from an SQS queue and stumbled onto the
QueueProcessingFargateServiceconstruct which appears to do just that. However, after configuring the construct, I am getting the following error when runningcdk deploy:Expected Behavior
The CDK stack deploys successfully.
Current Behavior
The CDK stack fails to deploy.
Reproduction Steps
Possible Solution
Maybe I just misconfigured the construct? 🤷
Is there some kind of underlying change needed to support
ecs.ContainerImage.fromDockerImageAsset(asset)vsecs.ContainerImage.fromRegistry('test')?Additional Information/Context
No response
CDK CLI Version
2.99.0 (build 0aa1096)
Framework Version
No response
Node.js Version
18.18.0
OS
ubuntu-2204:2023.02.1
Language
Typescript
Language Version
5.2.2
Other information
No response