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

data-source/aws_availability_zones: Remove blacklisted_names and blacklisted_zone_ids arguments #14134

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 10 additions & 28 deletions aws/data_source_aws_availability_zones.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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,
Expand Down Expand Up @@ -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)

Expand All @@ -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
}

Expand Down
56 changes: 0 additions & 56 deletions aws/data_source_aws_availability_zones_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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" {
Expand Down
2 changes: 0 additions & 2 deletions website/docs/d/availability_zones.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down