provider/aws: Convert remaining RDS resources to use upstream library

This commit is contained in:
Clint Shryock 2015-04-13 15:45:55 -05:00
parent d579b4b75c
commit 9187cab6ac
11 changed files with 98 additions and 100 deletions

View File

@ -11,14 +11,13 @@ import (
"github.com/hashicorp/aws-sdk-go/gen/autoscaling"
"github.com/hashicorp/aws-sdk-go/gen/ec2"
"github.com/hashicorp/aws-sdk-go/gen/iam"
"github.com/hashicorp/aws-sdk-go/gen/rds"
"github.com/hashicorp/aws-sdk-go/gen/route53"
"github.com/hashicorp/aws-sdk-go/gen/s3"
awsSDK "github.com/awslabs/aws-sdk-go/aws"
awsIAM "github.com/awslabs/aws-sdk-go/service/IAM"
awsEC2 "github.com/awslabs/aws-sdk-go/service/ec2"
awsRDS "github.com/awslabs/aws-sdk-go/service/rds"
"github.com/awslabs/aws-sdk-go/service/rds"
)
type Config struct {
@ -38,7 +37,6 @@ type AWSClient struct {
rdsconn *rds.RDS
iamconn *iam.IAM
ec2SDKconn *awsEC2.EC2
rdsSDKconn *awsRDS.RDS
iamSDKconn *awsIAM.IAM
}
@ -78,8 +76,6 @@ func (c *Config) Client() (interface{}, error) {
client.autoscalingconn = autoscaling.New(creds, c.Region, nil)
log.Println("[INFO] Initializing S3 connection")
client.s3conn = s3.New(creds, c.Region, nil)
log.Println("[INFO] Initializing RDS connection")
client.rdsconn = rds.New(creds, c.Region, nil)
// aws-sdk-go uses v4 for signing requests, which requires all global
// endpoints to use 'us-east-1'.
@ -93,7 +89,7 @@ func (c *Config) Client() (interface{}, error) {
client.ec2SDKconn = awsEC2.New(awsConfig)
log.Println("[INFO] Initializing RDS SDK Connection")
client.rdsSDKconn = awsRDS.New(awsConfig)
client.rdsconn = rds.New(awsConfig)
log.Println("[INFO] Initializing IAM SDK Connection")
client.iamSDKconn = awsIAM.New(awsConfig)

View File

@ -5,9 +5,9 @@ import (
"log"
"time"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/IAM"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/IAM"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
@ -194,10 +194,10 @@ func resourceAwsDbInstance() *schema.Resource {
}
func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).rdsSDKconn
conn := meta.(*AWSClient).rdsconn
tags := tagsFromMapRDS(d.Get("tags").(map[string]interface{}))
opts := rds.CreateDBInstanceInput{
AllocatedStorage: aws.Long(int64(d.Get("allocated_storage").(int))),
opts := rds.CreateDBInstanceInput{
AllocatedStorage: aws.Long(int64(d.Get("allocated_storage").(int))),
DBInstanceClass: aws.String(d.Get("instance_class").(string)),
DBInstanceIdentifier: aws.String(d.Get("identifier").(string)),
DBName: aws.String(d.Get("name").(string)),
@ -214,14 +214,14 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
}
attr := d.Get("backup_retention_period")
opts.BackupRetentionPeriod = aws.Long(int64(attr.(int)))
opts.BackupRetentionPeriod = aws.Long(int64(attr.(int)))
if attr, ok := d.GetOk("iops"); ok {
opts.IOPS = aws.Long(int64(attr.(int)))
opts.IOPS = aws.Long(int64(attr.(int)))
}
if attr, ok := d.GetOk("port"); ok {
opts.Port = aws.Long(int64(attr.(int)))
opts.Port = aws.Long(int64(attr.(int)))
}
if attr, ok := d.GetOk("multi_az"); ok {
@ -253,17 +253,17 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
}
if attr := d.Get("vpc_security_group_ids").(*schema.Set); attr.Len() > 0 {
var s []*string
var s []*string
for _, v := range attr.List() {
s = append(s, aws.String(v.(string)))
s = append(s, aws.String(v.(string)))
}
opts.VPCSecurityGroupIDs = s
}
if attr := d.Get("security_group_names").(*schema.Set); attr.Len() > 0 {
var s []*string
var s []*string
for _, v := range attr.List() {
s = append(s, aws.String(v.(string)))
s = append(s, aws.String(v.(string)))
}
opts.DBSecurityGroups = s
}
@ -345,7 +345,7 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
// list tags for resource
// set tags
conn := meta.(*AWSClient).rdsSDKconn
conn := meta.(*AWSClient).rdsconn
arn, err := buildRDSARN(d, meta)
if err != nil {
name := "<empty>"
@ -355,7 +355,7 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Error building ARN for DB Instance, not setting Tags for DB %s", name)
} else {
resp, err := conn.ListTagsForResource(&rds.ListTagsForResourceInput{
resp, err := conn.ListTagsForResource(&rds.ListTagsForResourceInput{
ResourceName: aws.String(arn),
})
@ -363,7 +363,7 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Error retreiving tags for ARN: %s", arn)
}
var dt []*rds.Tag
var dt []*rds.Tag
if len(resp.TagList) > 0 {
dt = resp.TagList
}
@ -396,11 +396,11 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
}
func resourceAwsDbInstanceDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).rdsSDKconn
conn := meta.(*AWSClient).rdsconn
log.Printf("[DEBUG] DB Instance destroy: %v", d.Id())
opts := rds.DeleteDBInstanceInput{DBInstanceIdentifier: aws.String(d.Id())}
opts := rds.DeleteDBInstanceInput{DBInstanceIdentifier: aws.String(d.Id())}
finalSnapshot := d.Get("final_snapshot_identifier").(string)
if finalSnapshot == "" {
@ -433,11 +433,11 @@ func resourceAwsDbInstanceDelete(d *schema.ResourceData, meta interface{}) error
}
func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).rdsSDKconn
conn := meta.(*AWSClient).rdsconn
d.Partial(true)
req := &rds.ModifyDBInstanceInput{
req := &rds.ModifyDBInstanceInput{
ApplyImmediately: aws.Boolean(d.Get("apply_immediately").(bool)),
DBInstanceIdentifier: aws.String(d.Id()),
}
@ -445,11 +445,11 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
if d.HasChange("allocated_storage") {
d.SetPartial("allocated_storage")
req.AllocatedStorage = aws.Long(int64(d.Get("allocated_storage").(int)))
req.AllocatedStorage = aws.Long(int64(d.Get("allocated_storage").(int)))
}
if d.HasChange("backup_retention_period") {
d.SetPartial("backup_retention_period")
req.BackupRetentionPeriod = aws.Long(int64(d.Get("backup_retention_period").(int)))
req.BackupRetentionPeriod = aws.Long(int64(d.Get("backup_retention_period").(int)))
}
if d.HasChange("instance_class") {
d.SetPartial("instance_class")
@ -465,7 +465,7 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
}
if d.HasChange("iops") {
d.SetPartial("iops")
req.IOPS = aws.Long(int64(d.Get("iops").(int)))
req.IOPS = aws.Long(int64(d.Get("iops").(int)))
}
if d.HasChange("backup_window") {
d.SetPartial("backup_window")
@ -490,9 +490,9 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
if d.HasChange("vpc_security_group_ids") {
if attr := d.Get("vpc_security_group_ids").(*schema.Set); attr.Len() > 0 {
var s []*string
var s []*string
for _, v := range attr.List() {
s = append(s, aws.String(v.(string)))
s = append(s, aws.String(v.(string)))
}
req.VPCSecurityGroupIDs = s
}
@ -500,9 +500,9 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
if d.HasChange("vpc_security_group_ids") {
if attr := d.Get("security_group_names").(*schema.Set); attr.Len() > 0 {
var s []*string
var s []*string
for _, v := range attr.List() {
s = append(s, aws.String(v.(string)))
s = append(s, aws.String(v.(string)))
}
req.DBSecurityGroups = s
}
@ -527,9 +527,9 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
func resourceAwsBbInstanceRetrieve(
d *schema.ResourceData, meta interface{}) (*rds.DBInstance, error) {
conn := meta.(*AWSClient).rdsSDKconn
conn := meta.(*AWSClient).rdsconn
opts := rds.DescribeDBInstancesInput{
opts := rds.DescribeDBInstancesInput{
DBInstanceIdentifier: aws.String(d.Id()),
}
@ -552,7 +552,7 @@ func resourceAwsBbInstanceRetrieve(
}
}
return resp.DBInstances[0], nil
return resp.DBInstances[0], nil
}
func resourceAwsDbInstanceStateRefreshFunc(
@ -574,10 +574,10 @@ func resourceAwsDbInstanceStateRefreshFunc(
}
func buildRDSARN(d *schema.ResourceData, meta interface{}) (string, error) {
iamconn := meta.(*AWSClient).iamSDKconn
iamconn := meta.(*AWSClient).iamSDKconn
region := meta.(*AWSClient).region
// An zero value GetUserInput{} defers to the currently logged in user
resp, err := iamconn.GetUser(&iam.GetUserInput{})
// An zero value GetUserInput{} defers to the currently logged in user
resp, err := iamconn.GetUser(&iam.GetUserInput{})
if err != nil {
return "", err
}

View File

@ -9,8 +9,8 @@ import (
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
)
func TestAccAWSDBInstance(t *testing.T) {
@ -47,7 +47,7 @@ func TestAccAWSDBInstance(t *testing.T) {
}
func testAccCheckAWSDBInstanceDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).rdsSDKconn
conn := testAccProvider.Meta().(*AWSClient).rdsconn
for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_db_instance" {
@ -56,7 +56,7 @@ func testAccCheckAWSDBInstanceDestroy(s *terraform.State) error {
// Try to find the Group
resp, err := conn.DescribeDBInstances(
&rds.DescribeDBInstancesInput{
&rds.DescribeDBInstancesInput{
DBInstanceIdentifier: aws.String(rs.Primary.ID),
})
@ -110,9 +110,9 @@ func testAccCheckAWSDBInstanceExists(n string, v *rds.DBInstance) resource.TestC
return fmt.Errorf("No DB Instance ID is set")
}
conn := testAccProvider.Meta().(*AWSClient).rdsSDKconn
conn := testAccProvider.Meta().(*AWSClient).rdsconn
opts := rds.DescribeDBInstancesInput{
opts := rds.DescribeDBInstancesInput{
DBInstanceIdentifier: aws.String(rs.Primary.ID),
}
@ -127,7 +127,7 @@ func testAccCheckAWSDBInstanceExists(n string, v *rds.DBInstance) resource.TestC
return fmt.Errorf("DB Instance not found")
}
*v = *resp.DBInstances[0]
*v = *resp.DBInstances[0]
return nil
}

View File

@ -11,8 +11,8 @@ import (
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/aws-sdk-go/aws"
"github.com/hashicorp/aws-sdk-go/gen/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
)
func resourceAwsDbParameterGroup() *schema.Resource {
@ -75,7 +75,7 @@ func resourceAwsDbParameterGroup() *schema.Resource {
func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).rdsconn
createOpts := rds.CreateDBParameterGroupMessage{
createOpts := rds.CreateDBParameterGroupInput{
DBParameterGroupName: aws.String(d.Get("name").(string)),
DBParameterGroupFamily: aws.String(d.Get("family").(string)),
Description: aws.String(d.Get("description").(string)),
@ -102,7 +102,7 @@ func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{})
func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).rdsconn
describeOpts := rds.DescribeDBParameterGroupsMessage{
describeOpts := rds.DescribeDBParameterGroupsInput{
DBParameterGroupName: aws.String(d.Id()),
}
@ -121,7 +121,7 @@ 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.DescribeDBParametersMessage{
describeParametersOpts := rds.DescribeDBParametersInput{
DBParameterGroupName: aws.String(d.Id()),
Source: aws.String("user"),
}
@ -131,7 +131,7 @@ func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) e
return err
}
d.Set("parameter", flattenParameters(describeParametersResp.Parameters))
d.Set("parameter", flattenParametersSDK(describeParametersResp.Parameters))
return nil
}
@ -154,13 +154,13 @@ func resourceAwsDbParameterGroupUpdate(d *schema.ResourceData, meta interface{})
ns := n.(*schema.Set)
// Expand the "parameter" set to aws-sdk-go compat []rds.Parameter
parameters, err := expandParameters(ns.Difference(os).List())
parameters, err := expandParametersSDK(ns.Difference(os).List())
if err != nil {
return err
}
if len(parameters) > 0 {
modifyOpts := rds.ModifyDBParameterGroupMessage{
modifyOpts := rds.ModifyDBParameterGroupInput{
DBParameterGroupName: aws.String(d.Get("name").(string)),
Parameters: parameters,
}
@ -198,11 +198,11 @@ func resourceAwsDbParameterGroupDeleteRefreshFunc(
return func() (interface{}, string, error) {
deleteOpts := rds.DeleteDBParameterGroupMessage{
deleteOpts := rds.DeleteDBParameterGroupInput{
DBParameterGroupName: aws.String(d.Id()),
}
if err := rdsconn.DeleteDBParameterGroup(&deleteOpts); err != nil {
if _, err := rdsconn.DeleteDBParameterGroup(&deleteOpts); err != nil {
rdserr, ok := err.(aws.APIError)
if !ok {
return d, "error", err

View File

@ -4,8 +4,8 @@ import (
"fmt"
"testing"
"github.com/hashicorp/aws-sdk-go/aws"
"github.com/hashicorp/aws-sdk-go/gen/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
@ -115,7 +115,7 @@ func testAccCheckAWSDBParameterGroupDestroy(s *terraform.State) error {
// Try to find the Group
resp, err := conn.DescribeDBParameterGroups(
&rds.DescribeDBParameterGroupsMessage{
&rds.DescribeDBParameterGroupsInput{
DBParameterGroupName: aws.String(rs.Primary.ID),
})
@ -171,7 +171,7 @@ func testAccCheckAWSDBParameterGroupExists(n string, v *rds.DBParameterGroup) re
conn := testAccProvider.Meta().(*AWSClient).rdsconn
opts := rds.DescribeDBParameterGroupsMessage{
opts := rds.DescribeDBParameterGroupsInput{
DBParameterGroupName: aws.String(rs.Primary.ID),
}
@ -186,7 +186,7 @@ func testAccCheckAWSDBParameterGroupExists(n string, v *rds.DBParameterGroup) re
return fmt.Errorf("DB Parameter Group not found")
}
*v = resp.DBParameterGroups[0]
*v = *resp.DBParameterGroups[0]
return nil
}

View File

@ -6,8 +6,8 @@ import (
"log"
"time"
"github.com/hashicorp/aws-sdk-go/aws"
"github.com/hashicorp/aws-sdk-go/gen/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/multierror"
"github.com/hashicorp/terraform/helper/resource"
@ -75,7 +75,7 @@ func resourceAwsDbSecurityGroupCreate(d *schema.ResourceData, meta interface{})
var err error
var errs []error
opts := rds.CreateDBSecurityGroupMessage{
opts := rds.CreateDBSecurityGroupInput{
DBSecurityGroupName: aws.String(d.Get("name").(string)),
DBSecurityGroupDescription: aws.String(d.Get("description").(string)),
}
@ -164,10 +164,10 @@ func resourceAwsDbSecurityGroupDelete(d *schema.ResourceData, meta interface{})
log.Printf("[DEBUG] DB Security Group destroy: %v", d.Id())
opts := rds.DeleteDBSecurityGroupMessage{DBSecurityGroupName: aws.String(d.Id())}
opts := rds.DeleteDBSecurityGroupInput{DBSecurityGroupName: aws.String(d.Id())}
log.Printf("[DEBUG] DB Security Group destroy configuration: %v", opts)
err := conn.DeleteDBSecurityGroup(&opts)
_, err := conn.DeleteDBSecurityGroup(&opts)
if err != nil {
newerr, ok := err.(aws.APIError)
@ -183,7 +183,7 @@ func resourceAwsDbSecurityGroupDelete(d *schema.ResourceData, meta interface{})
func resourceAwsDbSecurityGroupRetrieve(d *schema.ResourceData, meta interface{}) (*rds.DBSecurityGroup, error) {
conn := meta.(*AWSClient).rdsconn
opts := rds.DescribeDBSecurityGroupsMessage{
opts := rds.DescribeDBSecurityGroupsInput{
DBSecurityGroupName: aws.String(d.Id()),
}
@ -200,16 +200,14 @@ func resourceAwsDbSecurityGroupRetrieve(d *schema.ResourceData, meta interface{}
return nil, fmt.Errorf("Unable to find DB Security Group: %#v", resp.DBSecurityGroups)
}
v := resp.DBSecurityGroups[0]
return &v, nil
return resp.DBSecurityGroups[0], nil
}
// Authorizes the ingress rule on the db security group
func resourceAwsDbSecurityGroupAuthorizeRule(ingress interface{}, dbSecurityGroupName string, conn *rds.RDS) error {
ing := ingress.(map[string]interface{})
opts := rds.AuthorizeDBSecurityGroupIngressMessage{
opts := rds.AuthorizeDBSecurityGroupIngressInput{
DBSecurityGroupName: aws.String(dbSecurityGroupName),
}

View File

@ -4,8 +4,8 @@ import (
"fmt"
"testing"
"github.com/hashicorp/aws-sdk-go/aws"
"github.com/hashicorp/aws-sdk-go/gen/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
@ -47,7 +47,7 @@ func testAccCheckAWSDBSecurityGroupDestroy(s *terraform.State) error {
// Try to find the Group
resp, err := conn.DescribeDBSecurityGroups(
&rds.DescribeDBSecurityGroupsMessage{
&rds.DescribeDBSecurityGroupsInput{
DBSecurityGroupName: aws.String(rs.Primary.ID),
})
@ -115,7 +115,7 @@ func testAccCheckAWSDBSecurityGroupExists(n string, v *rds.DBSecurityGroup) reso
conn := testAccProvider.Meta().(*AWSClient).rdsconn
opts := rds.DescribeDBSecurityGroupsMessage{
opts := rds.DescribeDBSecurityGroupsInput{
DBSecurityGroupName: aws.String(rs.Primary.ID),
}
@ -130,13 +130,17 @@ func testAccCheckAWSDBSecurityGroupExists(n string, v *rds.DBSecurityGroup) reso
return fmt.Errorf("DB Security Group not found")
}
*v = resp.DBSecurityGroups[0]
*v = *resp.DBSecurityGroups[0]
return nil
}
}
const testAccAWSDBSecurityGroupConfig = `
provider "aws" {
region = "us-east-1"
}
resource "aws_db_security_group" "bar" {
name = "secgroup-terraform"
description = "just cuz"

View File

@ -6,8 +6,8 @@ import (
"strings"
"time"
"github.com/hashicorp/aws-sdk-go/aws"
"github.com/hashicorp/aws-sdk-go/gen/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
@ -49,12 +49,12 @@ func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) er
rdsconn := meta.(*AWSClient).rdsconn
subnetIdsSet := d.Get("subnet_ids").(*schema.Set)
subnetIds := make([]string, subnetIdsSet.Len())
subnetIds := make([]*string, subnetIdsSet.Len())
for i, subnetId := range subnetIdsSet.List() {
subnetIds[i] = subnetId.(string)
subnetIds[i] = aws.String(subnetId.(string))
}
createOpts := rds.CreateDBSubnetGroupMessage{
createOpts := rds.CreateDBSubnetGroupInput{
DBSubnetGroupName: aws.String(d.Get("name").(string)),
DBSubnetGroupDescription: aws.String(d.Get("description").(string)),
SubnetIDs: subnetIds,
@ -74,7 +74,7 @@ func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) er
func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).rdsconn
describeOpts := rds.DescribeDBSubnetGroupsMessage{
describeOpts := rds.DescribeDBSubnetGroupsInput{
DBSubnetGroupName: aws.String(d.Id()),
}
@ -92,7 +92,7 @@ func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) erro
return fmt.Errorf("Unable to find DB Subnet Group: %#v", describeResp.DBSubnetGroups)
}
var subnetGroup rds.DBSubnetGroup
var subnetGroup *rds.DBSubnetGroup
for _, s := range describeResp.DBSubnetGroups {
// AWS is down casing the name provided, so we compare lower case versions
// of the names. We lower case both our name and their name in the check,
@ -137,11 +137,11 @@ func resourceAwsDbSubnetGroupDeleteRefreshFunc(
return func() (interface{}, string, error) {
deleteOpts := rds.DeleteDBSubnetGroupMessage{
deleteOpts := rds.DeleteDBSubnetGroupInput{
DBSubnetGroupName: aws.String(d.Id()),
}
if err := rdsconn.DeleteDBSubnetGroup(&deleteOpts); err != nil {
if _, err := rdsconn.DeleteDBSubnetGroup(&deleteOpts); err != nil {
rdserr, ok := err.(aws.APIError)
if !ok {
return d, "error", err

View File

@ -7,8 +7,8 @@ import (
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
"github.com/hashicorp/aws-sdk-go/aws"
"github.com/hashicorp/aws-sdk-go/gen/rds"
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/rds"
)
func TestAccAWSDBSubnetGroup(t *testing.T) {
@ -45,7 +45,7 @@ func testAccCheckDBSubnetGroupDestroy(s *terraform.State) error {
// Try to find the resource
resp, err := conn.DescribeDBSubnetGroups(
&rds.DescribeDBSubnetGroupsMessage{DBSubnetGroupName: aws.String(rs.Primary.ID)})
&rds.DescribeDBSubnetGroupsInput{DBSubnetGroupName: aws.String(rs.Primary.ID)})
if err == nil {
if len(resp.DBSubnetGroups) > 0 {
return fmt.Errorf("still exist.")
@ -80,7 +80,7 @@ func testAccCheckDBSubnetGroupExists(n string, v *rds.DBSubnetGroup) resource.Te
conn := testAccProvider.Meta().(*AWSClient).rdsconn
resp, err := conn.DescribeDBSubnetGroups(
&rds.DescribeDBSubnetGroupsMessage{DBSubnetGroupName: aws.String(rs.Primary.ID)})
&rds.DescribeDBSubnetGroupsInput{DBSubnetGroupName: aws.String(rs.Primary.ID)})
if err != nil {
return err
}
@ -88,7 +88,7 @@ func testAccCheckDBSubnetGroupExists(n string, v *rds.DBSubnetGroup) resource.Te
return fmt.Errorf("DbSubnetGroup not found")
}
*v = resp.DBSubnetGroups[0]
*v = *resp.DBSubnetGroups[0]
return nil
}

View File

@ -6,7 +6,7 @@ import (
"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/ec2"
"github.com/awslabs/aws-sdk-go/service/elb"
"github.com/hashicorp/aws-sdk-go/gen/rds"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/schema"
)
@ -105,15 +105,15 @@ func expandIPPermsSDK(
// Takes the result of flatmap.Expand for an array of parameters and
// returns Parameter API compatible objects
func expandParametersSDK(configured []interface{}) ([]rds.Parameter, error) {
parameters := make([]rds.Parameter, 0, len(configured))
func expandParametersSDK(configured []interface{}) ([]*rds.Parameter, error) {
parameters := make([]*rds.Parameter, 0, len(configured))
// Loop over our configured parameters and create
// an array of aws-sdk-go compatabile objects
for _, pRaw := range configured {
data := pRaw.(map[string]interface{})
p := rds.Parameter{
p := &rds.Parameter{
ApplyMethod: aws.String(data["apply_method"].(string)),
ParameterName: aws.String(data["name"].(string)),
ParameterValue: aws.String(data["value"].(string)),
@ -189,7 +189,7 @@ func flattenListenersSDK(list []*elb.ListenerDescription) []map[string]interface
}
// Flattens an array of Parameters into a []map[string]interface{}
func flattenParametersSDK(list []rds.Parameter) []map[string]interface{} {
func flattenParametersSDK(list []*rds.Parameter) []map[string]interface{} {
result := make([]map[string]interface{}, 0, len(list))
for _, i := range list {
result = append(result, map[string]interface{}{

View File

@ -6,8 +6,8 @@ import (
"github.com/awslabs/aws-sdk-go/service/ec2"
"github.com/awslabs/aws-sdk-go/service/elb"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/aws-sdk-go/aws"
"github.com/hashicorp/aws-sdk-go/gen/rds"
"github.com/hashicorp/terraform/flatmap"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
@ -285,7 +285,7 @@ func TestExpandParametersSDK(t *testing.T) {
t.Fatalf("bad: %#v", err)
}
expected := rds.Parameter{
expected := &rds.Parameter{
ParameterName: aws.String("character_set_client"),
ParameterValue: aws.String("utf8"),
ApplyMethod: aws.String("immediate"),
@ -301,12 +301,12 @@ func TestExpandParametersSDK(t *testing.T) {
func TestFlattenParametersSDK(t *testing.T) {
cases := []struct {
Input []rds.Parameter
Input []*rds.Parameter
Output []map[string]interface{}
}{
{
Input: []rds.Parameter{
rds.Parameter{
Input: []*rds.Parameter{
&rds.Parameter{
ParameterName: aws.String("character_set_client"),
ParameterValue: aws.String("utf8"),
},