A Campos
A Campos

Reputation: 803

AWS RDS Database Version is different than Terraform version

I'm learning how to use Terraform to manage my AWS Infrastructure.

Monday I created it all from scratch based on my Terraform Apply.

Tuesday (the next day) I wanted to update my app with some code changes (nothing that would affect the rest of the infrastructure, just my image in ECS) and got this error message in my terraform apply output:

Error: Error modifying DB Instance foo-staging-db: InvalidParameterCombination: Cannot upgrade postgres from 11.8 to 11.4

When I double checked my terraform database.tf I saw this:

resource "aws_db_instance" "main" {
  ...
  engine                  = "postgres"
  engine_version          = "11.4"
  ...
}

Does anybody has an idea of what could have happened here?

  1. This is not the first time that I update my databases like this, since I destroy my infrastructure every weekend to limit my AWS costs.
  2. I solved the issue by changing my terraform Postgres version to 11.8, but still want to understand why the error happened in the first place.

Upvotes: 4

Views: 9442

Answers (1)

Banzy Vasilenkov
Banzy Vasilenkov

Reputation: 61

AWS use default setting auto_minor_version_upgrade=true and tries to update your database. You can do following to solve it

Method 1

Set flag to false explicitly using auto_minor_version_upgrade = false

Method 2

Use only first octet in version number engine_version = "11"

For more information https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance#engine_version

Upvotes: 6

Related Questions