Terraform: provider/aws: [question] DBName cannot be set when restoring from a MySQL, PostgreSQL, or MariaDB snapshot

Created on 18 Jan 2017  ยท  7Comments  ยท  Source: hashicorp/terraform

AWS RDS does not allow setting the DBName when restoring from a MySQL, PostgreSQL, or MariaDB snapshot, however it allows when restoring for Oracle and SQL Server -- vide cli documentation. A recent change on Terraform sets the DB Name on a restore operation for all databases. The current Terraform behavior is to show an AWS RDS exception (see below) whenever DB Name is set in a restore operation.
For this use case, is expected from Terraform to behave exact like AWS API or to execute a proactive validation before submission? Is expected Terraform to execute any validation during plan operation?

Actual Terraform Behavior

DB name is set on a restore from snapshot and Terraform issues this error:

* aws_db_instance.db_master: Error creating DB Instance: InvalidParameterValue: DBName must be null when Restoring for this Engine.
    status code: 400, request id: 48a17d5b-dc0c-11e6-8a5c-39e234c22f55

Actual AWS CLI Behavior

$ aws rds restore-db-instance-from-db-snapshot \
   --db-subnet-group-name default-vpc \
    --db-instance-identifier foo \
    --db-snapshot-identifier db-snapshot
    --db-name name
An error occurred (InvalidParameterValue) when calling the RestoreDBInstanceFromDBSnapshot operation: DBName name cannot be used.  It is a reserved word for this engine

Terraform Version

0.8.4

Affected Resource(s)

  • aws_db_instance

Steps to Reproduce

resource "aws_db_instance" "db_master" {
  ...
  name = "name"
  snapshot_identifier = "db-snapshot"
}
  1. terraform apply

References

  • GH-9988
  • GH-10664
bug provideaws

Most helpful comment

I don't know about the CLI, but I'm getting this error from the web interface for AWS RDS. I cannot restore my MySQL DB Snapshot. Kind of scaring me.
screen shot 2018-10-02 at 1 39 29 pm

All 7 comments

I don't know about the CLI, but I'm getting this error from the web interface for AWS RDS. I cannot restore my MySQL DB Snapshot. Kind of scaring me.
screen shot 2018-10-02 at 1 39 29 pm

Any luck with that restore @halfnibble ?

@luismsousa Oh yes! I forgot to post back that the official answer from AWS support was to use the AWS CLI to do the restore: Restoring from a DB Snapshot

And that did end up working for me. It doesn't sound like they have plans to fix the web interface anytime soon...

This also happens to me intermittently. I have found that logging out and back in again often fixes this problem...

This also happens to me intermittently. I have found that logging out and back in again often fixes this problem...

logging out and back worked for me

This also happens to me intermittently. I have found that logging out and back in again often fixes this problem...

logging out and back worked for me

logging out and back in did not work for me.
I started then using the point in time restore function.

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings