Skip to content
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: Error when using ECS service_name #27178

Closed
andreprawira opened this issue Sep 18, 2023 · 2 comments
Closed

ECS: Error when using ECS service_name #27178

andreprawira opened this issue Sep 18, 2023 · 2 comments
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@andreprawira
Copy link

Describe the bug

I'm using AWS CDK Python to create an ECS and i specified the cluster's service name. When i run the code in codepipeline first run works perfectly (as in fresh run, no cluster and no service ever created), it creates the cluster and the service using the correct name as it should. But when i re run the pipeline without any code change for the second time, i would get an error
Resource handler returned message: "Resource of type 'AWS::ECS::Service' with identifier 'dev-my-ecs-service' already exists." (RequestToken: 106a2ca3-6e6e-6715-8f20-0bb93b5ee61e, HandlerErrorCode: AlreadyExists)

Expected Behavior

i expect it would just leave it as is without trying to re-create the ecs cluster because there was no code change on the second run

Current Behavior

im guessing CDK thinks that there is no cluster with that name and that it should create a new one but when its trying to do so, there is already a service created using that name which was created on the previous run, im guessing so because the error message says 'dev-my-ecs-service' already exists.

Reproduction Steps

load_balanced_fargate_service = ecs_patterns.ApplicationLoadBalancedFargateService(self, "Service",
            cluster=cluster,
            memory_limit_mi_b=1024,
            service_name=f"{props.prefix}-my-ecs-service",
            desired_count=1,
            cpu=512,
            task_image_options=ecsPatterns.ApplicationLoadBalancedTaskImageOptions(
                image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample")
            ),
            task_subnets=ec2.SubnetSelection(
                subnets=[ec2.Subnet.from_subnet_id(self, "subnet", "VpcISOLATEDSubnet1Subnet80F07FA0")]
            ),
            load_balancer_name="application-lb-name"
        )

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.51.0 (build a87259f)

Framework Version

No response

Node.js Version

16.18.0

OS

Windows

Language

Python

Language Version

No response

Other information

No response

@andreprawira andreprawira added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 18, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Sep 18, 2023
@peterwoodworth
Copy link
Contributor

i expect it would just leave it as is without trying to re-create the ecs cluster because there was no code change on the second run

This is how it would work if you're creating one service per account + region, and you never make any changes that cause resource replacement to your resource. You're either attempting to deploy multiple stacks/constructs with this name, or there are changes the second time you run it that cause resource replacement, which is a well documented behavior with specifying the physical name. You haven't posted a diff or details into your pipeline setup, so I cannot say what exactly is going wrong.

@peterwoodworth peterwoodworth added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 18, 2023
@github-actions
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants