Skip to content

Commit

Permalink
tests/provider: Update resource testing to 0.12 syntax (O Resources)
Browse files Browse the repository at this point in the history
  • Loading branch information
YakDriver committed Aug 13, 2020
1 parent 0a61ba7 commit a31a923
Show file tree
Hide file tree
Showing 20 changed files with 572 additions and 359 deletions.
10 changes: 6 additions & 4 deletions aws/resource_aws_opsworks_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ resource "aws_opsworks_application" "test" {
document_root = "foo"
enable_ssl = false
name = %q
stack_id = "${aws_opsworks_stack.tf-acc.id}"
stack_id = aws_opsworks_stack.tf-acc.id
type = "other"
app_source {
Expand All @@ -292,7 +292,7 @@ resource "aws_opsworks_application" "test" {
enable_ssl = true
name = %q
rails_env = "staging"
stack_id = "${aws_opsworks_stack.tf-acc.id}"
stack_id = aws_opsworks_stack.tf-acc.id
type = "rails"
ssl_configuration {
Expand All @@ -313,6 +313,7 @@ iIbYXlwkPYAArDPv3wT5AkAwp4vym+YKmDqh6gseKfRDuJqRiW9yD5A8VGr/w88k
5rkuduVGP7tK3uIp00Its3aEyKF8mLGWYszVGeeLxAMH
-----END RSA PRIVATE KEY-----
EOS
certificate = <<EOS
-----BEGIN CERTIFICATE-----
MIIBkDCB+gIJALoScFD0sJq3MA0GCSqGSIb3DQEBBQUAMA0xCzAJBgNVBAYTAkRF
Expand All @@ -326,12 +327,13 @@ OZWPlwiUJbNIpK+04Bg2vd5m/NMMrvi75RfmyeMtSfq/NrIX2Q3+nyWI7DLq7yZI
V/YEvOqdAiy5NEWBztHx8HvB9G4=
-----END CERTIFICATE-----
EOS
}
app_source {
type = "git"
type = "git"
revision = "master"
url = "https://github.com/aws/example.git"
url = "https://github.com/aws/example.git"
}
environment {
Expand Down
100 changes: 54 additions & 46 deletions aws/resource_aws_opsworks_custom_layer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,47 +320,48 @@ resource "aws_security_group" "tf-ops-acc-layer2" {
func testAccAwsOpsworksCustomLayerConfigNoVpcCreate(name string) string {
return fmt.Sprintf(`
resource "aws_opsworks_custom_layer" "tf-acc" {
stack_id = "${aws_opsworks_stack.tf-acc.id}"
name = "%s"
short_name = "tf-ops-acc-custom-layer"
stack_id = aws_opsworks_stack.tf-acc.id
name = "%s"
short_name = "tf-ops-acc-custom-layer"
auto_assign_public_ips = true
custom_security_group_ids = [
"${aws_security_group.tf-ops-acc-layer1.id}",
"${aws_security_group.tf-ops-acc-layer2.id}",
aws_security_group.tf-ops-acc-layer1.id,
aws_security_group.tf-ops-acc-layer2.id,
]
drain_elb_on_shutdown = true
drain_elb_on_shutdown = true
instance_shutdown_timeout = 300
system_packages = [
"git",
"golang",
]
ebs_volume {
type = "gp2"
type = "gp2"
number_of_disks = 2
mount_point = "/home"
size = 100
raid_level = 0
encrypted = false
mount_point = "/home"
size = 100
raid_level = 0
encrypted = false
}
}
%s
%s
%s
`, name, testAccAwsOpsworksStackConfigNoVpcCreate(name), testAccAwsOpsworksCustomLayerSecurityGroups(name))
}

func testAccAwsOpsworksCustomLayerConfigVpcCreate(name string) string {
return fmt.Sprintf(`
resource "aws_opsworks_custom_layer" "tf-acc" {
stack_id = "${aws_opsworks_stack.tf-acc.id}"
stack_id = aws_opsworks_stack.tf-acc.id
name = "%s"
short_name = "tf-ops-acc-custom-layer"
auto_assign_public_ips = false
custom_security_group_ids = [
"${aws_security_group.tf-ops-acc-layer1.id}",
"${aws_security_group.tf-ops-acc-layer2.id}",
aws_security_group.tf-ops-acc-layer1.id,
aws_security_group.tf-ops-acc-layer2.id,
]
drain_elb_on_shutdown = true
Expand All @@ -382,63 +383,70 @@ resource "aws_opsworks_custom_layer" "tf-acc" {
%s
%s
`, name, testAccAwsOpsworksStackConfigVpcCreate(name), testAccAwsOpsworksCustomLayerSecurityGroups(name))
}

func testAccAwsOpsworksCustomLayerConfigUpdate(name string) string {
return fmt.Sprintf(`
resource "aws_security_group" "tf-ops-acc-layer3" {
name = "tf-ops-acc-layer-%[1]s"
ingress {
from_port = 8
to_port = -1
protocol = "icmp"
from_port = 8
to_port = -1
protocol = "icmp"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_opsworks_custom_layer" "tf-acc" {
stack_id = "${aws_opsworks_stack.tf-acc.id}"
name = "%[1]s"
short_name = "tf-ops-acc-custom-layer"
stack_id = aws_opsworks_stack.tf-acc.id
name = "%[1]s"
short_name = "tf-ops-acc-custom-layer"
auto_assign_public_ips = true
custom_security_group_ids = [
"${aws_security_group.tf-ops-acc-layer1.id}",
"${aws_security_group.tf-ops-acc-layer2.id}",
"${aws_security_group.tf-ops-acc-layer3.id}",
aws_security_group.tf-ops-acc-layer1.id,
aws_security_group.tf-ops-acc-layer2.id,
aws_security_group.tf-ops-acc-layer3.id,
]
drain_elb_on_shutdown = false
drain_elb_on_shutdown = false
instance_shutdown_timeout = 120
system_packages = [
"git",
"golang",
"subversion",
]
ebs_volume {
type = "gp2"
type = "gp2"
number_of_disks = 2
mount_point = "/home"
size = 100
raid_level = 0
encrypted = true
mount_point = "/home"
size = 100
raid_level = 0
encrypted = true
}
ebs_volume {
type = "io1"
type = "io1"
number_of_disks = 4
mount_point = "/var"
size = 100
raid_level = 1
iops = 3000
encrypted = true
mount_point = "/var"
size = 100
raid_level = 1
iops = 3000
encrypted = true
}
custom_json = "{\"layer_key\": \"layer_value2\"}"
custom_json = <<EOF
{
"layer_key": "layer_value2"
}
EOF
}
%s
%s
%s
`, name, testAccAwsOpsworksStackConfigNoVpcCreate(name), testAccAwsOpsworksCustomLayerSecurityGroups(name))
}

Expand All @@ -447,14 +455,14 @@ func testAccAwsOpsworksCustomLayerConfigTags1(name, tagKey1, tagValue1 string) s
testAccAwsOpsworksCustomLayerSecurityGroups(name) +
fmt.Sprintf(`
resource "aws_opsworks_custom_layer" "test" {
stack_id = "${aws_opsworks_stack.tf-acc.id}"
stack_id = aws_opsworks_stack.tf-acc.id
name = %[1]q
short_name = "tf-ops-acc-custom-layer"
auto_assign_public_ips = false
custom_security_group_ids = [
"${aws_security_group.tf-ops-acc-layer1.id}",
"${aws_security_group.tf-ops-acc-layer2.id}",
aws_security_group.tf-ops-acc-layer1.id,
aws_security_group.tf-ops-acc-layer2.id,
]
drain_elb_on_shutdown = true
Expand Down Expand Up @@ -485,14 +493,14 @@ func testAccAwsOpsworksCustomLayerConfigTags2(name, tagKey1, tagValue1, tagKey2,
testAccAwsOpsworksCustomLayerSecurityGroups(name) +
fmt.Sprintf(`
resource "aws_opsworks_custom_layer" "test" {
stack_id = "${aws_opsworks_stack.tf-acc.id}"
stack_id = aws_opsworks_stack.tf-acc.id
name = %[1]q
short_name = "tf-ops-acc-custom-layer"
auto_assign_public_ips = false
custom_security_group_ids = [
"${aws_security_group.tf-ops-acc-layer1.id}",
"${aws_security_group.tf-ops-acc-layer2.id}",
aws_security_group.tf-ops-acc-layer1.id,
aws_security_group.tf-ops-acc-layer2.id,
]
drain_elb_on_shutdown = true
Expand Down
18 changes: 9 additions & 9 deletions aws/resource_aws_opsworks_ganglia_layer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ func testAccAwsOpsworksGangliaLayerConfigVpcCreate(name string) string {
testAccAwsOpsworksCustomLayerSecurityGroups(name) +
fmt.Sprintf(`
resource "aws_opsworks_ganglia_layer" "test" {
stack_id = "${aws_opsworks_stack.tf-acc.id}"
stack_id = aws_opsworks_stack.tf-acc.id
name = %[1]q
password = %[1]q
custom_security_group_ids = [
"${aws_security_group.tf-ops-acc-layer1.id}",
"${aws_security_group.tf-ops-acc-layer2.id}",
aws_security_group.tf-ops-acc-layer1.id,
aws_security_group.tf-ops-acc-layer2.id,
]
}
`, name)
Expand All @@ -94,13 +94,13 @@ func testAccAwsOpsworksGangliaLayerConfigTags1(name, tagKey1, tagValue1 string)
testAccAwsOpsworksCustomLayerSecurityGroups(name) +
fmt.Sprintf(`
resource "aws_opsworks_ganglia_layer" "test" {
stack_id = "${aws_opsworks_stack.tf-acc.id}"
stack_id = aws_opsworks_stack.tf-acc.id
name = %[1]q
password = %[1]q
custom_security_group_ids = [
"${aws_security_group.tf-ops-acc-layer1.id}",
"${aws_security_group.tf-ops-acc-layer2.id}",
aws_security_group.tf-ops-acc-layer1.id,
aws_security_group.tf-ops-acc-layer2.id,
]
tags = {
Expand All @@ -115,13 +115,13 @@ func testAccAwsOpsworksGangliaLayerConfigTags2(name, tagKey1, tagValue1, tagKey2
testAccAwsOpsworksCustomLayerSecurityGroups(name) +
fmt.Sprintf(`
resource "aws_opsworks_ganglia_layer" "test" {
stack_id = "${aws_opsworks_stack.tf-acc.id}"
stack_id = aws_opsworks_stack.tf-acc.id
name = %[1]q
password = %[1]q
custom_security_group_ids = [
"${aws_security_group.tf-ops-acc-layer1.id}",
"${aws_security_group.tf-ops-acc-layer2.id}",
aws_security_group.tf-ops-acc-layer1.id,
aws_security_group.tf-ops-acc-layer2.id,
]
tags = {
Expand Down
18 changes: 9 additions & 9 deletions aws/resource_aws_opsworks_haproxy_layer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ func testAccAwsOpsworksHAProxyLayerConfigVpcCreate(name string) string {
testAccAwsOpsworksCustomLayerSecurityGroups(name) +
fmt.Sprintf(`
resource "aws_opsworks_haproxy_layer" "test" {
stack_id = "${aws_opsworks_stack.tf-acc.id}"
stack_id = aws_opsworks_stack.tf-acc.id
name = %[1]q
stats_password = %[1]q
custom_security_group_ids = [
"${aws_security_group.tf-ops-acc-layer1.id}",
"${aws_security_group.tf-ops-acc-layer2.id}",
aws_security_group.tf-ops-acc-layer1.id,
aws_security_group.tf-ops-acc-layer2.id,
]
}
`, name)
Expand All @@ -94,13 +94,13 @@ func testAccAwsOpsworksHAProxyLayerConfigTags1(name, tagKey1, tagValue1 string)
testAccAwsOpsworksCustomLayerSecurityGroups(name) +
fmt.Sprintf(`
resource "aws_opsworks_haproxy_layer" "test" {
stack_id = "${aws_opsworks_stack.tf-acc.id}"
stack_id = aws_opsworks_stack.tf-acc.id
name = %[1]q
stats_password = %[1]q
custom_security_group_ids = [
"${aws_security_group.tf-ops-acc-layer1.id}",
"${aws_security_group.tf-ops-acc-layer2.id}",
aws_security_group.tf-ops-acc-layer1.id,
aws_security_group.tf-ops-acc-layer2.id,
]
tags = {
Expand All @@ -115,13 +115,13 @@ func testAccAwsOpsworksHAProxyLayerConfigTags2(name, tagKey1, tagValue1, tagKey2
testAccAwsOpsworksCustomLayerSecurityGroups(name) +
fmt.Sprintf(`
resource "aws_opsworks_haproxy_layer" "test" {
stack_id = "${aws_opsworks_stack.tf-acc.id}"
stack_id = aws_opsworks_stack.tf-acc.id
name = %[1]q
stats_password = %[1]q
custom_security_group_ids = [
"${aws_security_group.tf-ops-acc-layer1.id}",
"${aws_security_group.tf-ops-acc-layer2.id}",
aws_security_group.tf-ops-acc-layer1.id,
aws_security_group.tf-ops-acc-layer2.id,
]
tags = {
Expand Down
Loading

0 comments on commit a31a923

Please sign in to comment.