From d49f5d3f37225f7cc8524cce05bc65e6069967d1 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Thu, 9 Jul 2020 22:04:02 -0400 Subject: [PATCH] data-source/aws_availability_zones: Remove blacklisted_names and blacklisted_zone_ids arguments Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/13766 Output from acceptance testing: ``` --- PASS: TestAccAWSAvailabilityZones_basic (15.27s) --- PASS: TestAccAWSAvailabilityZones_stateFilter (15.46s) --- PASS: TestAccAWSAvailabilityZones_AllAvailabilityZones (15.58s) --- PASS: TestAccAWSAvailabilityZones_Filter (15.70s) --- PASS: TestAccAWSAvailabilityZones_ExcludeNames (17.01s) --- PASS: TestAccAWSAvailabilityZones_ExcludeZoneIds (17.17s) ``` --- aws/data_source_aws_availability_zones.go | 38 ++++--------- ...data_source_aws_availability_zones_test.go | 56 ------------------- .../docs/d/availability_zones.html.markdown | 2 - 3 files changed, 10 insertions(+), 86 deletions(-) diff --git a/aws/data_source_aws_availability_zones.go b/aws/data_source_aws_availability_zones.go index 6457609af56..6de4daaba6a 100644 --- a/aws/data_source_aws_availability_zones.go +++ b/aws/data_source_aws_availability_zones.go @@ -21,19 +21,15 @@ func dataSourceAwsAvailabilityZones() *schema.Resource { Type: schema.TypeBool, Optional: true, }, - "blacklisted_names": { - Type: schema.TypeSet, - Optional: true, - ConflictsWith: []string{"exclude_names"}, - Deprecated: "use `exclude_names` instead", - Elem: &schema.Schema{Type: schema.TypeString}, + "exclude_names": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, }, - "blacklisted_zone_ids": { - Type: schema.TypeSet, - Optional: true, - ConflictsWith: []string{"exclude_zone_ids"}, - Deprecated: "use `exclude_zone_ids` instead", - Elem: &schema.Schema{Type: schema.TypeString}, + "exclude_zone_ids": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, }, "filter": ec2CustomFiltersSchema(), "group_names": { @@ -46,18 +42,6 @@ func dataSourceAwsAvailabilityZones() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "exclude_names": { - Type: schema.TypeSet, - Optional: true, - ConflictsWith: []string{"blacklisted_names"}, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "exclude_zone_ids": { - Type: schema.TypeSet, - Optional: true, - ConflictsWith: []string{"blacklisted_zone_ids"}, - Elem: &schema.Schema{Type: schema.TypeString}, - }, "state": { Type: schema.TypeString, Optional: true, @@ -119,8 +103,6 @@ func dataSourceAwsAvailabilityZonesRead(d *schema.ResourceData, meta interface{} return aws.StringValue(resp.AvailabilityZones[i].ZoneName) < aws.StringValue(resp.AvailabilityZones[j].ZoneName) }) - blacklistedNames := d.Get("blacklisted_names").(*schema.Set) - blacklistedZoneIDs := d.Get("blacklisted_zone_ids").(*schema.Set) excludeNames := d.Get("exclude_names").(*schema.Set) excludeZoneIDs := d.Get("exclude_zone_ids").(*schema.Set) @@ -132,11 +114,11 @@ func dataSourceAwsAvailabilityZonesRead(d *schema.ResourceData, meta interface{} name := aws.StringValue(v.ZoneName) zoneID := aws.StringValue(v.ZoneId) - if blacklistedNames.Contains(name) || excludeNames.Contains(name) { + if excludeNames.Contains(name) { continue } - if blacklistedZoneIDs.Contains(zoneID) || excludeZoneIDs.Contains(zoneID) { + if excludeZoneIDs.Contains(zoneID) { continue } diff --git a/aws/data_source_aws_availability_zones_test.go b/aws/data_source_aws_availability_zones_test.go index 4ffa5d752f3..9e46edc3cdb 100644 --- a/aws/data_source_aws_availability_zones_test.go +++ b/aws/data_source_aws_availability_zones_test.go @@ -105,42 +105,6 @@ func TestAccAWSAvailabilityZones_AllAvailabilityZones(t *testing.T) { }) } -func TestAccAWSAvailabilityZones_BlacklistedNames(t *testing.T) { - allDataSourceName := "data.aws_availability_zones.all" - excludeDataSourceName := "data.aws_availability_zones.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckAwsAvailabilityZonesConfigBlacklistedNames(), - Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAvailabilityZonesExcluded(allDataSourceName, excludeDataSourceName), - ), - }, - }, - }) -} - -func TestAccAWSAvailabilityZones_BlacklistedZoneIds(t *testing.T) { - allDataSourceName := "data.aws_availability_zones.all" - excludeDataSourceName := "data.aws_availability_zones.test" - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckAwsAvailabilityZonesConfigBlacklistedZoneIds(), - Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAvailabilityZonesExcluded(allDataSourceName, excludeDataSourceName), - ), - }, - }, - }) -} - func TestAccAWSAvailabilityZones_Filter(t *testing.T) { dataSourceName := "data.aws_availability_zones.test" @@ -343,26 +307,6 @@ data "aws_availability_zones" "test" { `) } -func testAccCheckAwsAvailabilityZonesConfigBlacklistedNames() string { - return fmt.Sprintf(` -data "aws_availability_zones" "all" {} - -data "aws_availability_zones" "test" { - blacklisted_names = ["${data.aws_availability_zones.all.names[0]}"] -} -`) -} - -func testAccCheckAwsAvailabilityZonesConfigBlacklistedZoneIds() string { - return fmt.Sprintf(` -data "aws_availability_zones" "all" {} - -data "aws_availability_zones" "test" { - blacklisted_zone_ids = ["${data.aws_availability_zones.all.zone_ids[0]}"] -} -`) -} - func testAccCheckAwsAvailabilityZonesConfigFilter() string { return fmt.Sprintf(` data "aws_availability_zones" "test" { diff --git a/website/docs/d/availability_zones.html.markdown b/website/docs/d/availability_zones.html.markdown index 6d322a47d9d..0d8552f277c 100644 --- a/website/docs/d/availability_zones.html.markdown +++ b/website/docs/d/availability_zones.html.markdown @@ -73,8 +73,6 @@ data "aws_availability_zones" "example" { The following arguments are supported: * `all_availability_zones` - (Optional) Set to `true` to include all Availability Zones and Local Zones regardless of your opt in status. -* `blacklisted_names` - (Optional, **DEPRECATED**) List of Availability Zone names to exclude. Use `exclude_names` instead. -* `blacklisted_zone_ids` - (Optional, **DEPRECATED**) List of Availability Zone IDs to exclude. Use `exclude_zone_ids` instead. * `filter` - (Optional) Configuration block(s) for filtering. Detailed below. * `exclude_names` - (Optional) List of Availability Zone names to exclude. * `exclude_zone_ids` - (Optional) List of Availability Zone IDs to exclude.