Skip to content

aws_db_instance seemingly ignores backup_retention_period #8380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
slavaaaaaaaaaa opened this issue Apr 18, 2019 · 3 comments
Closed

aws_db_instance seemingly ignores backup_retention_period #8380

slavaaaaaaaaaa opened this issue Apr 18, 2019 · 3 comments

Comments

@slavaaaaaaaaaa
Copy link

slavaaaaaaaaaa commented Apr 18, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.13
+ provider.aws v1.49.0

Affected Resource(s)

  • aws_db_instance

Terraform Configuration Files

resource "aws_db_instance" "master" {
  identifier         = "master"
  instance_class     = "db.m4.large"

  engine             = "postgres"
  engine_version     = "9.6.9"

  allocated_storage  = 20
  username           = "master"
  password           = "uselesspassword"

  db_subnet_group_name = "${aws_db_subnet_group.default.name}"
}

resource "aws_db_instance" "replica" {
  identifier         = "replica"
  instance_class     = "db.m4.large"

  engine             = "postgres"
  engine_version     = "9.6.9"

  replicate_source_db = "${aws_db_instance.master.identifier}"
  backup_retention_period = 5

  db_subnet_group_name = "${aws_db_subnet_group.default.name}"
}
...

Debug Output

* aws_db_instance.replica: Error creating DB Instance: InvalidDBInstanceState: Automated backups are not enabled for this database instance. To enable automated backups, use ModifyDBInstance to set the backup retention period to a non-zero value.
        status code: 400, request id: ...

It will take me some time to sanitize the full debug output - do let me know if it's needed.

Panic Output

Expected Behavior

Replica should have been created

Actual Behavior

  • aws_db_instance.replica: Error creating DB Instance: InvalidDBInstanceState: Automated backups are not enabled for this database instance. To enable automated backups, use ModifyDBInstance to set the backup retention period to a non-zero value.

Steps to Reproduce

  1. terraform apply

Important Factoids

According to documentation, backup_retention_period is to be > 0 for replicas. It is, but the resource still fails to create.

References

@catherinetcai
Copy link

The AWS docs do specify that Postgres read replicas don't do automated backups, only manual snapshots.

Also looking at AWS SDK Go, it seems like you need to enable automated backups on the master instance, not the replica.

@slavaaaaaaaaaa
Copy link
Author

@catherinetcai You're right, backups do need to be specified on the master. However, that didn't work until I recreated the master with the right setting: modification didn't fly.

This is the code that worked in the end:

resource "aws_db_instance" "master" {
  identifier         = "master"
  instance_class     = "db.m4.large"

  engine             = "postgres"
  engine_version     = "9.6.9"

  allocated_storage  = 20
  username           = "master"
  password           = "uselesspassword"
  skip_final_snapshot = true
  backup_retention_period = 5

  db_subnet_group_name = "${aws_db_subnet_group.default.name}"
}

resource "aws_db_instance" "replica" {
  identifier         = "replica"
  instance_class     = "db.m4.large"

  engine             = "postgres"
  engine_version     = "9.6.9"

  replicate_source_db = "${aws_db_instance.master.identifier}"
}
...

@ghost
Copy link

ghost commented Mar 30, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants