|
|
|
|
@ -9,7 +9,9 @@ import (
|
|
|
|
|
"github.com/hashicorp/terraform/helper/hashcode"
|
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
|
|
|
"github.com/mitchellh/goamz/rds"
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/aws-sdk-go/aws"
|
|
|
|
|
"github.com/hashicorp/aws-sdk-go/gen/rds"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func resourceAwsDbParameterGroup() *schema.Resource {
|
|
|
|
|
@ -70,12 +72,12 @@ func resourceAwsDbParameterGroup() *schema.Resource {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{}) error {
|
|
|
|
|
rdsconn := meta.(*AWSClient).rdsconn
|
|
|
|
|
rdsconn := meta.(*AWSClient).awsRDSconn
|
|
|
|
|
|
|
|
|
|
createOpts := rds.CreateDBParameterGroup{
|
|
|
|
|
DBParameterGroupName: d.Get("name").(string),
|
|
|
|
|
DBParameterGroupFamily: d.Get("family").(string),
|
|
|
|
|
Description: d.Get("description").(string),
|
|
|
|
|
createOpts := rds.CreateDBParameterGroupMessage{
|
|
|
|
|
DBParameterGroupName: aws.String(d.Get("name").(string)),
|
|
|
|
|
DBParameterGroupFamily: aws.String(d.Get("family").(string)),
|
|
|
|
|
Description: aws.String(d.Get("description").(string)),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.Printf("[DEBUG] Create DB Parameter Group: %#v", createOpts)
|
|
|
|
|
@ -90,17 +92,17 @@ func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{})
|
|
|
|
|
d.SetPartial("description")
|
|
|
|
|
d.Partial(false)
|
|
|
|
|
|
|
|
|
|
d.SetId(createOpts.DBParameterGroupName)
|
|
|
|
|
d.SetId(*createOpts.DBParameterGroupName)
|
|
|
|
|
log.Printf("[INFO] DB Parameter Group ID: %s", d.Id())
|
|
|
|
|
|
|
|
|
|
return resourceAwsDbParameterGroupUpdate(d, meta)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) error {
|
|
|
|
|
rdsconn := meta.(*AWSClient).rdsconn
|
|
|
|
|
rdsconn := meta.(*AWSClient).awsRDSconn
|
|
|
|
|
|
|
|
|
|
describeOpts := rds.DescribeDBParameterGroups{
|
|
|
|
|
DBParameterGroupName: d.Id(),
|
|
|
|
|
describeOpts := rds.DescribeDBParameterGroupsMessage{
|
|
|
|
|
DBParameterGroupName: aws.String(d.Id()),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describeResp, err := rdsconn.DescribeDBParameterGroups(&describeOpts)
|
|
|
|
|
@ -109,7 +111,7 @@ func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) e
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(describeResp.DBParameterGroups) != 1 ||
|
|
|
|
|
describeResp.DBParameterGroups[0].DBParameterGroupName != d.Id() {
|
|
|
|
|
*describeResp.DBParameterGroups[0].DBParameterGroupName != d.Id() {
|
|
|
|
|
return fmt.Errorf("Unable to find Parameter Group: %#v", describeResp.DBParameterGroups)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -118,9 +120,9 @@ func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) e
|
|
|
|
|
d.Set("description", describeResp.DBParameterGroups[0].Description)
|
|
|
|
|
|
|
|
|
|
// Only include user customized parameters as there's hundreds of system/default ones
|
|
|
|
|
describeParametersOpts := rds.DescribeDBParameters{
|
|
|
|
|
DBParameterGroupName: d.Id(),
|
|
|
|
|
Source: "user",
|
|
|
|
|
describeParametersOpts := rds.DescribeDBParametersMessage{
|
|
|
|
|
DBParameterGroupName: aws.String(d.Id()),
|
|
|
|
|
Source: aws.String("user"),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describeParametersResp, err := rdsconn.DescribeDBParameters(&describeParametersOpts)
|
|
|
|
|
@ -134,7 +136,7 @@ func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) e
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func resourceAwsDbParameterGroupUpdate(d *schema.ResourceData, meta interface{}) error {
|
|
|
|
|
rdsconn := meta.(*AWSClient).rdsconn
|
|
|
|
|
rdsconn := meta.(*AWSClient).awsRDSconn
|
|
|
|
|
|
|
|
|
|
d.Partial(true)
|
|
|
|
|
|
|
|
|
|
@ -157,8 +159,8 @@ func resourceAwsDbParameterGroupUpdate(d *schema.ResourceData, meta interface{})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(parameters) > 0 {
|
|
|
|
|
modifyOpts := rds.ModifyDBParameterGroup{
|
|
|
|
|
DBParameterGroupName: d.Get("name").(string),
|
|
|
|
|
modifyOpts := rds.ModifyDBParameterGroupMessage{
|
|
|
|
|
DBParameterGroupName: aws.String(d.Get("name").(string)),
|
|
|
|
|
Parameters: parameters,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -191,16 +193,16 @@ func resourceAwsDbParameterGroupDelete(d *schema.ResourceData, meta interface{})
|
|
|
|
|
func resourceAwsDbParameterGroupDeleteRefreshFunc(
|
|
|
|
|
d *schema.ResourceData,
|
|
|
|
|
meta interface{}) resource.StateRefreshFunc {
|
|
|
|
|
rdsconn := meta.(*AWSClient).rdsconn
|
|
|
|
|
rdsconn := meta.(*AWSClient).awsRDSconn
|
|
|
|
|
|
|
|
|
|
return func() (interface{}, string, error) {
|
|
|
|
|
|
|
|
|
|
deleteOpts := rds.DeleteDBParameterGroup{
|
|
|
|
|
DBParameterGroupName: d.Id(),
|
|
|
|
|
deleteOpts := rds.DeleteDBParameterGroupMessage{
|
|
|
|
|
DBParameterGroupName: aws.String(d.Id()),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if _, err := rdsconn.DeleteDBParameterGroup(&deleteOpts); err != nil {
|
|
|
|
|
rdserr, ok := err.(*rds.Error)
|
|
|
|
|
if err := rdsconn.DeleteDBParameterGroup(&deleteOpts); err != nil {
|
|
|
|
|
rdserr, ok := err.(aws.APIError)
|
|
|
|
|
if !ok {
|
|
|
|
|
return d, "error", err
|
|
|
|
|
}
|
|
|
|
|
|