Merge branch 'pr-6865'
* pr-6865: provider/aws: Add db_param group to RDS Cluster Instance test remove status attribute support aurora instance's parameter group and modifyinstance
This commit is contained in:
commit
b24228021f
|
@ -58,13 +58,26 @@ func resourceAwsRDSClusterInstance() *schema.Resource {
|
|||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: false,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"instance_class": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"db_parameter_group_name": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
// apply_immediately is used to determine when the update modifications
|
||||
// take place.
|
||||
// See http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.Modifying.html
|
||||
"apply_immediately": &schema.Schema{
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"tags": tagsSchema(),
|
||||
|
@ -84,6 +97,10 @@ func resourceAwsRDSClusterInstanceCreate(d *schema.ResourceData, meta interface{
|
|||
Tags: tags,
|
||||
}
|
||||
|
||||
if attr, ok := d.GetOk("db_parameter_group_name"); ok {
|
||||
createOpts.DBParameterGroupName = aws.String(attr.(string))
|
||||
}
|
||||
|
||||
if v := d.Get("identifier").(string); v != "" {
|
||||
createOpts.DBInstanceIdentifier = aws.String(v)
|
||||
} else {
|
||||
|
@ -169,6 +186,10 @@ func resourceAwsRDSClusterInstanceRead(d *schema.ResourceData, meta interface{})
|
|||
|
||||
d.Set("publicly_accessible", db.PubliclyAccessible)
|
||||
|
||||
if len(db.DBParameterGroups) > 0 {
|
||||
d.Set("parameter_group_name", db.DBParameterGroups[0].DBParameterGroupName)
|
||||
}
|
||||
|
||||
// Fetch and save tags
|
||||
arn, err := buildRDSARN(d.Id(), meta)
|
||||
if err != nil {
|
||||
|
@ -184,6 +205,50 @@ func resourceAwsRDSClusterInstanceRead(d *schema.ResourceData, meta interface{})
|
|||
|
||||
func resourceAwsRDSClusterInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||
conn := meta.(*AWSClient).rdsconn
|
||||
requestUpdate := false
|
||||
|
||||
req := &rds.ModifyDBInstanceInput{
|
||||
ApplyImmediately: aws.Bool(d.Get("apply_immediately").(bool)),
|
||||
DBInstanceIdentifier: aws.String(d.Id()),
|
||||
}
|
||||
|
||||
if d.HasChange("db_parameter_group_name") {
|
||||
req.DBParameterGroupName = aws.String(d.Get("db_parameter_group_name").(string))
|
||||
requestUpdate = true
|
||||
|
||||
}
|
||||
|
||||
if d.HasChange("instance_class") {
|
||||
req.DBInstanceClass = aws.String(d.Get("instance_class").(string))
|
||||
requestUpdate = true
|
||||
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Send DB Instance Modification request: %#v", requestUpdate)
|
||||
if requestUpdate {
|
||||
log.Printf("[DEBUG] DB Instance Modification request: %#v", req)
|
||||
_, err := conn.ModifyDBInstance(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error modifying DB Instance %s: %s", d.Id(), err)
|
||||
}
|
||||
|
||||
// reuse db_instance refresh func
|
||||
stateConf := &resource.StateChangeConf{
|
||||
Pending: []string{"creating", "backing-up", "modifying"},
|
||||
Target: []string{"available"},
|
||||
Refresh: resourceAwsDbInstanceStateRefreshFunc(d, meta),
|
||||
Timeout: 40 * time.Minute,
|
||||
MinTimeout: 10 * time.Second,
|
||||
Delay: 10 * time.Second,
|
||||
}
|
||||
|
||||
// Wait, catching any errors
|
||||
_, err = stateConf.WaitForState()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if arn, err := buildRDSARN(d.Id(), meta); err == nil {
|
||||
if err := setTagsRDS(conn, d, arn); err != nil {
|
||||
|
|
|
@ -177,10 +177,25 @@ resource "aws_rds_cluster" "default" {
|
|||
}
|
||||
|
||||
resource "aws_rds_cluster_instance" "cluster_instances" {
|
||||
identifier = "tf-cluster-instance-%d"
|
||||
cluster_identifier = "${aws_rds_cluster.default.id}"
|
||||
instance_class = "db.r3.large"
|
||||
identifier = "tf-cluster-instance-%d"
|
||||
cluster_identifier = "${aws_rds_cluster.default.id}"
|
||||
instance_class = "db.r3.large"
|
||||
db_parameter_group_name = "${aws_db_parameter_group.bar.name}"
|
||||
}
|
||||
|
||||
resource "aws_db_parameter_group" "bar" {
|
||||
name = "tfcluster-test-group"
|
||||
family = "aurora5.6"
|
||||
|
||||
parameter {
|
||||
name = "back_log"
|
||||
value = "32767"
|
||||
apply_method = "pending-reboot"
|
||||
}
|
||||
|
||||
tags {
|
||||
foo = "bar"
|
||||
}
|
||||
}
|
||||
`, n, n)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue