Merge pull request #1510 from hashicorp/f-aws-upstream-rds-instance

provider/aws: Convert AWS RDS to use upstream aws-sdk-go
This commit is contained in:
Clint 2015-04-15 15:23:52 -05:00
commit 334b157a5c
13 changed files with 119 additions and 115 deletions

View File

@ -10,13 +10,13 @@ import (
"github.com/hashicorp/aws-sdk-go/aws"
"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"
awsEC2 "github.com/awslabs/aws-sdk-go/service/ec2"
"github.com/awslabs/aws-sdk-go/service/iam"
"github.com/awslabs/aws-sdk-go/service/rds"
)
type Config struct {
@ -60,19 +60,20 @@ func (c *Config) Client() (interface{}, error) {
log.Println("[INFO] Building AWS auth structure")
creds := aws.DetectCreds(c.AccessKey, c.SecretKey, c.Token)
log.Println("[INFO] Building AWS SDK auth structure")
sdkCreds := awsSDK.DetectCreds(c.AccessKey, c.SecretKey, c.Token)
log.Println("[INFO] Initializing ELB connection")
client.elbconn = elb.New(&awsSDK.Config{
awsConfig := &awsSDK.Config{
Credentials: sdkCreds,
Region: c.Region,
})
}
log.Println("[INFO] Initializing ELB SDK connection")
client.elbconn = elb.New(awsConfig)
log.Println("[INFO] Initializing AutoScaling connection")
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'.
@ -81,12 +82,15 @@ func (c *Config) Client() (interface{}, error) {
client.r53conn = route53.New(creds, "us-east-1", nil)
log.Println("[INFO] Initializing EC2 Connection")
client.ec2conn = ec2.New(creds, c.Region, nil)
client.iamconn = iam.New(creds, c.Region, nil)
client.ec2SDKconn = awsEC2.New(&awsSDK.Config{
Credentials: sdkCreds,
Region: c.Region,
})
log.Println("[INFO] Initializing EC2 SDK Connection")
client.ec2SDKconn = awsEC2.New(awsConfig)
log.Println("[INFO] Initializing RDS SDK Connection")
client.rdsconn = rds.New(awsConfig)
log.Println("[INFO] Initializing IAM SDK Connection")
client.iamconn = iam.New(awsConfig)
}
if len(errs) > 0 {

View File

@ -5,9 +5,9 @@ import (
"log"
"time"
"github.com/hashicorp/aws-sdk-go/aws"
"github.com/hashicorp/aws-sdk-go/gen/iam"
"github.com/hashicorp/aws-sdk-go/gen/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"
@ -196,8 +196,8 @@ func resourceAwsDbInstance() *schema.Resource {
func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).rdsconn
tags := tagsFromMapRDS(d.Get("tags").(map[string]interface{}))
opts := rds.CreateDBInstanceMessage{
AllocatedStorage: aws.Integer(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.Integer(attr.(int))
opts.BackupRetentionPeriod = aws.Long(int64(attr.(int)))
if attr, ok := d.GetOk("iops"); ok {
opts.IOPS = aws.Integer(attr.(int))
opts.IOPS = aws.Long(int64(attr.(int)))
}
if attr, ok := d.GetOk("port"); ok {
opts.Port = aws.Integer(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, 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, v.(string))
s = append(s, aws.String(v.(string)))
}
opts.DBSecurityGroups = s
}
@ -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.ListTagsForResourceMessage{
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
}
@ -400,7 +400,7 @@ func resourceAwsDbInstanceDelete(d *schema.ResourceData, meta interface{}) error
log.Printf("[DEBUG] DB Instance destroy: %v", d.Id())
opts := rds.DeleteDBInstanceMessage{DBInstanceIdentifier: aws.String(d.Id())}
opts := rds.DeleteDBInstanceInput{DBInstanceIdentifier: aws.String(d.Id())}
finalSnapshot := d.Get("final_snapshot_identifier").(string)
if finalSnapshot == "" {
@ -437,7 +437,7 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
d.Partial(true)
req := &rds.ModifyDBInstanceMessage{
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.Integer(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.Integer(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.Integer(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, 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, v.(string))
s = append(s, aws.String(v.(string)))
}
req.DBSecurityGroups = s
}
@ -529,7 +529,7 @@ func resourceAwsBbInstanceRetrieve(
d *schema.ResourceData, meta interface{}) (*rds.DBInstance, error) {
conn := meta.(*AWSClient).rdsconn
opts := rds.DescribeDBInstancesMessage{
opts := rds.DescribeDBInstancesInput{
DBInstanceIdentifier: aws.String(d.Id()),
}
@ -552,9 +552,7 @@ func resourceAwsBbInstanceRetrieve(
}
}
v := resp.DBInstances[0]
return &v, nil
return resp.DBInstances[0], nil
}
func resourceAwsDbInstanceStateRefreshFunc(
@ -578,8 +576,8 @@ func resourceAwsDbInstanceStateRefreshFunc(
func buildRDSARN(d *schema.ResourceData, meta interface{}) (string, error) {
iamconn := meta.(*AWSClient).iamconn
region := meta.(*AWSClient).region
// An zero value GetUserRequest{} defers to the currently logged in user
resp, err := iamconn.GetUser(&iam.GetUserRequest{})
// 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/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 TestAccAWSDBInstance(t *testing.T) {
@ -56,7 +56,7 @@ func testAccCheckAWSDBInstanceDestroy(s *terraform.State) error {
// Try to find the Group
resp, err := conn.DescribeDBInstances(
&rds.DescribeDBInstancesMessage{
&rds.DescribeDBInstancesInput{
DBInstanceIdentifier: aws.String(rs.Primary.ID),
})
@ -112,7 +112,7 @@ func testAccCheckAWSDBInstanceExists(n string, v *rds.DBInstance) resource.TestC
conn := testAccProvider.Meta().(*AWSClient).rdsconn
opts := rds.DescribeDBInstancesMessage{
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"),
},

View File

@ -3,8 +3,8 @@ package aws
import (
"log"
"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/schema"
)
@ -20,12 +20,12 @@ func setTagsRDS(conn *rds.RDS, d *schema.ResourceData, arn string) error {
// Set tags
if len(remove) > 0 {
log.Printf("[DEBUG] Removing tags: %#v", remove)
k := make([]string, len(remove), len(remove))
k := make([]*string, len(remove), len(remove))
for i, t := range remove {
k[i] = *t.Key
k[i] = t.Key
}
err := conn.RemoveTagsFromResource(&rds.RemoveTagsFromResourceMessage{
_, err := conn.RemoveTagsFromResource(&rds.RemoveTagsFromResourceInput{
ResourceName: aws.String(arn),
TagKeys: k,
})
@ -35,7 +35,7 @@ func setTagsRDS(conn *rds.RDS, d *schema.ResourceData, arn string) error {
}
if len(create) > 0 {
log.Printf("[DEBUG] Creating tags: %#v", create)
err := conn.AddTagsToResource(&rds.AddTagsToResourceMessage{
_, err := conn.AddTagsToResource(&rds.AddTagsToResourceInput{
ResourceName: aws.String(arn),
Tags: create,
})
@ -51,7 +51,7 @@ func setTagsRDS(conn *rds.RDS, d *schema.ResourceData, arn string) error {
// diffTags takes our tags locally and the ones remotely and returns
// the set of tags that must be created, and the set of tags that must
// be destroyed.
func diffTagsRDS(oldTags, newTags []rds.Tag) ([]rds.Tag, []rds.Tag) {
func diffTagsRDS(oldTags, newTags []*rds.Tag) ([]*rds.Tag, []*rds.Tag) {
// First, we're creating everything we have
create := make(map[string]interface{})
for _, t := range newTags {
@ -59,7 +59,7 @@ func diffTagsRDS(oldTags, newTags []rds.Tag) ([]rds.Tag, []rds.Tag) {
}
// Build the list of what to remove
var remove []rds.Tag
var remove []*rds.Tag
for _, t := range oldTags {
old, ok := create[*t.Key]
if !ok || old != *t.Value {
@ -72,10 +72,10 @@ func diffTagsRDS(oldTags, newTags []rds.Tag) ([]rds.Tag, []rds.Tag) {
}
// tagsFromMap returns the tags for the given map of data.
func tagsFromMapRDS(m map[string]interface{}) []rds.Tag {
result := make([]rds.Tag, 0, len(m))
func tagsFromMapRDS(m map[string]interface{}) []*rds.Tag {
result := make([]*rds.Tag, 0, len(m))
for k, v := range m {
result = append(result, rds.Tag{
result = append(result, &rds.Tag{
Key: aws.String(k),
Value: aws.String(v.(string)),
})
@ -85,7 +85,7 @@ func tagsFromMapRDS(m map[string]interface{}) []rds.Tag {
}
// tagsToMap turns the list of tags into a map.
func tagsToMapRDS(ts []rds.Tag) map[string]string {
func tagsToMapRDS(ts []*rds.Tag) map[string]string {
result := make(map[string]string)
for _, t := range ts {
result[*t.Key] = *t.Value

View File

@ -5,7 +5,7 @@ import (
"reflect"
"testing"
"github.com/hashicorp/aws-sdk-go/gen/rds"
"github.com/awslabs/aws-sdk-go/service/rds"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
@ -63,9 +63,9 @@ func TestDiffRDSTags(t *testing.T) {
// testAccCheckTags can be used to check the tags on a resource.
func testAccCheckRDSTags(
ts *[]rds.Tag, key string, value string) resource.TestCheckFunc {
ts []*rds.Tag, key string, value string) resource.TestCheckFunc {
return func(s *terraform.State) error {
m := tagsToMapRDS(*ts)
m := tagsToMapRDS(ts)
v, ok := m[key]
if value != "" && !ok {
return fmt.Errorf("Missing tag: %s", key)