From c1509b022079214dd6111721848b41cb10bd2140 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 21 Apr 2016 22:17:14 -0700 Subject: [PATCH] providers/aws: eip id-only --- .../aws/resource_aws_ebs_volume_test.go | 5 ++-- builtin/providers/aws/resource_aws_eip.go | 8 ++++++ .../providers/aws/resource_aws_eip_test.go | 28 +++++++++++-------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/builtin/providers/aws/resource_aws_ebs_volume_test.go b/builtin/providers/aws/resource_aws_ebs_volume_test.go index 4542d91089..f161e32bbf 100644 --- a/builtin/providers/aws/resource_aws_ebs_volume_test.go +++ b/builtin/providers/aws/resource_aws_ebs_volume_test.go @@ -30,9 +30,8 @@ func TestAccAWSEBSVolume_basic(t *testing.T) { func TestAccAWSEBSVolume_NoIops(t *testing.T) { var v ec2.Volume resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "aws_ebs_volume.iops_test", - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, Steps: []resource.TestStep{ resource.TestStep{ Config: testAccAwsEbsVolumeConfigWithNoIops, diff --git a/builtin/providers/aws/resource_aws_eip.go b/builtin/providers/aws/resource_aws_eip.go index ee1aec8bc8..00033289e1 100644 --- a/builtin/providers/aws/resource_aws_eip.go +++ b/builtin/providers/aws/resource_aws_eip.go @@ -158,6 +158,14 @@ func resourceAwsEipRead(d *schema.ResourceData, meta interface{}) error { d.Set("private_ip", address.PrivateIpAddress) d.Set("public_ip", address.PublicIp) + // On import (domain never set, which it must've been if we created), + // set the 'vpc' attribute depending on if we're in a VPC. + if _, ok := d.GetOk("domain"); !ok { + d.Set("vpc", *address.Domain == "vpc") + } + + d.Set("domain", address.Domain) + return nil } diff --git a/builtin/providers/aws/resource_aws_eip_test.go b/builtin/providers/aws/resource_aws_eip_test.go index ef3e8113bd..9c0064e074 100644 --- a/builtin/providers/aws/resource_aws_eip_test.go +++ b/builtin/providers/aws/resource_aws_eip_test.go @@ -16,9 +16,10 @@ func TestAccAWSEIP_basic(t *testing.T) { var conf ec2.Address resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSEIPDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "aws_eip.bar", + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEIPDestroy, Steps: []resource.TestStep{ resource.TestStep{ Config: testAccAWSEIPConfig, @@ -35,9 +36,10 @@ func TestAccAWSEIP_instance(t *testing.T) { var conf ec2.Address resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSEIPDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "aws_eip.bar", + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEIPDestroy, Steps: []resource.TestStep{ resource.TestStep{ Config: testAccAWSEIPInstanceConfig, @@ -62,9 +64,10 @@ func TestAccAWSEIP_network_interface(t *testing.T) { var conf ec2.Address resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSEIPDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "aws_eip.bar", + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEIPDestroy, Steps: []resource.TestStep{ resource.TestStep{ Config: testAccAWSEIPNetworkInterfaceConfig, @@ -82,9 +85,10 @@ func TestAccAWSEIP_twoEIPsOneNetworkInterface(t *testing.T) { var one, two ec2.Address resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSEIPDestroy, + PreCheck: func() { testAccPreCheck(t) }, + IDRefreshName: "aws_eip.one", + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSEIPDestroy, Steps: []resource.TestStep{ resource.TestStep{ Config: testAccAWSEIPMultiNetworkInterfaceConfig,