From a15547b955f0dccd07e102a051ad235dbec56496 Mon Sep 17 00:00:00 2001 From: Clint Shryock Date: Tue, 7 Apr 2015 10:37:17 -0500 Subject: [PATCH] provider/aws: Convert EIP to use upstream aws-sdk-go --- builtin/providers/aws/resource_aws_eip.go | 36 +++++++++---------- .../providers/aws/resource_aws_eip_test.go | 30 ++++++++-------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/builtin/providers/aws/resource_aws_eip.go b/builtin/providers/aws/resource_aws_eip.go index c78fec4c9..de92983e2 100644 --- a/builtin/providers/aws/resource_aws_eip.go +++ b/builtin/providers/aws/resource_aws_eip.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/hashicorp/aws-sdk-go/aws" - "github.com/hashicorp/aws-sdk-go/gen/ec2" + "github.com/awslabs/aws-sdk-go/aws" + "github.com/awslabs/aws-sdk-go/service/ec2" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/schema" ) @@ -60,7 +60,7 @@ func resourceAwsEip() *schema.Resource { } func resourceAwsEipCreate(d *schema.ResourceData, meta interface{}) error { - ec2conn := meta.(*AWSClient).ec2conn + ec2conn := meta.(*AWSClient).ec2SDKconn // By default, we're not in a VPC domainOpt := "" @@ -68,7 +68,7 @@ func resourceAwsEipCreate(d *schema.ResourceData, meta interface{}) error { domainOpt = "vpc" } - allocOpts := &ec2.AllocateAddressRequest{ + allocOpts := &ec2.AllocateAddressInput{ Domain: aws.String(domainOpt), } @@ -97,24 +97,24 @@ func resourceAwsEipCreate(d *schema.ResourceData, meta interface{}) error { } func resourceAwsEipRead(d *schema.ResourceData, meta interface{}) error { - ec2conn := meta.(*AWSClient).ec2conn + ec2conn := meta.(*AWSClient).ec2SDKconn domain := resourceAwsEipDomain(d) id := d.Id() - assocIds := []string{} - publicIps := []string{} + assocIds := []*string{} + publicIps := []*string{} if domain == "vpc" { - assocIds = []string{id} + assocIds = []*string{aws.String(id)} } else { - publicIps = []string{id} + publicIps = []*string{aws.String(id)} } log.Printf( "[DEBUG] EIP describe configuration: %#v, %#v (domain: %s)", assocIds, publicIps, domain) - req := &ec2.DescribeAddressesRequest{ + req := &ec2.DescribeAddressesInput{ AllocationIDs: assocIds, PublicIPs: publicIps, } @@ -148,7 +148,7 @@ func resourceAwsEipRead(d *schema.ResourceData, meta interface{}) error { } func resourceAwsEipUpdate(d *schema.ResourceData, meta interface{}) error { - ec2conn := meta.(*AWSClient).ec2conn + ec2conn := meta.(*AWSClient).ec2SDKconn domain := resourceAwsEipDomain(d) @@ -156,14 +156,14 @@ func resourceAwsEipUpdate(d *schema.ResourceData, meta interface{}) error { if v, ok := d.GetOk("instance"); ok { instanceId := v.(string) - assocOpts := &ec2.AssociateAddressRequest{ + assocOpts := &ec2.AssociateAddressInput{ InstanceID: aws.String(instanceId), PublicIP: aws.String(d.Id()), } // more unique ID conditionals if domain == "vpc" { - assocOpts = &ec2.AssociateAddressRequest{ + assocOpts = &ec2.AssociateAddressInput{ InstanceID: aws.String(instanceId), AllocationID: aws.String(d.Id()), PublicIP: aws.String(""), @@ -181,7 +181,7 @@ func resourceAwsEipUpdate(d *schema.ResourceData, meta interface{}) error { } func resourceAwsEipDelete(d *schema.ResourceData, meta interface{}) error { - ec2conn := meta.(*AWSClient).ec2conn + ec2conn := meta.(*AWSClient).ec2SDKconn if err := resourceAwsEipRead(d, meta); err != nil { return err @@ -197,11 +197,11 @@ func resourceAwsEipDelete(d *schema.ResourceData, meta interface{}) error { var err error switch resourceAwsEipDomain(d) { case "vpc": - err = ec2conn.DisassociateAddress(&ec2.DisassociateAddressRequest{ + _, err = ec2conn.DisassociateAddress(&ec2.DisassociateAddressInput{ AssociationID: aws.String(d.Get("association_id").(string)), }) case "standard": - err = ec2conn.DisassociateAddress(&ec2.DisassociateAddressRequest{ + _, err = ec2conn.DisassociateAddress(&ec2.DisassociateAddressInput{ PublicIP: aws.String(d.Get("public_ip").(string)), }) } @@ -218,12 +218,12 @@ func resourceAwsEipDelete(d *schema.ResourceData, meta interface{}) error { log.Printf( "[DEBUG] EIP release (destroy) address allocation: %v", d.Id()) - err = ec2conn.ReleaseAddress(&ec2.ReleaseAddressRequest{ + _, err = ec2conn.ReleaseAddress(&ec2.ReleaseAddressInput{ AllocationID: aws.String(d.Id()), }) case "standard": log.Printf("[DEBUG] EIP release (destroy) address: %v", d.Id()) - err = ec2conn.ReleaseAddress(&ec2.ReleaseAddressRequest{ + _, err = ec2conn.ReleaseAddress(&ec2.ReleaseAddressInput{ PublicIP: aws.String(d.Id()), }) } diff --git a/builtin/providers/aws/resource_aws_eip_test.go b/builtin/providers/aws/resource_aws_eip_test.go index b9944366f..5120a9648 100644 --- a/builtin/providers/aws/resource_aws_eip_test.go +++ b/builtin/providers/aws/resource_aws_eip_test.go @@ -5,8 +5,8 @@ import ( "strings" "testing" - "github.com/hashicorp/aws-sdk-go/aws" - "github.com/hashicorp/aws-sdk-go/gen/ec2" + "github.com/awslabs/aws-sdk-go/aws" + "github.com/awslabs/aws-sdk-go/service/ec2" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) @@ -58,16 +58,16 @@ func TestAccAWSEIP_instance(t *testing.T) { } func testAccCheckAWSEIPDestroy(s *terraform.State) error { - conn := testAccProvider.Meta().(*AWSClient).ec2conn + conn := testAccProvider.Meta().(*AWSClient).ec2SDKconn for _, rs := range s.RootModule().Resources { if rs.Type != "aws_eip" { continue } - req := &ec2.DescribeAddressesRequest{ - AllocationIDs: []string{}, - PublicIPs: []string{rs.Primary.ID}, + req := &ec2.DescribeAddressesInput{ + AllocationIDs: []*string{}, + PublicIPs: []*string{aws.String(rs.Primary.ID)}, } describe, err := conn.DescribeAddresses(req) @@ -113,12 +113,12 @@ func testAccCheckAWSEIPExists(n string, res *ec2.Address) resource.TestCheckFunc return fmt.Errorf("No EIP ID is set") } - conn := testAccProvider.Meta().(*AWSClient).ec2conn + conn := testAccProvider.Meta().(*AWSClient).ec2SDKconn if strings.Contains(rs.Primary.ID, "eipalloc") { - req := &ec2.DescribeAddressesRequest{ - AllocationIDs: []string{rs.Primary.ID}, - PublicIPs: []string{}, + req := &ec2.DescribeAddressesInput{ + AllocationIDs: []*string{aws.String(rs.Primary.ID)}, + PublicIPs: []*string{}, } describe, err := conn.DescribeAddresses(req) if err != nil { @@ -129,12 +129,12 @@ func testAccCheckAWSEIPExists(n string, res *ec2.Address) resource.TestCheckFunc *describe.Addresses[0].AllocationID != rs.Primary.ID { return fmt.Errorf("EIP not found") } - *res = describe.Addresses[0] + *res = *describe.Addresses[0] } else { - req := &ec2.DescribeAddressesRequest{ - AllocationIDs: []string{}, - PublicIPs: []string{rs.Primary.ID}, + req := &ec2.DescribeAddressesInput{ + AllocationIDs: []*string{}, + PublicIPs: []*string{aws.String(rs.Primary.ID)}, } describe, err := conn.DescribeAddresses(req) if err != nil { @@ -145,7 +145,7 @@ func testAccCheckAWSEIPExists(n string, res *ec2.Address) resource.TestCheckFunc *describe.Addresses[0].PublicIP != rs.Primary.ID { return fmt.Errorf("EIP not found") } - *res = describe.Addresses[0] + *res = *describe.Addresses[0] } return nil