copilot-cli: ECS service deleted, now I can't deploy!

5d5962699bd5: Layer already exists 
a42439ce9650: Layer already exists 
26270c5e25fa: Layer already exists 
e2c6ff462357: Layer already exists 
latest: digest: sha256:93ff153ceed5926d1ddf4bf9e0c596d08fd5c2b0b86b32f533ea07a546c67046 size: 3476
✔ Proposing infrastructure changes for stack api-prod-v1 
- Updating the infrastructure for stack api-prod-v1                                  [update rollback complete]  [56.6s]
  The following resource(s) failed to update: [Service].                                                         
  - An autoscaling target to scale your service's desired count                      [not started]                
  - An ECS service to run and maintain your tasks in the environment cluster         [update complete]           [0.0s]
    Failed to retrieve attribute [Arn] for resource [DiscoveryService]: nu                                       
    ll (Service: AWSServiceDiscovery; Status Code: 400; Error Code: Servic                                       
    eNotFound; Request ID: 1eb88d3b-ef8b-4de0-a254-786afd973f8c; Proxy: nu                                       
    ll)                                                                                                          
  - An ECS task definition to group your containers and run them on ECS              [delete complete]           [2.7s]
✘ deploy service: stack api-prod-v1 did not complete successfully and exited with status UPDATE_ROLLBACK_COMPLETE

Need advice please!

Deleted the service fro the ECS panel due to another problem. I thought I’d be able to just use deploy or deploy --force but then the above error is given

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

Excellent! All went according to plan. Thank you once again. ❤️ I pray this be the end of this thread.

Hi @coopsmoss 👋

My recommendation would be option 2 where you hard code count first and then recreate auto scaling. However, I suspect that the first time you remove auto scaling it’s going to fail because suddenly CloudFormation won’t be able to find the auto scaling group to delete. If that happens, I think you can create the autoscaling group with the same name as what CloudFormation expects (https://docs.aws.amazon.com/cli/latest/reference/autoscaling/create-auto-scaling-group.html) you shouldn’t need to connect it to your ECS service so it should be safe to manually create it. Afterwards, CloudFormation should be able to delete the resource, and you can set the count.

This didn’t fix it at first, but after another deploy it’s all working great! Thanks a bunch @efekarakus. The outage all the small issues following it have been incredibly stressful, buy you’ve been so helpful and I think everything is back to normal now, so I can’t thank you enough.

oh very strange 🤔 – was there any other resource besides the ECS service, such as the service discovery namespace, that were manually deleted?

If the service discovery service was deleted, we can also try re-creating it manually but I’m not certain if it will work:

  1. Find the DiscoveryService resource PhysicalId by navigating to the CloudFormation “Resources” tab for the stack
  2. Navigate to AWS Cloud Map > Namespaces > {env}.{app}.local
  3. Create a service with your service name
  4. Try copilot deploy again

If none of this works, I think my recommended work around would be to create a brand new service copilot svc init and copilot deploy that. Once the service is deployed with a brand new database, you can migrate the data from the old database to the new one and then delete the old stack. Hope this helps!

Can you check the resources tab in the cloudformation stack? Hopefully it will be listed there

Gotcha! Hmm perhaps one other way might be trying to recreate the ECS service manually but with the exact same auto generated name by copilot. Once the resources are back to a good original state you can try running copilot deploy again