By using AWS re:Post, you agree to the AWS re:Post Terms of Use

Force update CDK Stack

0

I have additional CDK stacks. I have to change now a service definition but I get the error

The record types in the request must be the same as those present in the existing service. Records in the existing service are [A], but the records in the request are [A,SRV]. The record types of a service cannot be changed. 

Is there a way to update the service with a force command or another way to avoid delete and redeploy?

asked a month ago66 views
1 Answer
0

Unfortunately, there isn't a straightforward "force update" command in AWS CDK to change the record types of an existing service as described in your error message. The error you're encountering is due to a fundamental limitation in AWS CloudFormation, which CDK uses under the hood.

CloudFormation does not allow changing the record types of an existing service. In this case, you're trying to add an SRV record to a service that previously only had an A record, which is not permitted.

Given this limitation, your options are somewhat limited:

  1. Delete and redeploy: This is the most straightforward approach, though it may cause some downtime or require careful orchestration.

  2. Create a new service: Instead of modifying the existing service, you could create a new service with both A and SRV records, then update your other resources to use this new service.

  3. Use a custom resource: You might be able to use a custom resource in your CDK stack to manipulate the service outside of CloudFormation's normal processes. This is an advanced approach and requires careful implementation.

  4. Manually update the service: You could temporarily remove the service from your CDK stack, manually update it in the AWS console or via AWS CLI, and then import it back into your CDK stack.

If you choose to import the manually updated resource back into your CDK stack, you can use the cdk import command. This allows you to bring existing resources under CDK management without recreating them.

Remember, whichever approach you choose, it's crucial to test thoroughly in a non-production environment first, as these changes can potentially cause service disruptions.
Sources
How to import existing resources into AWS CDK Stacks | AWS DevOps Blog

profile picture
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions