Skip to content

Commit

Permalink
data-source/aws_availability_zones: Switch skip_* naming to exclude_*
Browse files Browse the repository at this point in the history
Output from acceptance testing:

```
--- PASS: TestAccAWSAvailabilityZones_AllAvailabilityZones (18.12s)
--- PASS: TestAccAWSAvailabilityZones_stateFilter (18.20s)
--- PASS: TestAccAWSAvailabilityZones_Filter (18.30s)
--- PASS: TestAccAWSAvailabilityZones_basic (18.32s)
--- PASS: TestAccAWSAvailabilityZones_ExcludeZoneIds (19.82s)
--- PASS: TestAccAWSAvailabilityZones_ExcludeNames (20.00s)
--- PASS: TestAccAWSAvailabilityZones_BlacklistedNames (20.04s)
--- PASS: TestAccAWSAvailabilityZones_BlacklistedZoneIds (20.14s)
```
  • Loading branch information
bflad committed Jun 23, 2020
1 parent a897caf commit d259af4
Show file tree
Hide file tree
Showing 25 changed files with 128 additions and 128 deletions.
20 changes: 10 additions & 10 deletions aws/data_source_aws_availability_zones.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ func dataSourceAwsAvailabilityZones() *schema.Resource {
"blacklisted_names": {
Type: schema.TypeSet,
Optional: true,
ConflictsWith: []string{"skip_names"},
Deprecated: "use `skip_names` instead",
ConflictsWith: []string{"exclude_names"},
Deprecated: "use `exclude_names` instead",
Elem: &schema.Schema{Type: schema.TypeString},
},
"blacklisted_zone_ids": {
Type: schema.TypeSet,
Optional: true,
ConflictsWith: []string{"skip_zone_ids"},
Deprecated: "use `skip_zone_ids` instead",
ConflictsWith: []string{"exclude_zone_ids"},
Deprecated: "use `exclude_zone_ids` instead",
Elem: &schema.Schema{Type: schema.TypeString},
},
"filter": ec2CustomFiltersSchema(),
Expand All @@ -46,13 +46,13 @@ func dataSourceAwsAvailabilityZones() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"skip_names": {
"exclude_names": {
Type: schema.TypeSet,
Optional: true,
ConflictsWith: []string{"blacklisted_names"},
Elem: &schema.Schema{Type: schema.TypeString},
},
"skip_zone_ids": {
"exclude_zone_ids": {
Type: schema.TypeSet,
Optional: true,
ConflictsWith: []string{"blacklisted_zone_ids"},
Expand Down Expand Up @@ -121,8 +121,8 @@ func dataSourceAwsAvailabilityZonesRead(d *schema.ResourceData, meta interface{}

blacklistedNames := d.Get("blacklisted_names").(*schema.Set)
blacklistedZoneIDs := d.Get("blacklisted_zone_ids").(*schema.Set)
skipNames := d.Get("skip_names").(*schema.Set)
skipZoneIDs := d.Get("skip_zone_ids").(*schema.Set)
excludeNames := d.Get("exclude_names").(*schema.Set)
excludeZoneIDs := d.Get("exclude_zone_ids").(*schema.Set)

groupNames := schema.NewSet(schema.HashString, nil)
names := []string{}
Expand All @@ -132,11 +132,11 @@ func dataSourceAwsAvailabilityZonesRead(d *schema.ResourceData, meta interface{}
name := aws.StringValue(v.ZoneName)
zoneID := aws.StringValue(v.ZoneId)

if blacklistedNames.Contains(name) || skipNames.Contains(name) {
if blacklistedNames.Contains(name) || excludeNames.Contains(name) {
continue
}

if blacklistedZoneIDs.Contains(zoneID) || skipZoneIDs.Contains(zoneID) {
if blacklistedZoneIDs.Contains(zoneID) || excludeZoneIDs.Contains(zoneID) {
continue
}

Expand Down
44 changes: 22 additions & 22 deletions aws/data_source_aws_availability_zones_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestAccAWSAvailabilityZones_AllAvailabilityZones(t *testing.T) {

func TestAccAWSAvailabilityZones_BlacklistedNames(t *testing.T) {
allDataSourceName := "data.aws_availability_zones.all"
skippedDataSourceName := "data.aws_availability_zones.test"
excludeDataSourceName := "data.aws_availability_zones.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -116,7 +116,7 @@ func TestAccAWSAvailabilityZones_BlacklistedNames(t *testing.T) {
{
Config: testAccCheckAwsAvailabilityZonesConfigBlacklistedNames(),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAvailabilityZonesSkipping(allDataSourceName, skippedDataSourceName),
testAccCheckAwsAvailabilityZonesExcluded(allDataSourceName, excludeDataSourceName),
),
},
},
Expand All @@ -125,7 +125,7 @@ func TestAccAWSAvailabilityZones_BlacklistedNames(t *testing.T) {

func TestAccAWSAvailabilityZones_BlacklistedZoneIds(t *testing.T) {
allDataSourceName := "data.aws_availability_zones.all"
skippedDataSourceName := "data.aws_availability_zones.test"
excludeDataSourceName := "data.aws_availability_zones.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -134,7 +134,7 @@ func TestAccAWSAvailabilityZones_BlacklistedZoneIds(t *testing.T) {
{
Config: testAccCheckAwsAvailabilityZonesConfigBlacklistedZoneIds(),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAvailabilityZonesSkipping(allDataSourceName, skippedDataSourceName),
testAccCheckAwsAvailabilityZonesExcluded(allDataSourceName, excludeDataSourceName),
),
},
},
Expand All @@ -158,36 +158,36 @@ func TestAccAWSAvailabilityZones_Filter(t *testing.T) {
})
}

func TestAccAWSAvailabilityZones_SkipNames(t *testing.T) {
func TestAccAWSAvailabilityZones_ExcludeNames(t *testing.T) {
allDataSourceName := "data.aws_availability_zones.all"
skippedDataSourceName := "data.aws_availability_zones.test"
excludeDataSourceName := "data.aws_availability_zones.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckAwsAvailabilityZonesConfigSkipNames(),
Config: testAccCheckAwsAvailabilityZonesConfigExcludeNames(),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAvailabilityZonesSkipping(allDataSourceName, skippedDataSourceName),
testAccCheckAwsAvailabilityZonesExcluded(allDataSourceName, excludeDataSourceName),
),
},
},
})
}

func TestAccAWSAvailabilityZones_SkipZoneIds(t *testing.T) {
func TestAccAWSAvailabilityZones_ExcludeZoneIds(t *testing.T) {
allDataSourceName := "data.aws_availability_zones.all"
skippedDataSourceName := "data.aws_availability_zones.test"
excludeDataSourceName := "data.aws_availability_zones.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckAwsAvailabilityZonesConfigSkipZoneIds(),
Config: testAccCheckAwsAvailabilityZonesConfigExcludeZoneIds(),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAvailabilityZonesSkipping(allDataSourceName, skippedDataSourceName),
testAccCheckAwsAvailabilityZonesExcluded(allDataSourceName, excludeDataSourceName),
),
},
},
Expand Down Expand Up @@ -234,16 +234,16 @@ func testAccCheckAwsAvailabilityZonesMeta(n string) resource.TestCheckFunc {
}
}

func testAccCheckAwsAvailabilityZonesSkipping(allDataSourceName, skippingDataSourceName string) resource.TestCheckFunc {
func testAccCheckAwsAvailabilityZonesExcluded(allDataSourceName, excludeDataSourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
allResourceState, ok := s.RootModule().Resources[allDataSourceName]
if !ok {
return fmt.Errorf("Resource does not exist: %s", allDataSourceName)
}

skippingResourceState, ok := s.RootModule().Resources[skippingDataSourceName]
excludeResourceState, ok := s.RootModule().Resources[excludeDataSourceName]
if !ok {
return fmt.Errorf("Resource does not exist: %s", skippingDataSourceName)
return fmt.Errorf("Resource does not exist: %s", excludeDataSourceName)
}

for _, attribute := range []string{"names.#", "zone_ids.#"} {
Expand All @@ -253,13 +253,13 @@ func testAccCheckAwsAvailabilityZonesSkipping(allDataSourceName, skippingDataSou
return fmt.Errorf("cannot find %s in %s resource state attributes: %+v", attribute, allDataSourceName, allResourceState.Primary.Attributes)
}

skippingValue, ok := skippingResourceState.Primary.Attributes[attribute]
excludeValue, ok := excludeResourceState.Primary.Attributes[attribute]

if !ok {
return fmt.Errorf("cannot find %s in %s resource state attributes: %+v", attribute, skippingDataSourceName, skippingResourceState.Primary.Attributes)
return fmt.Errorf("cannot find %s in %s resource state attributes: %+v", attribute, excludeDataSourceName, excludeResourceState.Primary.Attributes)
}

if allValue == skippingValue {
if allValue == excludeValue {
return fmt.Errorf("expected %s attribute value difference, got: %s", attribute, allValue)
}
}
Expand Down Expand Up @@ -374,22 +374,22 @@ data "aws_availability_zones" "test" {
`)
}

func testAccCheckAwsAvailabilityZonesConfigSkipNames() string {
func testAccCheckAwsAvailabilityZonesConfigExcludeNames() string {
return fmt.Sprintf(`
data "aws_availability_zones" "all" {}
data "aws_availability_zones" "test" {
skip_names = ["${data.aws_availability_zones.all.names[0]}"]
exclude_names = ["${data.aws_availability_zones.all.names[0]}"]
}
`)
}

func testAccCheckAwsAvailabilityZonesConfigSkipZoneIds() string {
func testAccCheckAwsAvailabilityZonesConfigExcludeZoneIds() string {
return fmt.Sprintf(`
data "aws_availability_zones" "all" {}
data "aws_availability_zones" "test" {
skip_zone_ids = ["${data.aws_availability_zones.all.zone_ids[0]}"]
exclude_zone_ids = ["${data.aws_availability_zones.all.zone_ids[0]}"]
}
`)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func testAccAWSEc2TransitGatewayVpcAttachmentDataSourceConfigFilter() string {
return fmt.Sprintf(`
data "aws_availability_zones" "available" {
# IncorrectState: Transit Gateway is not available in availability zone us-west-2d
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down Expand Up @@ -109,8 +109,8 @@ func testAccAWSEc2TransitGatewayVpcAttachmentDataSourceConfigID() string {
return fmt.Sprintf(`
data "aws_availability_zones" "available" {
# IncorrectState: Transit Gateway is not available in availability zone us-west-2d
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_eip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ data "aws_eip" "test" {
const testAccDataSourceAwsEipConfigInstance = `
data "aws_availability_zones" "available" {
# Error launching source instance: Unsupported: Your requested instance type (t2.micro) is not supported in your requested Availability Zone (us-west-2d).
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ func testAccAWSRouteDataSourceConfigTransitGatewayID() string {
return fmt.Sprintf(`
data "aws_availability_zones" "available" {
# IncorrectState: Transit Gateway is not available in availability zone us-west-2d
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_appautoscaling_scheduled_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ func testAccAppautoscalingScheduledActionConfig_EMR(rName, ts string) string {
return fmt.Sprintf(`
data "aws_availability_zones" "available" {
# The requested instance type c4.large is not supported in the requested availability zone.
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_appautoscaling_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ func testAccAWSAppautoscalingTargetEmrClusterConfig(rInt int) string {
return fmt.Sprintf(`
data "aws_availability_zones" "available" {
# The requested instance type m3.xlarge is not supported in the requested availability zone.
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down
24 changes: 12 additions & 12 deletions aws/resource_aws_autoscaling_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,8 @@ data "aws_ami" "test" {
data "aws_availability_zones" "available" {
# t2.micro is not supported in us-west-2d
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down Expand Up @@ -2422,8 +2422,8 @@ resource "aws_internet_gateway" "gw" {
data "aws_availability_zones" "available" {
# t2.micro is not supported in us-west-2d
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down Expand Up @@ -2527,8 +2527,8 @@ resource "aws_internet_gateway" "gw" {
data "aws_availability_zones" "available" {
# t2.micro is not supported in us-west-2d
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down Expand Up @@ -3495,8 +3495,8 @@ resource "aws_vpc" "test" {
data "aws_availability_zones" "available" {
# t2.micro is not supported in us-west-2d
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down Expand Up @@ -3782,8 +3782,8 @@ data "aws_ami" "test" {
data "aws_availability_zones" "available" {
# t2.micro is not supported in us-west-2d
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down Expand Up @@ -4206,8 +4206,8 @@ func testAccAWSAutoScalingGroupPartitionConfig(rName string) string {
return fmt.Sprintf(`
data "aws_availability_zones" "available" {
# t2.micro is not supported in us-west-2d
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_cloud9_environment_ec2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ func testAccAWSCloud9EnvironmentEc2ConfigBase() string {
return fmt.Sprintf(`
data "aws_availability_zones" "available" {
# t2.micro instance type is not available in these Availability Zones
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down
8 changes: 4 additions & 4 deletions aws/resource_aws_codebuild_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3385,8 +3385,8 @@ func testAccAWSCodeBuildProjectConfig_VpcConfig1(rName string) string {
return testAccAWSCodeBuildProjectConfig_Base_ServiceRole(rName) + fmt.Sprintf(`
data "aws_availability_zones" "available" {
# InvalidInputException: CodeBuild currently doesn't support VPC in us-west-2d, please select subnets in other availability zones.
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down Expand Up @@ -3446,8 +3446,8 @@ func testAccAWSCodeBuildProjectConfig_VpcConfig2(rName string) string {
return testAccAWSCodeBuildProjectConfig_Base_ServiceRole(rName) + fmt.Sprintf(`
data "aws_availability_zones" "available" {
# InvalidInputException: CodeBuild currently doesn't support VPC in us-west-2d, please select subnets in other availability zones.
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_ec2_client_vpn_network_association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ func testAccEc2ClientVpnNetworkAssociationConfig(rName string) string {
return testAccEc2ClientVpnNetworkAssociationConfigAcmCertificateBase() + fmt.Sprintf(`
data "aws_availability_zones" "available" {
# InvalidParameterValue: AZ us-west-2d is not currently supported. Please choose another az in this region
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_ec2_transit_gateway_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ func testAccAWSEc2TransitGatewayRouteConfigDestinationCidrBlock() string {
return fmt.Sprintf(`
data "aws_availability_zones" "available" {
# IncorrectState: Transit Gateway is not available in availability zone us-west-2d
skip_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"
filter {
name = "opt-in-status"
Expand Down
Loading

0 comments on commit d259af4

Please sign in to comment.