question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(rds): Is it really that easy to destroy a database?

See original GitHub issue

The Question

This is the situation: we are developing an application which has CDK stack using the RDS module for Postgresql. The application is normally deployed using Github Actions and the database has (for now) only ONE user defined.

One day one developer deployed from their local environment (we should not do this, but it happened) and all of the sudden, the database in RDS disappeared.

During the deployment, CDK detected a change: that only change is in the credentials of the database; the value in the live environment differs (of course) from the value from the developer’s laptop. This single change, for some reason, made CDK (or Cloudformation) take the decision to destroy the database and recreating it from scratch. This is part of the Cloudformation logs:

UPDATE_IN_PROGRESS: Requested update requires the creation of a new physical resource; hence creating one.

I know that there are options to avoid this potential disaster, but they should be enabled by default.

Our running theory is that CDK is not able to understand if/how to change credentials in a running db, hence it goes with the simplest solution: destroy/create. We tried more than once, and this is apparently the effect.

This is the relevant part of our ifrastructure:

    const instance = new rds.DatabaseInstance(this, 'SomeDatabaseInstance', {
      vpc,
      engine: rds.DatabaseInstanceEngine.postgres({
        version: rds.PostgresEngineVersion.VER_12_3,
      }),
      vpcPlacement: {
        subnetType: SubnetType.PUBLIC,
      },
      databaseName: config.database.name,
      credentials: {
        username: config.database.username,
        password: secret,
      },
      instanceType: config.database.instanceType,
    });

Environment

  • CDK CLI Version: 1.73.0
  • Module Version:@aws-cdk/aws-rds@1.73.0”
  • Node.js Version: 14.13.0
  • OS: macOS Catalina
  • Language (Version): TypeScript (4.0.3)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
skinny85commented, Dec 18, 2020

Of course. Changing the username of the master user requires the replacement of the database. But I don’t see why you would ever need to change that value (including in the developer stacks).

1reaction
skinny85commented, Dec 23, 2020

I’m going to resolve this one. @claudioc please comment if you have any more questions!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deleting a DB instance - Amazon Relational Database Service
You can delete a DB instance using the AWS Management Console, the AWS CLI, or the RDS API. The time required to delete...
Read more >
Delete postgresql database without superuser rights on AWS ...
I'm trying to delete a postgres database on an AWS RDS service with a bash script. Based on some answers here I came...
Read more >
5. SQL Server on AWS RDS - Delete instance - YouTube
SQL Server is a relational database management system developed by Microsoft. Amazon RDS for SQL Server makes it easy to set up, operate, ......
Read more >
What is Amazon RDS (Relational Database Service)?
Amazon RDS database instances ... A database administrator can create, configure, manage and delete an Amazon RDS instance, along with the resources it...
Read more >
RDS — Boto3 Docs 1.26.37 documentation - Amazon AWS
Amazon Relational Database Service (Amazon RDS) is a web service that makes it easier to set up, operate, and scale a relational database...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found