Al usar AWS re:Post, aceptas las AWS re:Post Términos de uso

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 Respuesta
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
respondido hace 2 meses
profile picture
EXPERTO
revisado hace 2 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas