Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates resource acceptance tests to Terraform 0.12 syntax, batch 3: EBS to GuardDuty #15070

Merged
merged 10 commits into from
Sep 14, 2020
13 changes: 12 additions & 1 deletion .github/workflows/acctest-terraform-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- .github/workflows/acctest-terraform-lint.yml
- aws/core_acceptance_test.go
- aws/data_source_aws_*_test.go
- aws/resource_aws_[a-d]*_test.go
- aws/resource_aws_[a-g]*_test.go

env:
GO_VERSION: "1.14"
Expand Down Expand Up @@ -44,10 +44,15 @@ jobs:
-o -name 'resource_aws_b*_test.go' \
-o -name 'resource_aws_c*_test.go' \
-o -name 'resource_aws_d*_test.go' \
-o -name 'resource_aws_e*_test.go' \
-o -name 'resource_aws_f*_test.go' \
-o -name 'resource_aws_g*_test.go' \
\) \
| sort -u \
| grep -v resource_aws_apigatewayv2_domain_name_test.go \
| grep -v resource_aws_dynamodb_table_test.go \
| grep -v resource_aws_ecs_capacity_provider_test.go \
| grep -v resource_aws_efs_file_system_test.go \
| xargs -I {} terrafmt diff --check --quiet --fmtcompat {}

validate-terraform:
Expand Down Expand Up @@ -82,9 +87,15 @@ jobs:
-o -name 'resource_aws_b*_test.go' \
-o -name 'resource_aws_c*_test.go' \
-o -name 'resource_aws_d*_test.go' \
-o -name 'resource_aws_e*_test.go' \
-o -name 'resource_aws_f*_test.go' \
-o -name 'resource_aws_g*_test.go' \
\) \
| sort -u \
| grep -v resource_aws_apigatewayv2_domain_name_test.go \
| grep -v resource_aws_dynamodb_table_test.go \
| grep -v resource_aws_ecs_capacity_provider_test.go \
| grep -v resource_aws_efs_file_system_test.go \
| grep -v resource_aws_elasticache_cluster_test.go \
| ./scripts/validate-terraform.sh

2 changes: 1 addition & 1 deletion aws/data_source_aws_outposts_outposts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func testAccPreCheckAWSOutpostsOutposts(t *testing.T) {

// Ensure there is at least one Outpost
if output == nil || len(output.Outposts) == 0 {
t.Skip("skipping since no Outposts Outpost found")
t.Skip("skipping since no Outposts found")
}
}

Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_ebs_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ resource "aws_instance" "test" {
}

tags = {
Name = "test-terraform"
Name = "test-terraform"
}
}

Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_ec2_availability_zone_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ data "aws_availability_zones" "test" {
# Filter to one Availability Zone Group per Region as Local Zones become available
# e.g. ensure there are not two us-west-2-XXX when adding to this list
filter {
name = "group-name"
name = "group-name"
values = [
"us-west-2-lax-1",
]
Expand Down
6 changes: 3 additions & 3 deletions aws/resource_aws_ec2_client_vpn_authorization_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,12 @@ resource "aws_ec2_client_vpn_endpoint" "test" {
client_cidr_block = "10.0.0.0/16"

authentication_options {
type = "certificate-authentication"
root_certificate_chain_arn = aws_acm_certificate.test.arn
type = "certificate-authentication"
root_certificate_chain_arn = aws_acm_certificate.test.arn
}

connection_log_options {
enabled = false
enabled = false
}
}`, rName))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ resource "aws_ec2_client_vpn_network_association" "test" {
subnet_id = aws_subnet.test.id
security_groups = [aws_security_group.test1.id, aws_security_group.test2.id]
}

resource "aws_ec2_client_vpn_endpoint" "test" {
description = "terraform-testacc-clientvpn-%[1]s"
server_certificate_arn = aws_acm_certificate.test.arn
Expand Down
14 changes: 7 additions & 7 deletions aws/resource_aws_ec2_client_vpn_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ resource "aws_ec2_client_vpn_endpoint" "test" {
client_cidr_block = "10.0.0.0/16"

authentication_options {
type = "certificate-authentication"
root_certificate_chain_arn = aws_acm_certificate.test.arn
type = "certificate-authentication"
root_certificate_chain_arn = aws_acm_certificate.test.arn
}

connection_log_options {
enabled = false
enabled = false
}
}
`, rName))
Expand All @@ -195,7 +195,7 @@ resource "aws_ec2_client_vpn_route" "test" {
description = "test client VPN route"

depends_on = [
aws_ec2_client_vpn_network_association.test,
aws_ec2_client_vpn_network_association.test,
]
}

Expand All @@ -210,12 +210,12 @@ resource "aws_ec2_client_vpn_endpoint" "test" {
client_cidr_block = "10.0.0.0/16"

authentication_options {
type = "certificate-authentication"
root_certificate_chain_arn = aws_acm_certificate.test.arn
type = "certificate-authentication"
root_certificate_chain_arn = aws_acm_certificate.test.arn
}

connection_log_options {
enabled = false
enabled = false
}
}
`, rName))
Expand Down
14 changes: 7 additions & 7 deletions aws/resource_aws_ec2_fleet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1385,8 +1385,8 @@ resource "aws_launch_template" "test2" {
resource "aws_ec2_fleet" "test" {
launch_template_config {
launch_template_specification {
launch_template_id = "${%s.id}"
version = "${%s.latest_version}"
launch_template_id = %s.id
version = %s.latest_version
}
}

Expand Down Expand Up @@ -1425,8 +1425,8 @@ resource "aws_launch_template" "test2" {
resource "aws_ec2_fleet" "test" {
launch_template_config {
launch_template_specification {
launch_template_name = "${%s.name}"
version = "${%s.latest_version}"
launch_template_name = %s.name
version = %s.latest_version
}
}

Expand Down Expand Up @@ -1491,7 +1491,7 @@ resource "aws_ec2_fleet" "test" {
}

override {
availability_zone = "${data.aws_availability_zones.available.names[%d]}"
availability_zone = data.aws_availability_zones.available.names[%d]
}
}

Expand Down Expand Up @@ -1615,7 +1615,7 @@ resource "aws_subnet" "test" {
count = 2

cidr_block = "10.1.${count.index}.0/24"
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id

tags = {
Name = var.TestAccNameTag
Expand All @@ -1630,7 +1630,7 @@ resource "aws_ec2_fleet" "test" {
}

override {
subnet_id = "${aws_subnet.test.*.id[%d]}"
subnet_id = aws_subnet.test.*.id[%d]
}
}

Expand Down
10 changes: 5 additions & 5 deletions aws/resource_aws_ec2_traffic_mirror_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ resource "aws_lb" "lb" {
load_balancer_type = "network"
subnets = [aws_subnet.sub1.id, aws_subnet.sub2.id]

enable_deletion_protection = false
enable_deletion_protection = false

tags = {
Name = %[1]q
Expand All @@ -254,12 +254,12 @@ data "aws_ami" "amzn-linux" {
most_recent = true

filter {
name = "name"
name = "name"
values = ["amzn2-ami-hvm-2.0*"]
}

filter {
name = "architecture"
name = "architecture"
values = ["x86_64"]
}

Expand Down Expand Up @@ -291,7 +291,7 @@ resource "aws_lb" "lb" {
load_balancer_type = "network"
subnets = [aws_subnet.sub1.id, aws_subnet.sub2.id]

enable_deletion_protection = false
enable_deletion_protection = false

tags = {
Name = %[1]q
Expand All @@ -318,7 +318,7 @@ resource "aws_lb" "lb" {
load_balancer_type = "network"
subnets = [aws_subnet.sub1.id, aws_subnet.sub2.id]

enable_deletion_protection = false
enable_deletion_protection = false

tags = {
Name = %[1]q
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ resource "aws_ec2_transit_gateway_peering_attachment" "test" {
transit_gateway_id = aws_ec2_transit_gateway.test.id

tags = {
Name = %[2]q
Name = %[2]q

%[3]s = %[4]q
}
}
Expand All @@ -392,7 +393,8 @@ resource "aws_ec2_transit_gateway_peering_attachment" "test" {
transit_gateway_id = aws_ec2_transit_gateway.test.id

tags = {
Name = %[2]q
Name = %[2]q

%[3]s = %[4]q
%[5]s = %[6]q
}
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_ec2_transit_gateway_vpc_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ resource "aws_subnet" "test" {
resource "aws_ec2_transit_gateway" "test" {}

resource "aws_ec2_transit_gateway_vpc_attachment" "test" {
subnet_ids = [aws_subnet.test.0.id]
subnet_ids = [aws_subnet.test[0].id]
transit_gateway_id = aws_ec2_transit_gateway.test.id
vpc_id = aws_vpc.test.id
}
Expand Down Expand Up @@ -816,7 +816,7 @@ resource "aws_subnet" "test" {
resource "aws_ec2_transit_gateway" "test" {}

resource "aws_ec2_transit_gateway_vpc_attachment" "test" {
subnet_ids = [aws_subnet.test.0.id, aws_subnet.test.1.id]
subnet_ids = [aws_subnet.test[0].id, aws_subnet.test[1].id]
transit_gateway_id = aws_ec2_transit_gateway.test.id
vpc_id = aws_vpc.test.id
}
Expand Down
18 changes: 9 additions & 9 deletions aws/resource_aws_ecs_capacity_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,13 @@ resource "aws_autoscaling_group" "test" {
id = aws_launch_template.test.id
}

tags = [
{
key = "foo"
value = "bar"
propagate_at_launch = true
},
]
tags = [
{
key = "foo"
value = "bar"
propagate_at_launch = true
},
]
}
`, rName)
}
Expand Down Expand Up @@ -427,10 +427,10 @@ resource "aws_ecs_capacity_provider" "test" {
func testAccAWSEcsCapacityProviderConfigTags1(rName, tag1Key, tag1Value string) string {
return testAccAWSEcsCapacityProviderConfigBase(rName) + fmt.Sprintf(`
resource "aws_ecs_capacity_provider" "test" {
name = %q
name = %[1]q

tags = {
%q = %q,
%[2]q = %[3]q,
}

auto_scaling_group_provider {
Expand Down
22 changes: 11 additions & 11 deletions aws/resource_aws_ecs_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,27 +426,27 @@ resource "aws_ecs_cluster" "test" {
func testAccAWSEcsClusterCapacityProviderConfig(rName string) string {
return testAccAWSEcsCapacityProviderConfigBase(rName) + fmt.Sprintf(`
resource "aws_ecs_capacity_provider" "test" {
name = %q
name = %q

auto_scaling_group_provider {
auto_scaling_group_arn = aws_autoscaling_group.test.arn
}
auto_scaling_group_provider {
auto_scaling_group_arn = aws_autoscaling_group.test.arn
}
}
`, rName)
}

func testAccAWSEcsClusterSingleCapacityProvider(rName, providerName string) string {
return testAccAWSEcsClusterCapacityProviderConfig(providerName) + fmt.Sprintf(`
resource "aws_ecs_cluster" "test" {
name = %[1]q
name = %[1]q

capacity_providers = [aws_ecs_capacity_provider.test.name]
capacity_providers = [aws_ecs_capacity_provider.test.name]

default_capacity_provider_strategy {
base = 1
capacity_provider = aws_ecs_capacity_provider.test.name
weight = 1
}
default_capacity_provider_strategy {
base = 1
capacity_provider = aws_ecs_capacity_provider.test.name
weight = 1
}
}
`, rName)
}
Expand Down
10 changes: 5 additions & 5 deletions aws/resource_aws_ecs_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1424,8 +1424,8 @@ resource "aws_ecs_service" "mongo" {

capacity_provider_strategy {
capacity_provider = aws_ecs_capacity_provider.test.name
weight = %d
base = %d
weight = %d
base = %d
}
}
`, providerName, clusterName, tdName, svcName, weight, base)
Expand All @@ -1438,7 +1438,7 @@ resource "aws_ecs_service" "mongo" {
cluster = aws_ecs_cluster.test.id
task_definition = aws_ecs_task_definition.mongo.arn
desired_count = 1

network_configuration {
security_groups = [aws_security_group.allow_all.id]
subnets = [aws_subnet.main.id]
Expand Down Expand Up @@ -1490,8 +1490,8 @@ resource "aws_security_group" "allow_all" {
}

resource "aws_subnet" "main" {
cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, 1)
vpc_id = aws_vpc.main.id
cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, 1)
vpc_id = aws_vpc.main.id

tags = {
Name = "tf-acc-ecs-service-with-multiple-capacity-providers"
Expand Down
Loading