Implement apply_method for RDS parameters

This is necessary to support creating parameter groups with parameters
that require a reboot, since the RDS API will return an error when
attempting to set those parameters with ApplyMethod "immediate".
This commit is contained in:
Phil Frost 2015-01-30 11:00:14 -05:00
parent 6947ba2518
commit 8eb5418c4a
3 changed files with 17 additions and 3 deletions

View File

@ -48,6 +48,19 @@ func resourceAwsDbParameterGroup() *schema.Resource {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
}, },
"apply_method": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Default: "immediate",
// this parameter is not actually state, but a
// meta-parameter describing how the RDS API call
// to modify the parameter group should be made.
// Future reads of the resource from AWS don't tell
// us what we used for apply_method previously, so
// by squashing state to an empty string we avoid
// needing to do an update for every future run.
StateFunc: func(interface{}) string { return "" },
},
}, },
}, },
Set: resourceAwsDbParameterHash, Set: resourceAwsDbParameterHash,

View File

@ -99,9 +99,7 @@ func expandParameters(configured []interface{}) ([]rds.Parameter, error) {
data := pRaw.(map[string]interface{}) data := pRaw.(map[string]interface{})
p := rds.Parameter{ p := rds.Parameter{
// Only immediate is supported for now; should add in pending-reboot at some point ApplyMethod: data["apply_method"].(string),
// but gets tricky as the DescribeParameterGroups AWS call doesn't return this data
ApplyMethod: "immediate",
ParameterName: data["name"].(string), ParameterName: data["name"].(string),
ParameterValue: data["value"].(string), ParameterValue: data["value"].(string),
} }

View File

@ -41,6 +41,9 @@ Parameter blocks support the following:
* `name` - (Required) The name of the DB parameter. * `name` - (Required) The name of the DB parameter.
* `value` - (Required) The value of the DB parameter. * `value` - (Required) The value of the DB parameter.
* `apply_method` - (Optional) "immediate" (default), or "pending-reboot". Some
engines can't apply some parameters without a reboot, and you will need to
specify "pending-reboot" here.
## Attributes Reference ## Attributes Reference