Skip to content

Commit

Permalink
Merge pull request #14718 from terraform-providers/t-hardaz-vpc
Browse files Browse the repository at this point in the history
tests/provider: Update hardcoded AZs (VPC Endpoint)
  • Loading branch information
YakDriver authored Aug 18, 2020
2 parents 33d3080 + 6867c61 commit 829a3e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
25 changes: 14 additions & 11 deletions aws/resource_aws_vpc_endpoint_connection_notification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ func testAccCheckVpcEndpointConnectionNotificationExists(n string) resource.Test
}

func testAccVpcEndpointConnectionNotificationBasicConfig(lbName string) string {
return fmt.Sprintf(
`
return composeConfig(testAccAvailableAZsNoOptInConfig(), fmt.Sprintf(`
data "aws_partition" "current" {}
resource "aws_vpc" "nlb_test" {
cidr_block = "10.0.0.0/16"
Expand Down Expand Up @@ -137,7 +138,7 @@ resource "aws_lb" "nlb_test" {
resource "aws_subnet" "nlb_test_1" {
vpc_id = "${aws_vpc.nlb_test.id}"
cidr_block = "10.0.1.0/24"
availability_zone = "us-west-2a"
availability_zone = data.aws_availability_zones.available.names[0]
tags = {
Name = "tf-acc-vpc-endpoint-connection-notification-1"
Expand All @@ -147,7 +148,7 @@ resource "aws_subnet" "nlb_test_1" {
resource "aws_subnet" "nlb_test_2" {
vpc_id = "${aws_vpc.nlb_test.id}"
cidr_block = "10.0.2.0/24"
availability_zone = "us-west-2b"
availability_zone = data.aws_availability_zones.available.names[1]
tags = {
Name = "tf-acc-vpc-endpoint-connection-notification-2"
Expand Down Expand Up @@ -180,7 +181,7 @@ resource "aws_sns_topic" "topic" {
"Service": "vpce.amazonaws.com"
},
"Action": "SNS:Publish",
"Resource": "arn:aws:sns:*:*:vpce-notification-topic"
"Resource": "arn:${data.aws_partition.current.partition}:sns:*:*:vpce-notification-topic"
}]
}
POLICY
Expand All @@ -191,12 +192,14 @@ resource "aws_vpc_endpoint_connection_notification" "test" {
connection_notification_arn = "${aws_sns_topic.topic.arn}"
connection_events = ["Accept", "Reject"]
}
`, lbName)
`, lbName))
}

func testAccVpcEndpointConnectionNotificationModifiedConfig(lbName string) string {
return fmt.Sprintf(
return composeConfig(testAccAvailableAZsNoOptInConfig(), fmt.Sprintf(
`
data "aws_partition" "current" {}
resource "aws_vpc" "nlb_test" {
cidr_block = "10.0.0.0/16"
Expand Down Expand Up @@ -226,7 +229,7 @@ func testAccVpcEndpointConnectionNotificationModifiedConfig(lbName string) strin
resource "aws_subnet" "nlb_test_1" {
vpc_id = "${aws_vpc.nlb_test.id}"
cidr_block = "10.0.1.0/24"
availability_zone = "us-west-2a"
availability_zone = data.aws_availability_zones.available.names[0]
tags = {
Name = "tf-acc-vpc-endpoint-connection-notification-1"
Expand All @@ -236,7 +239,7 @@ func testAccVpcEndpointConnectionNotificationModifiedConfig(lbName string) strin
resource "aws_subnet" "nlb_test_2" {
vpc_id = "${aws_vpc.nlb_test.id}"
cidr_block = "10.0.2.0/24"
availability_zone = "us-west-2b"
availability_zone = data.aws_availability_zones.available.names[1]
tags = {
Name = "tf-acc-vpc-endpoint-connection-notification-2"
Expand Down Expand Up @@ -269,7 +272,7 @@ func testAccVpcEndpointConnectionNotificationModifiedConfig(lbName string) strin
"Service": "vpce.amazonaws.com"
},
"Action": "SNS:Publish",
"Resource": "arn:aws:sns:*:*:vpce-notification-topic"
"Resource": "arn:${data.aws_partition.current.partition}:sns:*:*:vpce-notification-topic"
}]
}
POLICY
Expand All @@ -280,5 +283,5 @@ func testAccVpcEndpointConnectionNotificationModifiedConfig(lbName string) strin
connection_notification_arn = "${aws_sns_topic.topic.arn}"
connection_events = ["Accept"]
}
`, lbName)
`, lbName))
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func testAccCheckVpcEndpointServiceAllowedPrincipalExists(n string) resource.Tes
}

func testAccVpcEndpointServiceAllowedPrincipalBasicConfig(lbName string) string {
return fmt.Sprintf(
return composeConfig(testAccAvailableAZsNoOptInConfig(), fmt.Sprintf(
`
resource "aws_vpc" "nlb_test" {
cidr_block = "10.0.0.0/16"
Expand Down Expand Up @@ -126,7 +126,7 @@ resource "aws_lb" "nlb_test_1" {
resource "aws_subnet" "nlb_test_1" {
vpc_id = "${aws_vpc.nlb_test.id}"
cidr_block = "10.0.1.0/24"
availability_zone = "us-west-2a"
availability_zone = data.aws_availability_zones.available.names[0]
tags = {
Name = "tf-acc-vpc-endpoint-service-allowed-principal-1"
Expand All @@ -136,7 +136,7 @@ resource "aws_subnet" "nlb_test_1" {
resource "aws_subnet" "nlb_test_2" {
vpc_id = "${aws_vpc.nlb_test.id}"
cidr_block = "10.0.2.0/24"
availability_zone = "us-west-2b"
availability_zone = data.aws_availability_zones.available.names[1]
tags = {
Name = "tf-acc-vpc-endpoint-service-allowed-principal-2"
Expand All @@ -158,5 +158,5 @@ resource "aws_vpc_endpoint_service_allowed_principal" "foo" {
principal_arn = "${data.aws_caller_identity.current.arn}"
}
`, lbName)
`, lbName))
}

0 comments on commit 829a3e5

Please sign in to comment.