AWS re:Post을(를) 사용하면 다음에 동의하게 됩니다. AWS re:Post 이용 약관

Why does CDK show an RDS EngineVersion change when the CDK version and the GUI version are the same?

0

I have a stack with an RDS db. The version was originally ds.PostgresEngineVersion.VER_12_5, but has been updated to 12.19 manually over the years. It shows as version 12.19 in the GUI. I updated the CDK repo to reflect the current version, ds.PostgresEngineVersion.VER_12_19, but a cdk diff shows

Resources
[~] AWS::RDS::DBInstance StackDBInstance StackDBInstance12345

└─ [~] EngineVersion
├─ [-] 12.5
└─ [+] 12.19

I want to avoid rebuilding this database, since I need to maintain the data within it and the access to that data (I know I can restore from snapshot, but if there's a way to avoid that I'd like to). Why does CDK want to rebuild a db with no changes from what's spun up?

1개 답변
2

The discrepancy you're seeing between the CDK diff and the actual state of your RDS instance is likely due to how CDK tracks and manages resource states compared to manual updates made directly to the RDS instance.

When you manually updated the RDS instance from version 12.5 to 12.19 over time, these changes were not reflected in your CDK stack's state. CDK maintains its own representation of the infrastructure state based on what was last deployed through it.

By updating your CDK code to use ds.PostgresEngineVersion.VER_12_19, you're now aligning the CDK's view of the desired state with the actual current state of your RDS instance. However, from CDK's perspective, this appears as a change because it's comparing against its last known state (12.5) rather than the current state of the deployed resource.

The good news is that this diff doesn't necessarily mean CDK will rebuild your database. In most cases, when you apply this change, CDK will recognize that the actual resource is already at the desired version and won't perform any destructive actions. It will likely just update its own state to reflect the new version.

To avoid any potential issues, you can take the following steps:

  1. Double-check that the version in your CDK code exactly matches the current version of your RDS instance.
  2. Consider using a CDK escape hatch to explicitly set the engine version to match the current state, which can help CDK recognize that no actual change is needed.
  3. Before applying the changes, use the --no-execute flag with cdk deploy to see the detailed plan of what changes will actually be made.

Remember, while CDK is showing a diff, it doesn't always mean a resource will be replaced or rebuilt. In this case, it's more likely updating its own state to match the current reality of your infrastructure.
Sources
Upgrading a DB instance engine version - Amazon Relational Database Service
Upgrading the engine version of a Multi-AZ DB cluster for Amazon RDS - Amazon Relational Database Service

profile picture
답변함 2달 전
profile picture
전문가
검토됨 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠