Skip to content

Commit

Permalink
Fix hardcoded AZs
Browse files Browse the repository at this point in the history
  • Loading branch information
YakDriver committed Aug 7, 2020
1 parent 3bb317a commit 9663ecd
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 129 deletions.
2 changes: 1 addition & 1 deletion aws/resource_aws_apigatewayv2_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ resource "aws_apigatewayv2_integration" "test" {
func testAccAWSAPIGatewayV2IntegrationConfig_vpcLinkWebSocket(rName string) string {
return composeConfig(
testAccAWSAPIGatewayV2IntegrationConfig_apiWebSocket(rName),
testAccAvailableAZsNoOptInConfig() + fmt.Sprintf(`
testAccAvailableAZsNoOptInConfig()+fmt.Sprintf(`
resource "aws_vpc" "test" {
cidr_block = "10.10.0.0/16"
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_backup_selection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ resource "aws_backup_selection" "test" {
func testAccBackupSelectionConfigWithResources(rName string) string {
return composeConfig(
testAccBackupSelectionConfigBase(rName),
testAccAvailableAZsNoOptInConfig() + fmt.Sprintf(`
testAccAvailableAZsNoOptInConfig()+fmt.Sprintf(`
resource "aws_ebs_volume" "test" {
count = 2
Expand Down
14 changes: 7 additions & 7 deletions aws/resource_aws_directory_service_directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ resource "aws_subnet" "test2" {
}
`

const testAccDirectoryServiceDirectoryConfig = testAccDirectoryServiceDirectoryConfigBase + `
var testAccDirectoryServiceDirectoryConfig = testAccDirectoryServiceDirectoryConfigBase + `
resource "aws_directory_service_directory" "test" {
name = "corp.notexample.com"
password = "SuperSecretPassw0rd"
Expand All @@ -519,7 +519,7 @@ resource "aws_directory_service_directory" "test" {
}
`

const testAccDirectoryServiceDirectoryTagsConfig = testAccDirectoryServiceDirectoryConfigBase + `
var testAccDirectoryServiceDirectoryTagsConfig = testAccDirectoryServiceDirectoryConfigBase + `
resource "aws_directory_service_directory" "test" {
name = "corp.notexample.com"
password = "SuperSecretPassw0rd"
Expand All @@ -537,7 +537,7 @@ resource "aws_directory_service_directory" "test" {
}
`

const testAccDirectoryServiceDirectoryUpdateTagsConfig = testAccDirectoryServiceDirectoryConfigBase + `
var testAccDirectoryServiceDirectoryUpdateTagsConfig = testAccDirectoryServiceDirectoryConfigBase + `
resource "aws_directory_service_directory" "test" {
name = "corp.notexample.com"
password = "SuperSecretPassw0rd"
Expand All @@ -556,7 +556,7 @@ resource "aws_directory_service_directory" "test" {
}
`

const testAccDirectoryServiceDirectoryRemoveTagsConfig = testAccDirectoryServiceDirectoryConfigBase + `
var testAccDirectoryServiceDirectoryRemoveTagsConfig = testAccDirectoryServiceDirectoryConfigBase + `
resource "aws_directory_service_directory" "test" {
name = "corp.notexample.com"
password = "SuperSecretPassw0rd"
Expand All @@ -573,7 +573,7 @@ resource "aws_directory_service_directory" "test" {
}
`

const testAccDirectoryServiceDirectoryConfig_connector = testAccDirectoryServiceDirectoryConfigBase + `
var testAccDirectoryServiceDirectoryConfig_connector = testAccDirectoryServiceDirectoryConfigBase + `
resource "aws_directory_service_directory" "base" {
name = "corp.notexample.com"
password = "SuperSecretPassw0rd"
Expand All @@ -600,7 +600,7 @@ resource "aws_directory_service_directory" "test" {
}
`

const testAccDirectoryServiceDirectoryConfig_microsoft = testAccDirectoryServiceDirectoryConfigBase + `
var testAccDirectoryServiceDirectoryConfig_microsoft = testAccDirectoryServiceDirectoryConfigBase + `
resource "aws_directory_service_directory" "test" {
name = "corp.notexample.com"
password = "SuperSecretPassw0rd"
Expand All @@ -613,7 +613,7 @@ resource "aws_directory_service_directory" "test" {
}
`

const testAccDirectoryServiceDirectoryConfig_microsoftStandard = testAccDirectoryServiceDirectoryConfigBase + `
var testAccDirectoryServiceDirectoryConfig_microsoftStandard = testAccDirectoryServiceDirectoryConfigBase + `
resource "aws_directory_service_directory" "test" {
name = "corp.notexample.com"
password = "SuperSecretPassw0rd"
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_kinesis_firehose_delivery_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,7 @@ resource "aws_kinesis_firehose_delivery_stream" "test" {
func testAccKinesisFirehoseDeliveryStreamRedshiftConfigBase(rName string, rInt int) string {
return composeConfig(
fmt.Sprintf(testAccKinesisFirehoseDeliveryStreamBaseConfig, rInt, rInt, rInt),
testAccAvailableAZsNoOptInConfig() + fmt.Sprintf(`
testAccAvailableAZsNoOptInConfig()+fmt.Sprintf(`
resource "aws_vpc" "test" {
cidr_block = "10.1.0.0/16"
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_spot_fleet_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ func testAccAWSSpotFleetRequestConfigBase(rName string) string {
return composeConfig(
testAccLatestAmazonLinuxHvmEbsAmiConfig(),
testAccAvailableEc2InstanceTypeForRegion("t3.micro", "t2.micro"),
testAccAvailableAZsNoOptInConfig() + fmt.Sprintf(`
testAccAvailableAZsNoOptInConfig()+fmt.Sprintf(`
resource "aws_key_pair" "test" {
key_name = %[1]q
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]"
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_storagegateway_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ func testAccAWSStorageGatewayGatewayConfig_SmbActiveDirectorySettings(rName stri
return composeConfig(
// Reference: https://docs.aws.amazon.com/storagegateway/latest/userguide/Requirements.html
testAccAvailableEc2InstanceTypeForAvailabilityZone("aws_subnet.test[0].availability_zone", "m5.xlarge", "m4.xlarge"),
testAccAvailableAZsNoOptInConfig() + fmt.Sprintf(`
testAccAvailableAZsNoOptInConfig()+fmt.Sprintf(`
# Directory Service Directories must be deployed across multiple EC2 Availability Zones
resource "aws_vpc" "test" {
cidr_block = "10.0.0.0/16"
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_volume_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func testAccVolumeAttachmentInstanceOnlyConfigBase(rName string) string {
return composeConfig(
testAccLatestAmazonLinuxHvmEbsAmiConfig(),
testAccAvailableEc2InstanceTypeForAvailabilityZone("data.aws_availability_zones.available.names[0]", "t3.micro", "t2.micro"),
testAccAvailableAZsNoOptInConfig() + fmt.Sprintf(`
testAccAvailableAZsNoOptInConfig()+fmt.Sprintf(`
resource "aws_instance" "test" {
ami = "${data.aws_ami.amzn-ami-minimal-hvm-ebs.id}"
availability_zone = "${data.aws_availability_zones.available.names[0]}"
Expand Down
186 changes: 94 additions & 92 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,7 @@ func testAccCheckVpcEndpointConnectionNotificationExists(n string) resource.Test
}

func testAccVpcEndpointConnectionNotificationBasicConfig(lbName string) string {
return fmt.Sprintf(
`
return testAccAvailableAZsNoOptInConfig() + fmt.Sprintf(`
resource "aws_vpc" "nlb_test" {
cidr_block = "10.0.0.0/16"
Expand All @@ -120,8 +119,8 @@ resource "aws_lb" "nlb_test" {
name = "%s"
subnets = [
"${aws_subnet.nlb_test_1.id}",
"${aws_subnet.nlb_test_2.id}",
aws_subnet.nlb_test_1.id,
aws_subnet.nlb_test_2.id,
]
load_balancer_type = "network"
Expand All @@ -135,19 +134,19 @@ resource "aws_lb" "nlb_test" {
}
resource "aws_subnet" "nlb_test_1" {
vpc_id = "${aws_vpc.nlb_test.id}"
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"
}
}
resource "aws_subnet" "nlb_test_2" {
vpc_id = "${aws_vpc.nlb_test.id}"
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 All @@ -160,11 +159,11 @@ resource "aws_vpc_endpoint_service" "test" {
acceptance_required = false
network_load_balancer_arns = [
"${aws_lb.nlb_test.id}",
aws_lb.nlb_test.id,
]
allowed_principals = [
"${data.aws_caller_identity.current.arn}"
data.aws_caller_identity.current.arn
]
}
Expand All @@ -173,112 +172,115 @@ resource "aws_sns_topic" "topic" {
policy = <<POLICY
{
"Version":"2012-10-17",
"Statement":[{
"Effect": "Allow",
"Principal": {
"Service": "vpce.amazonaws.com"
},
"Action": "SNS:Publish",
"Resource": "arn:aws:sns:*:*:vpce-notification-topic"
}]
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "vpce.amazonaws.com"
},
"Action": "SNS:Publish",
"Resource": "arn:aws:sns:*:*:vpce-notification-topic"
}
]
}
POLICY
}
resource "aws_vpc_endpoint_connection_notification" "test" {
vpc_endpoint_service_id = "${aws_vpc_endpoint_service.test.id}"
connection_notification_arn = "${aws_sns_topic.topic.arn}"
connection_events = ["Accept", "Reject"]
vpc_endpoint_service_id = aws_vpc_endpoint_service.test.id
connection_notification_arn = aws_sns_topic.topic.arn
connection_events = ["Accept", "Reject"]
}
`, lbName)
}

func testAccVpcEndpointConnectionNotificationModifiedConfig(lbName string) string {
return fmt.Sprintf(
`
resource "aws_vpc" "nlb_test" {
cidr_block = "10.0.0.0/16"
return testAccAvailableAZsNoOptInConfig() + fmt.Sprintf(`
resource "aws_vpc" "nlb_test" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "terraform-testacc-vpc-endpoint-connection-notification"
}
}
tags = {
Name = "terraform-testacc-vpc-endpoint-connection-notification"
}
}
resource "aws_lb" "nlb_test" {
name = "%s"
resource "aws_lb" "nlb_test" {
name = "%s"
subnets = [
"${aws_subnet.nlb_test_1.id}",
"${aws_subnet.nlb_test_2.id}",
]
subnets = [
aws_subnet.nlb_test_1.id,
aws_subnet.nlb_test_2.id,
]
load_balancer_type = "network"
internal = true
idle_timeout = 60
enable_deletion_protection = false
load_balancer_type = "network"
internal = true
idle_timeout = 60
enable_deletion_protection = false
tags = {
Name = "testAccVpcEndpointConnectionNotificationBasicConfig_nlb"
}
}
tags = {
Name = "testAccVpcEndpointConnectionNotificationBasicConfig_nlb"
}
}
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"
resource "aws_subnet" "nlb_test_1" {
vpc_id = aws_vpc.nlb_test.id
cidr_block = "10.0.1.0/24"
availability_zone = data.aws_availability_zones.available.names[0]
tags = {
Name = "tf-acc-vpc-endpoint-connection-notification-1"
}
}
tags = {
Name = "tf-acc-vpc-endpoint-connection-notification-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"
resource "aws_subnet" "nlb_test_2" {
vpc_id = aws_vpc.nlb_test.id
cidr_block = "10.0.2.0/24"
availability_zone = data.aws_availability_zones.available.names[1]
tags = {
Name = "tf-acc-vpc-endpoint-connection-notification-2"
}
}
tags = {
Name = "tf-acc-vpc-endpoint-connection-notification-2"
}
}
data "aws_caller_identity" "current" {}
data "aws_caller_identity" "current" {}
resource "aws_vpc_endpoint_service" "test" {
acceptance_required = false
resource "aws_vpc_endpoint_service" "test" {
acceptance_required = false
network_load_balancer_arns = [
"${aws_lb.nlb_test.id}",
]
network_load_balancer_arns = [
aws_lb.nlb_test.id,
]
allowed_principals = [
"${data.aws_caller_identity.current.arn}"
]
}
allowed_principals = [
data.aws_caller_identity.current.arn
]
}
resource "aws_sns_topic" "topic" {
name = "vpce-notification-topic"
policy = <<POLICY
{
"Version":"2012-10-17",
"Statement":[{
"Effect": "Allow",
"Principal": {
"Service": "vpce.amazonaws.com"
},
"Action": "SNS:Publish",
"Resource": "arn:aws:sns:*:*:vpce-notification-topic"
}]
}
POLICY
}
resource "aws_sns_topic" "topic" {
name = "vpce-notification-topic"
resource "aws_vpc_endpoint_connection_notification" "test" {
vpc_endpoint_service_id = "${aws_vpc_endpoint_service.test.id}"
connection_notification_arn = "${aws_sns_topic.topic.arn}"
connection_events = ["Accept"]
}
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "vpce.amazonaws.com"
},
"Action": "SNS:Publish",
"Resource": "arn:aws:sns:*:*:vpce-notification-topic"
}
]
}
POLICY
}
resource "aws_vpc_endpoint_connection_notification" "test" {
vpc_endpoint_service_id = aws_vpc_endpoint_service.test.id
connection_notification_arn = aws_sns_topic.topic.arn
connection_events = ["Accept"]
}
`, lbName)
}
Loading

0 comments on commit 9663ecd

Please sign in to comment.