Skip to content

Commit

Permalink
Fix data source config formatting, 0.12 up to regions
Browse files Browse the repository at this point in the history
  • Loading branch information
YakDriver committed Aug 5, 2020
1 parent f213ed9 commit 00a8231
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 97 deletions.
1 change: 1 addition & 0 deletions aws/data_source_aws_lambda_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ resource "aws_efs_access_point" "access_point_1" {
root_directory {
path = "/lambda"
creation_info {
owner_gid = 1000
owner_uid = 1000
Expand Down
1 change: 0 additions & 1 deletion aws/data_source_aws_launch_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ func TestAccAWSLaunchTemplateDataSource_associatePublicIPAddress(t *testing.T) {
}

func TestAccAWSLaunchTemplateDataSource_NonExistent(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand Down
14 changes: 7 additions & 7 deletions aws/data_source_aws_nat_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ resource "aws_vpc" "test" {
}
resource "aws_subnet" "test" {
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
cidr_block = "172.%d.123.0/24"
availability_zone = "us-west-2a"
Expand All @@ -68,16 +68,16 @@ resource "aws_eip" "test" {
# IGWs are required for an NGW to spin up; manual dependency
resource "aws_internet_gateway" "test" {
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
tags = {
Name = "terraform-testacc-nat-gateway-data-source-%d"
}
}
resource "aws_nat_gateway" "test" {
subnet_id = "${aws_subnet.test.id}"
allocation_id = "${aws_eip.test.id}"
subnet_id = aws_subnet.test.id
allocation_id = aws_eip.test.id
tags = {
Name = "terraform-testacc-nat-gw-data-source-%d"
Expand All @@ -88,16 +88,16 @@ resource "aws_nat_gateway" "test" {
}
data "aws_nat_gateway" "test_by_id" {
id = "${aws_nat_gateway.test.id}"
id = aws_nat_gateway.test.id
}
data "aws_nat_gateway" "test_by_subnet_id" {
subnet_id = "${aws_nat_gateway.test.subnet_id}"
subnet_id = aws_nat_gateway.test.subnet_id
}
data "aws_nat_gateway" "test_by_tags" {
tags = {
Name = "${aws_nat_gateway.test.tags["Name"]}"
Name = aws_nat_gateway.test.tags["Name"]
}
}
`, rInt, rInt, rInt, rInt)
Expand Down
8 changes: 4 additions & 4 deletions aws/data_source_aws_network_acls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ resource "aws_vpc" "test" {
resource "aws_network_acl" "acl" {
count = 2
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
tags = {
Name = "testacc-acl-%s"
Expand All @@ -116,7 +116,7 @@ func testAccDataSourceAwsNetworkAclsConfig_Filter(rName string) string {
data "aws_network_acls" "test" {
filter {
name = "network-acl-id"
values = ["${aws_network_acl.acl.0.id}"]
values = [aws_network_acl.acl.0.id]
}
}
`
Expand All @@ -126,7 +126,7 @@ func testAccDataSourceAwsNetworkAclsConfig_Tags(rName string) string {
return testAccDataSourceAwsNetworkAclsConfig_Base(rName) + `
data "aws_network_acls" "test" {
tags = {
Name = "${aws_network_acl.acl.0.tags.Name}"
Name = aws_network_acl.acl.0.tags.Name
}
}
`
Expand All @@ -135,7 +135,7 @@ data "aws_network_acls" "test" {
func testAccDataSourceAwsNetworkAclsConfig_VpcID(rName string) string {
return testAccDataSourceAwsNetworkAclsConfig_Base(rName) + `
data "aws_network_acls" "test" {
vpc_id = "${aws_network_acl.acl.0.vpc_id}"
vpc_id = aws_network_acl.acl.0.vpc_id
}
`
}
24 changes: 12 additions & 12 deletions aws/data_source_aws_network_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ resource "aws_vpc" "test" {
resource "aws_subnet" "test" {
cidr_block = "10.0.0.0/24"
availability_zone = "${data.aws_availability_zones.available.names[0]}"
vpc_id = "${aws_vpc.test.id}"
availability_zone = data.aws_availability_zones.available.names[0]
vpc_id = aws_vpc.test.id
tags = {
Name = "tf-acc-eni-data-source-basic"
Expand All @@ -64,17 +64,17 @@ resource "aws_subnet" "test" {
resource "aws_security_group" "test" {
name = "tf-sg-%s"
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
}
resource "aws_network_interface" "test" {
subnet_id = "${aws_subnet.test.id}"
subnet_id = aws_subnet.test.id
private_ips = ["10.0.0.50"]
security_groups = ["${aws_security_group.test.id}"]
security_groups = [aws_security_group.test.id]
}
data "aws_network_interface" "test" {
id = "${aws_network_interface.test.id}"
id = aws_network_interface.test.id
}
`, rName)
}
Expand Down Expand Up @@ -117,8 +117,8 @@ resource "aws_vpc" "test" {
resource "aws_subnet" "test" {
cidr_block = "10.0.0.0/24"
availability_zone = "${data.aws_availability_zones.available.names[0]}"
vpc_id = "${aws_vpc.test.id}"
availability_zone = data.aws_availability_zones.available.names[0]
vpc_id = aws_vpc.test.id
tags = {
Name = "tf-acc-eni-data-source-filters"
Expand All @@ -127,19 +127,19 @@ resource "aws_subnet" "test" {
resource "aws_security_group" "test" {
name = "tf-sg-%s"
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
}
resource "aws_network_interface" "test" {
subnet_id = "${aws_subnet.test.id}"
subnet_id = aws_subnet.test.id
private_ips = ["10.0.0.60"]
security_groups = ["${aws_security_group.test.id}"]
security_groups = [aws_security_group.test.id]
}
data "aws_network_interface" "test" {
filter {
name = "network-interface-id"
values = ["${aws_network_interface.test.id}"]
values = [aws_network_interface.test.id]
}
}
`, rName)
Expand Down
12 changes: 6 additions & 6 deletions aws/data_source_aws_network_interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ resource "aws_vpc" "test" {
resource "aws_subnet" "test" {
cidr_block = "10.0.0.0/24"
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
tags = {
Name = "terraform-testacc-eni-data-source-basic-%s"
}
}
resource "aws_network_interface" "test" {
subnet_id = "${aws_subnet.test.id}"
subnet_id = aws_subnet.test.id
}
resource "aws_network_interface" "test1" {
subnet_id = "${aws_subnet.test.id}"
subnet_id = aws_subnet.test.id
tags = {
Name = "${aws_vpc.test.tags.Name}"
Name = aws_vpc.test.tags.Name
}
}
`, rName, rName)
Expand All @@ -80,7 +80,7 @@ func testAccDataSourceAwsNetworkInterfacesConfig_Filter(rName string) string {
data "aws_network_interfaces" "test" {
filter {
name = "subnet-id"
values = ["${aws_network_interface.test.subnet_id}", "${aws_network_interface.test1.subnet_id}"]
values = [aws_network_interface.test.subnet_id, aws_network_interface.test1.subnet_id]
}
}
`
Expand All @@ -90,7 +90,7 @@ func testAccDataSourceAwsNetworkInterfacesConfig_Tags(rName string) string {
return testAccDataSourceAwsNetworkInterfacesConfig_Base(rName) + `
data "aws_network_interfaces" "test" {
tags = {
Name = "${aws_network_interface.test1.tags.Name}"
Name = aws_network_interface.test1.tags.Name
}
}
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const testAccDataSourceAwsOrganizationsOrganizationalUnitsConfig = `
resource "aws_organizations_organization" "test" {}
resource "aws_organizations_organizational_unit" "test" {
name = "test"
parent_id = aws_organizations_organization.test.roots[0].id
name = "test"
parent_id = aws_organizations_organization.test.roots[0].id
}
data "aws_organizations_organizational_units" "test" {
parent_id = aws_organizations_organizational_unit.test.parent_id
parent_id = aws_organizations_organizational_unit.test.parent_id
}
`
2 changes: 1 addition & 1 deletion aws/data_source_aws_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ func testAccCheckAwsDnsSuffix(n string) resource.TestCheckFunc {
}

const testAccCheckAwsPartitionConfig_basic = `
data "aws_partition" "current" { }
data "aws_partition" "current" {}
`
2 changes: 1 addition & 1 deletion aws/data_source_aws_prefix_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ data "aws_prefix_list" "s3_by_id" {
}
data "aws_prefix_list" "s3_by_name" {
name = "com.amazonaws.us-west-2.s3"
name = "com.amazonaws.us-west-2.s3"
}
`

Expand Down
30 changes: 4 additions & 26 deletions aws/data_source_aws_pricing_product_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ func TestAccDataSourceAwsPricingProduct_redshift(t *testing.T) {
}

func testAccDataSourceAwsPricingProductConfigEc2(dataName string, instanceType string) string {
return fmt.Sprintf(`data "aws_pricing_product" "%s" {
return fmt.Sprintf(`
data "aws_pricing_product" "%s" {
service_code = "AmazonEC2"
filters {
Expand Down Expand Up @@ -91,7 +92,8 @@ func testAccDataSourceAwsPricingProductConfigEc2(dataName string, instanceType s
}

func testAccDataSourceAwsPricingProductConfigRedshift() string {
return `data "aws_pricing_product" "test" {
return `
data "aws_pricing_product" "test" {
service_code = "AmazonRedshift"
filters {
Expand All @@ -105,27 +107,3 @@ func testAccDataSourceAwsPricingProductConfigRedshift() string {
}
}
`
}

func testAccPricingCheckValueIsJSON(data string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[data]

if !ok {
return fmt.Errorf("Can't find resource: %s", data)
}

result := rs.Primary.Attributes["result"]
var objmap map[string]*json.RawMessage

if err := json.Unmarshal([]byte(result), &objmap); err != nil {
return fmt.Errorf("%s result value (%s) is not JSON: %s", data, result, err)
}

if len(objmap) == 0 {
return fmt.Errorf("%s result value (%s) unmarshalling resulted in an empty map", data, result)
}

return nil
}
}
10 changes: 5 additions & 5 deletions aws/data_source_aws_qldb_ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ func TestAccDataSourceAwsQLDBLedger_basic(t *testing.T) {
func testAccDataSourceAwsQLDBLedgerConfig(rName string) string {
return fmt.Sprintf(`
resource "aws_qldb_ledger" "tf_wrong1" {
name = "%[1]s1"
name = "%[1]s1"
deletion_protection = false
}
resource "aws_qldb_ledger" "tf_test" {
name = "%[1]s2"
name = "%[1]s2"
deletion_protection = false
}
resource "aws_qldb_ledger" "tf_wrong2" {
name = "%[1]s3"
deletion_protection = false
name = "%[1]s3"
deletion_protection = false
}
data "aws_qldb_ledger" "by_name" {
name = "${aws_qldb_ledger.tf_test.name}"
name = aws_qldb_ledger.tf_test.name
}
`, rName)
}
8 changes: 4 additions & 4 deletions aws/data_source_aws_ram_resource_share_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ resource "aws_ram_resource_share" "test" {
}
data "aws_ram_resource_share" "test" {
name = "${aws_ram_resource_share.test.name}"
name = aws_ram_resource_share.test.name
resource_owner = "SELF"
}
`, rName, rName)
Expand All @@ -83,7 +83,7 @@ resource "aws_ram_resource_share" "test" {
}
data "aws_ram_resource_share" "test" {
name = "${aws_ram_resource_share.test.name}"
name = aws_ram_resource_share.test.name
resource_owner = "SELF"
filter {
Expand All @@ -96,7 +96,7 @@ data "aws_ram_resource_share" "test" {

const testAccDataSourceAwsRamResourceShareConfig_NonExistent = `
data "aws_ram_resource_share" "test" {
name = "tf-acc-test-does-not-exist"
resource_owner = "SELF"
name = "tf-acc-test-does-not-exist"
resource_owner = "SELF"
}
`
10 changes: 5 additions & 5 deletions aws/data_source_aws_rds_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ resource "aws_rds_cluster" "test" {
cluster_identifier = "%s"
database_name = "mydb"
db_cluster_parameter_group_name = "default.aurora5.6"
db_subnet_group_name = "${aws_db_subnet_group.test.name}"
db_subnet_group_name = aws_db_subnet_group.test.name
master_password = "mustbeeightcharacters"
master_username = "foo"
skip_final_snapshot = true
Expand All @@ -61,7 +61,7 @@ resource "aws_vpc" "test" {
}
resource "aws_subnet" "a" {
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
cidr_block = "10.0.0.0/24"
availability_zone = "us-west-2a"
Expand All @@ -71,7 +71,7 @@ resource "aws_subnet" "a" {
}
resource "aws_subnet" "b" {
vpc_id = "${aws_vpc.test.id}"
vpc_id = aws_vpc.test.id
cidr_block = "10.0.1.0/24"
availability_zone = "us-west-2b"
Expand All @@ -82,11 +82,11 @@ resource "aws_subnet" "b" {
resource "aws_db_subnet_group" "test" {
name = "%s"
subnet_ids = ["${aws_subnet.a.id}", "${aws_subnet.b.id}"]
subnet_ids = [aws_subnet.a.id, aws_subnet.b.id]
}
data "aws_rds_cluster" "test" {
cluster_identifier = "${aws_rds_cluster.test.cluster_identifier}"
cluster_identifier = aws_rds_cluster.test.cluster_identifier
}
`, clusterName, clusterName)
}
Loading

0 comments on commit 00a8231

Please sign in to comment.