Merge pull request #1075 from hashicorp/aws-go-remove-goamz-rds

provider/aws: Remove goamz/rds, only use aws-sdk-go for RDS
This commit is contained in:
Clint 2015-02-27 10:57:58 -06:00
commit 1f7e71b7f6
9 changed files with 24 additions and 28 deletions

View File

@ -10,11 +10,10 @@ import (
"github.com/mitchellh/goamz/aws" "github.com/mitchellh/goamz/aws"
"github.com/mitchellh/goamz/ec2" "github.com/mitchellh/goamz/ec2"
"github.com/mitchellh/goamz/elb" "github.com/mitchellh/goamz/elb"
"github.com/mitchellh/goamz/rds"
awsGo "github.com/hashicorp/aws-sdk-go/aws" awsGo "github.com/hashicorp/aws-sdk-go/aws"
"github.com/hashicorp/aws-sdk-go/gen/autoscaling" "github.com/hashicorp/aws-sdk-go/gen/autoscaling"
awsRDS "github.com/hashicorp/aws-sdk-go/gen/rds" "github.com/hashicorp/aws-sdk-go/gen/rds"
"github.com/hashicorp/aws-sdk-go/gen/route53" "github.com/hashicorp/aws-sdk-go/gen/route53"
"github.com/hashicorp/aws-sdk-go/gen/s3" "github.com/hashicorp/aws-sdk-go/gen/s3"
) )
@ -30,10 +29,9 @@ type AWSClient struct {
elbconn *elb.ELB elbconn *elb.ELB
autoscalingconn *autoscaling.AutoScaling autoscalingconn *autoscaling.AutoScaling
s3conn *s3.S3 s3conn *s3.S3
rdsconn *rds.Rds
r53conn *route53.Route53 r53conn *route53.Route53
region string region string
awsRDSconn *awsRDS.RDS rdsconn *rds.RDS
} }
// Client configures and returns a fully initailized AWSClient // Client configures and returns a fully initailized AWSClient
@ -71,15 +69,13 @@ func (c *Config) Client() (interface{}, error) {
log.Println("[INFO] Initializing S3 connection") log.Println("[INFO] Initializing S3 connection")
client.s3conn = s3.New(creds, c.Region, nil) client.s3conn = s3.New(creds, c.Region, nil)
log.Println("[INFO] Initializing RDS connection") log.Println("[INFO] Initializing RDS connection")
client.rdsconn = rds.New(auth, region) client.rdsconn = rds.New(creds, c.Region, nil)
// aws-sdk-go uses v4 for signing requests, which requires all global // aws-sdk-go uses v4 for signing requests, which requires all global
// endpoints to use 'us-east-1'. // endpoints to use 'us-east-1'.
// See http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html // See http://docs.aws.amazon.com/general/latest/gr/sigv4_changes.html
log.Println("[INFO] Initializing Route53 connection") log.Println("[INFO] Initializing Route53 connection")
client.r53conn = route53.New(creds, "us-east-1", nil) client.r53conn = route53.New(creds, "us-east-1", nil)
log.Println("[INFO] Initializing AWS Go RDS connection")
client.awsRDSconn = awsRDS.New(creds, c.Region, nil)
} }
if len(errs) > 0 { if len(errs) > 0 {

View File

@ -185,7 +185,7 @@ func resourceAwsDbInstance() *schema.Resource {
} }
func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error { func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).awsRDSconn conn := meta.(*AWSClient).rdsconn
opts := rds.CreateDBInstanceMessage{ opts := rds.CreateDBInstanceMessage{
AllocatedStorage: aws.Integer(d.Get("allocated_storage").(int)), AllocatedStorage: aws.Integer(d.Get("allocated_storage").(int)),
DBInstanceClass: aws.String(d.Get("instance_class").(string)), DBInstanceClass: aws.String(d.Get("instance_class").(string)),
@ -347,7 +347,7 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
} }
func resourceAwsDbInstanceDelete(d *schema.ResourceData, meta interface{}) error { func resourceAwsDbInstanceDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).awsRDSconn conn := meta.(*AWSClient).rdsconn
log.Printf("[DEBUG] DB Instance destroy: %v", d.Id()) log.Printf("[DEBUG] DB Instance destroy: %v", d.Id())
@ -385,7 +385,7 @@ func resourceAwsDbInstanceDelete(d *schema.ResourceData, meta interface{}) error
func resourceAwsBbInstanceRetrieve( func resourceAwsBbInstanceRetrieve(
d *schema.ResourceData, meta interface{}) (*rds.DBInstance, error) { d *schema.ResourceData, meta interface{}) (*rds.DBInstance, error) {
conn := meta.(*AWSClient).awsRDSconn conn := meta.(*AWSClient).rdsconn
opts := rds.DescribeDBInstancesMessage{ opts := rds.DescribeDBInstancesMessage{
DBInstanceIdentifier: aws.String(d.Id()), DBInstanceIdentifier: aws.String(d.Id()),

View File

@ -47,7 +47,7 @@ func TestAccAWSDBInstance(t *testing.T) {
} }
func testAccCheckAWSDBInstanceDestroy(s *terraform.State) error { func testAccCheckAWSDBInstanceDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).awsRDSconn conn := testAccProvider.Meta().(*AWSClient).rdsconn
for _, rs := range s.RootModule().Resources { for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_db_instance" { if rs.Type != "aws_db_instance" {
@ -110,7 +110,7 @@ func testAccCheckAWSDBInstanceExists(n string, v *rds.DBInstance) resource.TestC
return fmt.Errorf("No DB Instance ID is set") return fmt.Errorf("No DB Instance ID is set")
} }
conn := testAccProvider.Meta().(*AWSClient).awsRDSconn conn := testAccProvider.Meta().(*AWSClient).rdsconn
opts := rds.DescribeDBInstancesMessage{ opts := rds.DescribeDBInstancesMessage{
DBInstanceIdentifier: aws.String(rs.Primary.ID), DBInstanceIdentifier: aws.String(rs.Primary.ID),

View File

@ -72,7 +72,7 @@ func resourceAwsDbParameterGroup() *schema.Resource {
} }
func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{}) error { func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).awsRDSconn rdsconn := meta.(*AWSClient).rdsconn
createOpts := rds.CreateDBParameterGroupMessage{ createOpts := rds.CreateDBParameterGroupMessage{
DBParameterGroupName: aws.String(d.Get("name").(string)), DBParameterGroupName: aws.String(d.Get("name").(string)),
@ -99,7 +99,7 @@ func resourceAwsDbParameterGroupCreate(d *schema.ResourceData, meta interface{})
} }
func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) error { func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).awsRDSconn rdsconn := meta.(*AWSClient).rdsconn
describeOpts := rds.DescribeDBParameterGroupsMessage{ describeOpts := rds.DescribeDBParameterGroupsMessage{
DBParameterGroupName: aws.String(d.Id()), DBParameterGroupName: aws.String(d.Id()),
@ -136,7 +136,7 @@ func resourceAwsDbParameterGroupRead(d *schema.ResourceData, meta interface{}) e
} }
func resourceAwsDbParameterGroupUpdate(d *schema.ResourceData, meta interface{}) error { func resourceAwsDbParameterGroupUpdate(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).awsRDSconn rdsconn := meta.(*AWSClient).rdsconn
d.Partial(true) d.Partial(true)
@ -193,7 +193,7 @@ func resourceAwsDbParameterGroupDelete(d *schema.ResourceData, meta interface{})
func resourceAwsDbParameterGroupDeleteRefreshFunc( func resourceAwsDbParameterGroupDeleteRefreshFunc(
d *schema.ResourceData, d *schema.ResourceData,
meta interface{}) resource.StateRefreshFunc { meta interface{}) resource.StateRefreshFunc {
rdsconn := meta.(*AWSClient).awsRDSconn rdsconn := meta.(*AWSClient).rdsconn
return func() (interface{}, string, error) { return func() (interface{}, string, error) {

View File

@ -106,7 +106,7 @@ func TestAccAWSDBParameterGroupOnly(t *testing.T) {
} }
func testAccCheckAWSDBParameterGroupDestroy(s *terraform.State) error { func testAccCheckAWSDBParameterGroupDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).awsRDSconn conn := testAccProvider.Meta().(*AWSClient).rdsconn
for _, rs := range s.RootModule().Resources { for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_db_parameter_group" { if rs.Type != "aws_db_parameter_group" {
@ -169,7 +169,7 @@ func testAccCheckAWSDBParameterGroupExists(n string, v *rds.DBParameterGroup) re
return fmt.Errorf("No DB Parameter Group ID is set") return fmt.Errorf("No DB Parameter Group ID is set")
} }
conn := testAccProvider.Meta().(*AWSClient).awsRDSconn conn := testAccProvider.Meta().(*AWSClient).rdsconn
opts := rds.DescribeDBParameterGroupsMessage{ opts := rds.DescribeDBParameterGroupsMessage{
DBParameterGroupName: aws.String(rs.Primary.ID), DBParameterGroupName: aws.String(rs.Primary.ID),

View File

@ -70,7 +70,7 @@ func resourceAwsDbSecurityGroup() *schema.Resource {
} }
func resourceAwsDbSecurityGroupCreate(d *schema.ResourceData, meta interface{}) error { func resourceAwsDbSecurityGroupCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).awsRDSconn conn := meta.(*AWSClient).rdsconn
var err error var err error
var errs []error var errs []error
@ -160,7 +160,7 @@ func resourceAwsDbSecurityGroupRead(d *schema.ResourceData, meta interface{}) er
} }
func resourceAwsDbSecurityGroupDelete(d *schema.ResourceData, meta interface{}) error { func resourceAwsDbSecurityGroupDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).awsRDSconn conn := meta.(*AWSClient).rdsconn
log.Printf("[DEBUG] DB Security Group destroy: %v", d.Id()) log.Printf("[DEBUG] DB Security Group destroy: %v", d.Id())
@ -181,7 +181,7 @@ func resourceAwsDbSecurityGroupDelete(d *schema.ResourceData, meta interface{})
} }
func resourceAwsDbSecurityGroupRetrieve(d *schema.ResourceData, meta interface{}) (*rds.DBSecurityGroup, error) { func resourceAwsDbSecurityGroupRetrieve(d *schema.ResourceData, meta interface{}) (*rds.DBSecurityGroup, error) {
conn := meta.(*AWSClient).awsRDSconn conn := meta.(*AWSClient).rdsconn
opts := rds.DescribeDBSecurityGroupsMessage{ opts := rds.DescribeDBSecurityGroupsMessage{
DBSecurityGroupName: aws.String(d.Id()), DBSecurityGroupName: aws.String(d.Id()),

View File

@ -38,7 +38,7 @@ func TestAccAWSDBSecurityGroup(t *testing.T) {
} }
func testAccCheckAWSDBSecurityGroupDestroy(s *terraform.State) error { func testAccCheckAWSDBSecurityGroupDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).awsRDSconn conn := testAccProvider.Meta().(*AWSClient).rdsconn
for _, rs := range s.RootModule().Resources { for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_db_security_group" { if rs.Type != "aws_db_security_group" {
@ -113,7 +113,7 @@ func testAccCheckAWSDBSecurityGroupExists(n string, v *rds.DBSecurityGroup) reso
return fmt.Errorf("No DB Security Group ID is set") return fmt.Errorf("No DB Security Group ID is set")
} }
conn := testAccProvider.Meta().(*AWSClient).awsRDSconn conn := testAccProvider.Meta().(*AWSClient).rdsconn
opts := rds.DescribeDBSecurityGroupsMessage{ opts := rds.DescribeDBSecurityGroupsMessage{
DBSecurityGroupName: aws.String(rs.Primary.ID), DBSecurityGroupName: aws.String(rs.Primary.ID),

View File

@ -45,7 +45,7 @@ func resourceAwsDbSubnetGroup() *schema.Resource {
} }
func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) error { func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).awsRDSconn rdsconn := meta.(*AWSClient).rdsconn
subnetIdsSet := d.Get("subnet_ids").(*schema.Set) subnetIdsSet := d.Get("subnet_ids").(*schema.Set)
subnetIds := make([]string, subnetIdsSet.Len()) subnetIds := make([]string, subnetIdsSet.Len())
@ -71,7 +71,7 @@ func resourceAwsDbSubnetGroupCreate(d *schema.ResourceData, meta interface{}) er
} }
func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) error { func resourceAwsDbSubnetGroupRead(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).awsRDSconn rdsconn := meta.(*AWSClient).rdsconn
describeOpts := rds.DescribeDBSubnetGroupsMessage{ describeOpts := rds.DescribeDBSubnetGroupsMessage{
DBSubnetGroupName: aws.String(d.Id()), DBSubnetGroupName: aws.String(d.Id()),
@ -116,7 +116,7 @@ func resourceAwsDbSubnetGroupDelete(d *schema.ResourceData, meta interface{}) er
func resourceAwsDbSubnetGroupDeleteRefreshFunc( func resourceAwsDbSubnetGroupDeleteRefreshFunc(
d *schema.ResourceData, d *schema.ResourceData,
meta interface{}) resource.StateRefreshFunc { meta interface{}) resource.StateRefreshFunc {
rdsconn := meta.(*AWSClient).awsRDSconn rdsconn := meta.(*AWSClient).rdsconn
return func() (interface{}, string, error) { return func() (interface{}, string, error) {

View File

@ -36,7 +36,7 @@ func TestAccAWSDBSubnetGroup(t *testing.T) {
} }
func testAccCheckDBSubnetGroupDestroy(s *terraform.State) error { func testAccCheckDBSubnetGroupDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*AWSClient).awsRDSconn conn := testAccProvider.Meta().(*AWSClient).rdsconn
for _, rs := range s.RootModule().Resources { for _, rs := range s.RootModule().Resources {
if rs.Type != "aws_db_subnet_group" { if rs.Type != "aws_db_subnet_group" {
@ -78,7 +78,7 @@ func testAccCheckDBSubnetGroupExists(n string, v *rds.DBSubnetGroup) resource.Te
return fmt.Errorf("No ID is set") return fmt.Errorf("No ID is set")
} }
conn := testAccProvider.Meta().(*AWSClient).awsRDSconn conn := testAccProvider.Meta().(*AWSClient).rdsconn
resp, err := conn.DescribeDBSubnetGroups( resp, err := conn.DescribeDBSubnetGroups(
&rds.DescribeDBSubnetGroupsMessage{DBSubnetGroupName: aws.String(rs.Primary.ID)}) &rds.DescribeDBSubnetGroupsMessage{DBSubnetGroupName: aws.String(rs.Primary.ID)})
if err != nil { if err != nil {