- Newest
- Most votes
- Most comments
This issue appears to be related to a known CloudFormation behavior when transitioning ECS services from LaunchType to Capacity Providers. While not explicitly documented as a bug, it's a situation that can occur during such migrations.
The failure to delete the old ECS service is likely due to the complex nature of ECS service updates, especially when changing fundamental properties like the launch type or capacity provider strategy. CloudFormation may struggle to properly handle this transition, resulting in the DELETE_FAILED status you're experiencing.
The error message you're seeing ("Cannot invoke "com.amazonaws.ecs.service.logger.model.LogContext.updateContextFromException(java.lang.Exception)" because "this.logContext" is null") suggests an internal AWS issue, which could be contributing to the problem.
To work around this issue, you might consider the following approaches:
-
Manually delete the old ECS service after the CloudFormation update completes. Since you mentioned this succeeds, it's a viable temporary solution.
-
Instead of updating the existing service, create a new ECS service with the desired capacity provider strategy, then delete the old service. This two-step process might avoid the CloudFormation deletion issue.
-
Use a custom resource in your CloudFormation template to handle the transition. This could involve using AWS Lambda to manage the service update and deletion process more granularly.
-
If possible, consider using AWS CDK or other infrastructure-as-code tools that might handle this transition more gracefully.
Regarding the transition from LaunchType to Capacity Providers, while AWS documentation does mention the use of defaultCapacityProviderStrategy when LaunchType is omitted, it doesn't provide specific guidance for this migration scenario. It would indeed be beneficial for AWS to provide official documentation or best practices for this transition process.
If this issue persists or significantly impacts your operations, it's recommended to open a support case with AWS. They can provide more tailored assistance and potentially escalate the issue if it's indeed a bug in CloudFormation.
Remember that when working with Auto Scaling groups and capacity providers, it's crucial to carefully consider protection and termination settings to ensure proper cleanup when resources are no longer needed. This can help mitigate issues during stack updates and deletions.
Sources
ECS Autoscaling Group and EC2 Instance not deleted by delete stack CDK typescript | AWS re:Post
Troubleshoot CloudFormation stack deployment failure | AWS re:Post
answered 2 years ago
Relevant content
asked 2 years ago
asked 2 years ago
- AWS OFFICIALUpdated 12 days ago
