From 6318b8fd4c7ec42c4ea4c9d2688441c9ef95890b Mon Sep 17 00:00:00 2001 From: Clint Date: Thu, 9 Jun 2016 16:45:29 -0500 Subject: [PATCH] provider/aws: Rename parameter_group_name to db_cluster_parameter_group_name (supersedes #7068) (#7083) * modify parameter_group_name to db_cluster_parameter_group_name #7046 * provider/aws: Deprecate parameter_group_name in RDS Cluster Use db_cluster_parameter_group_name instead --- .../providers/aws/resource_aws_rds_cluster.go | 20 +++++++++++++++++++ .../aws/resource_aws_rds_cluster_test.go | 6 +++--- .../providers/aws/r/rds_cluster.html.markdown | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/builtin/providers/aws/resource_aws_rds_cluster.go b/builtin/providers/aws/resource_aws_rds_cluster.go index 74f7e3014..89379177c 100644 --- a/builtin/providers/aws/resource_aws_rds_cluster.go +++ b/builtin/providers/aws/resource_aws_rds_cluster.go @@ -61,7 +61,17 @@ func resourceAwsRDSCluster() *schema.Resource { Computed: true, }, + // TODO: remove parameter_group_name + // See https://github.com/hashicorp/terraform/issues/7046 + // Likely need migration to remove from state "parameter_group_name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + Deprecated: "Use db_cluster_parameter_group_name instead. This attribute will be removed in a future version", + }, + + "db_cluster_parameter_group_name": &schema.Schema{ Type: schema.TypeString, Optional: true, Computed: true, @@ -205,6 +215,10 @@ func resourceAwsRDSClusterCreate(d *schema.ResourceData, meta interface{}) error createOpts.DBClusterParameterGroupName = aws.String(attr.(string)) } + if attr, ok := d.GetOk("db_cluster_parameter_group_name"); ok { + createOpts.DBClusterParameterGroupName = aws.String(attr.(string)) + } + if attr := d.Get("vpc_security_group_ids").(*schema.Set); attr.Len() > 0 { createOpts.VpcSecurityGroupIds = expandStringList(attr.List()) } @@ -297,6 +311,7 @@ func resourceAwsRDSClusterRead(d *schema.ResourceData, meta interface{}) error { d.Set("db_subnet_group_name", dbc.DBSubnetGroup) d.Set("parameter_group_name", dbc.DBClusterParameterGroup) + d.Set("db_cluster_parameter_group_name", dbc.DBClusterParameterGroup) d.Set("endpoint", dbc.Endpoint) d.Set("engine", dbc.Engine) d.Set("master_username", dbc.MasterUsername) @@ -362,6 +377,11 @@ func resourceAwsRDSClusterUpdate(d *schema.ResourceData, meta interface{}) error req.DBClusterParameterGroupName = aws.String(d.Get("parameter_group_name").(string)) } + if d.HasChange("db_cluster_parameter_group_name") { + d.SetPartial("db_cluster_parameter_group_name") + req.DBClusterParameterGroupName = aws.String(d.Get("db_cluster_parameter_group_name").(string)) + } + _, err := conn.ModifyDBCluster(req) if err != nil { return fmt.Errorf("[WARN] Error modifying RDS Cluster (%s): %s", d.Id(), err) diff --git a/builtin/providers/aws/resource_aws_rds_cluster_test.go b/builtin/providers/aws/resource_aws_rds_cluster_test.go index 8ae460bca..ec59f44fe 100644 --- a/builtin/providers/aws/resource_aws_rds_cluster_test.go +++ b/builtin/providers/aws/resource_aws_rds_cluster_test.go @@ -28,7 +28,7 @@ func TestAccAWSRDSCluster_basic(t *testing.T) { resource.TestCheckResourceAttr( "aws_rds_cluster.default", "storage_encrypted", "false"), resource.TestCheckResourceAttr( - "aws_rds_cluster.default", "parameter_group_name", "default.aurora5.6"), + "aws_rds_cluster.default", "db_cluster_parameter_group_name", "default.aurora5.6"), ), }, }, @@ -50,7 +50,7 @@ func TestAccAWSRDSCluster_encrypted(t *testing.T) { resource.TestCheckResourceAttr( "aws_rds_cluster.default", "storage_encrypted", "true"), resource.TestCheckResourceAttr( - "aws_rds_cluster.default", "parameter_group_name", "default.aurora5.6"), + "aws_rds_cluster.default", "db_cluster_parameter_group_name", "default.aurora5.6"), ), }, }, @@ -168,7 +168,7 @@ resource "aws_rds_cluster" "default" { database_name = "mydb" master_username = "foo" master_password = "mustbeeightcharaters" - parameter_group_name = "default.aurora5.6" + db_cluster_parameter_group_name = "default.aurora5.6" }`, n) } diff --git a/website/source/docs/providers/aws/r/rds_cluster.html.markdown b/website/source/docs/providers/aws/r/rds_cluster.html.markdown index 852c37be9..5438cb10b 100644 --- a/website/source/docs/providers/aws/r/rds_cluster.html.markdown +++ b/website/source/docs/providers/aws/r/rds_cluster.html.markdown @@ -77,7 +77,7 @@ Default: A 30-minute window selected at random from an 8-hour block of time per are applied immediately, or during the next maintenance window. Default is `false`. See [Amazon RDS Documentation for more information.](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.Modifying.html) * `db_subnet_group_name` - (Optional) A DB subnet group to associate with this DB instance. **NOTE:** This must match the `db_subnet_group_name` specified on every [`aws_rds_cluster_instance`](/docs/providers/aws/r/rds_cluster_instance.html) in the cluster. -* `parameter_group_name` - (Optional) A cluster parameter group to associate with the cluster. +* `db_cluster_parameter_group_name` - (Optional) A cluster parameter group to associate with the cluster. ## Attributes Reference