Skip to content
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

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

Closed
hashibot opened this issue Jun 13, 2017 · 6 comments
Labels
bug Addresses a defect in current functionality. service/rds Issues and PRs that pertain to the rds service.

Comments

@hashibot
Copy link

This issue was originally opened by @hgontijo as hashicorp/terraform#11278. It was migrated here as part of the provider split. The original body of the issue is below.


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

@hashibot hashibot added the bug Addresses a defect in current functionality. label Jun 13, 2017
@aviaviavi
Copy link

Is there a workaround for this? I'd like to restore my DB from a snapshot, but currently seem unable to do this from terraform.

@hgontijo
Copy link

hgontijo commented Sep 1, 2017

@aviaviavi, the workaround is to not set the name while restoring a DB snapshot.

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

You can also override the name parameter programmatically to avoid changing the Terraform script.

@aviaviavi
Copy link

Ok thanks @hgontijo.

I'll give this a try when I'm needing to do a restore next

@radeksimko radeksimko added the service/rds Issues and PRs that pertain to the rds service. label Jan 25, 2018
@brandonstevens
Copy link
Contributor

I'm not able to reproduce this issue and it appears to be fixed by this PR: hashicorp/terraform#13140.

@bflad
Copy link
Contributor

bflad commented Jun 22, 2018

Thanks @brandonstevens -- that does appear to be the case here. If there is still an issue on the latest version of the AWS provider, please open a new issue with all the relevant details and we'll troubleshoot further. 👍

@ghost
Copy link

ghost commented Apr 5, 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 Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/rds Issues and PRs that pertain to the rds service.
Projects
None yet
Development

No branches or pull requests

6 participants