support aurora instance's parameter group and modifyinstance
This commit is contained in:
parent
322c885ea6
commit
38ac748b88
|
@ -58,13 +58,31 @@ 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,
|
||||
},
|
||||
|
||||
"status": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
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 +102,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 +191,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 +210,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 {
|
||||
|
|
Loading…
Reference in New Issue