Merge pull request #8645 from hashicorp/aws-vpn-gateway-za
provider/aws: Do not set empty string to state for `aws_vpn_gateway` availability zone
This commit is contained in:
commit
3ad4cfe117
|
@ -94,7 +94,10 @@ func resourceAwsVpnGatewayRead(d *schema.ResourceData, meta interface{}) error {
|
|||
} else {
|
||||
d.Set("vpc_id", *vpnAttachment.VpcId)
|
||||
}
|
||||
d.Set("availability_zone", vpnGateway.AvailabilityZone)
|
||||
|
||||
if vpnGateway.AvailabilityZone != nil && *vpnGateway.AvailabilityZone != "" {
|
||||
d.Set("availability_zone", vpnGateway.AvailabilityZone)
|
||||
}
|
||||
d.Set("tags", tagsToMap(vpnGateway.Tags))
|
||||
|
||||
return nil
|
||||
|
|
|
@ -58,6 +58,26 @@ func TestAccAWSVpnGateway_basic(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccAWSVpnGateway_withAvailabilityZoneSetToState(t *testing.T) {
|
||||
var v ec2.VpnGateway
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckVpnGatewayDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccVpnGatewayConfigWithAZ,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckVpnGatewayExists("aws_vpn_gateway.foo", &v),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_vpn_gateway.foo", "availability_zone", "us-west-2a"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAWSVpnGateway_disappears(t *testing.T) {
|
||||
var v ec2.VpnGateway
|
||||
|
||||
|
@ -435,3 +455,14 @@ resource "aws_vpn_gateway" "bar" {
|
|||
vpc_id = "${aws_vpc.foo.id}"
|
||||
}
|
||||
`
|
||||
|
||||
const testAccVpnGatewayConfigWithAZ = `
|
||||
resource "aws_vpc" "foo" {
|
||||
cidr_block = "10.1.0.0/16"
|
||||
}
|
||||
|
||||
resource "aws_vpn_gateway" "foo" {
|
||||
vpc_id = "${aws_vpc.foo.id}"
|
||||
availability_zone = "us-west-2a"
|
||||
}
|
||||
`
|
||||
|
|
Loading…
Reference in New Issue