-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ecs: create Ec2Service or FargateService with imported TaskDefinition #7863
Comments
related to #6240 |
I also need this feature, to be able to define the TaskDefinition externally to support EFS volumes for Fargate. |
This will help me to use CDK to provision the infra and use Github Actions with amazon-ecs-deploy-task-definition for automated deployments. |
Looks like the PR to fix this went stale. If anyone is interested to revive it, you are welcome to 😄 |
I am still running into this issue and it would be great if we we could resolve it without having to do much hacking. The following is the workaround that I'm current using, it's a modified hack from #25777. const defaultTaskDefinition = new FargateTaskDefinition(this, 'DefaultTask', {
family: 'DefaultTask',
taskRole: taskRole,
executionRole: taskExecutionRole,
});
defaultTaskDefinition.addContainer(`${serviceName}Container`, {
containerName: 'DefaultContainer',
image: ContainerImage.fromRegistry('registry.hub.docker.com/ealen/echo-server'),
});
const myService = new FargateService(this, 'MyService', {
cluster: this.cluster,
taskDefinition: defaultTaskDefinition,
desiredCount: 1,
securityGroups: [securityGroup],
serviceName: 'MyService',
assignPublicIp: false
});
// Lookup the FargateTaskDefinition from the ARN and override the service defnition
const existingTaskDefinition = FargateTaskDefinition.fromFargateTaskDefinitionArn(this, 'ExistingTaskDefinition', 'Existing Task ARN');
(myService.node.tryFindChild('Service') as CfnService).taskDefinition =
existingTaskDefinition.taskDefinitionArn; It seems that the bigger issue is that CDK does not allow us to make updates to the FargateService without reverting the task definition to the initial task definition defined by the FargateService construct. |
FargateService
requires theTaskDefinition
type and using existing task definition is not allowed.aws-cdk/packages/@aws-cdk/aws-ecs/lib/fargate/fargate-service.ts
Line 17 in c304d24
Use Case
Becasue cloudformation is missing some features such as TaskDefinition with EFS support, we may create our own task definition with CLI or console and allow CDK to create Fargate service by importing the existing task definition.
Proposed Solution
Maybe we can simply use
ITaskDefinition
instead?The drawback is we will not be able to check the defaultContainer here.
aws-cdk/packages/@aws-cdk/aws-ecs/lib/fargate/fargate-service.ts
Lines 167 to 169 in c304d24
Other
This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: