Skip to content

Commit 0c34cd5

Browse files
committed
Throw error when name or username supplied
for rds snapshot restore of mysql, postgresql or mariadb
1 parent 5bb0ab1 commit 0c34cd5

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

aws/resource_aws_db_instance.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,12 +898,21 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
898898
// https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBInstanceFromDBSnapshot.html
899899
switch strings.ToLower(d.Get("engine").(string)) {
900900
case "mysql", "postgres", "mariadb":
901-
// skip
901+
// Throw an error if name attribute is provided when engine is mysql, postgres or mariadb when restoring from snapshot
902+
// https://github.com/hashicorp/terraform-provider-aws/issues/17037
903+
return fmt.Errorf("Error restoring database from AWS DB Snapshot: %s, name attribute is not supported when engine is %s", d.Get("snapshot_identifier").(string), d.Get("engine").(string))
902904
default:
903905
opts.DBName = aws.String(attr.(string))
904906
}
905907
}
906908

909+
if _, ok := d.GetOk("username"); ok {
910+
// "Note: This parameter [username] doesn't apply when restoring from snapshot"
911+
// https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_RestoreDBInstanceFromDBSnapshot.html
912+
// https://github.com/hashicorp/terraform-provider-aws/issues/17037
913+
return fmt.Errorf("Error restoring database from AWS DB Snapshot: %s, username attribute is not supported when restoring from snapshot", d.Get("snapshot_identifier").(string))
914+
}
915+
907916
if attr, ok := d.GetOk("allocated_storage"); ok {
908917
modifyDbInstanceInput.AllocatedStorage = aws.Int64(int64(attr.(int)))
909918
requiresModifyDbInstance = true

0 commit comments

Comments
 (0)