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

provider: First pass at removing non-inclusive terminology #13771

Merged
merged 3 commits into from
Jun 26, 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
35 changes: 27 additions & 8 deletions aws/data_source_aws_availability_zones.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ func dataSourceAwsAvailabilityZones() *schema.Resource {
Optional: true,
},
"blacklisted_names": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Type: schema.TypeSet,
Optional: true,
ConflictsWith: []string{"exclude_names"},
Deprecated: "use `exclude_names` instead",
Elem: &schema.Schema{Type: schema.TypeString},
},
"blacklisted_zone_ids": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Type: schema.TypeSet,
Optional: true,
ConflictsWith: []string{"exclude_zone_ids"},
Deprecated: "use `exclude_zone_ids` instead",
Elem: &schema.Schema{Type: schema.TypeString},
},
"filter": ec2CustomFiltersSchema(),
"group_names": {
Expand All @@ -42,6 +46,18 @@ 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 @@ -105,6 +121,9 @@ func dataSourceAwsAvailabilityZonesRead(d *schema.ResourceData, meta interface{}

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)

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

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

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

Expand Down
76 changes: 66 additions & 10 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"
blacklistedDataSourceName := "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(
testAccCheckAwsAvailabilityZonesBlacklisting(allDataSourceName, blacklistedDataSourceName),
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"
blacklistedDataSourceName := "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(
testAccCheckAwsAvailabilityZonesBlacklisting(allDataSourceName, blacklistedDataSourceName),
testAccCheckAwsAvailabilityZonesExcluded(allDataSourceName, excludeDataSourceName),
),
},
},
Expand All @@ -158,6 +158,42 @@ func TestAccAWSAvailabilityZones_Filter(t *testing.T) {
})
}

func TestAccAWSAvailabilityZones_ExcludeNames(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: testAccCheckAwsAvailabilityZonesConfigExcludeNames(),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAvailabilityZonesExcluded(allDataSourceName, excludeDataSourceName),
),
},
},
})
}

func TestAccAWSAvailabilityZones_ExcludeZoneIds(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: testAccCheckAwsAvailabilityZonesConfigExcludeZoneIds(),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsAvailabilityZonesExcluded(allDataSourceName, excludeDataSourceName),
),
},
},
})
}

func TestAccAWSAvailabilityZones_stateFilter(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -198,16 +234,16 @@ func testAccCheckAwsAvailabilityZonesMeta(n string) resource.TestCheckFunc {
}
}

func testAccCheckAwsAvailabilityZonesBlacklisting(allDataSourceName, blacklistedDataSourceName 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)
}

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

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

blacklistedValue, ok := blacklistedResourceState.Primary.Attributes[attribute]
excludeValue, ok := excludeResourceState.Primary.Attributes[attribute]

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

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

func testAccCheckAwsAvailabilityZonesConfigExcludeNames() string {
return fmt.Sprintf(`
data "aws_availability_zones" "all" {}

data "aws_availability_zones" "test" {
exclude_names = ["${data.aws_availability_zones.all.names[0]}"]
}
`)
}

func testAccCheckAwsAvailabilityZonesConfigExcludeZoneIds() string {
return fmt.Sprintf(`
data "aws_availability_zones" "all" {}

data "aws_availability_zones" "test" {
exclude_zone_ids = ["${data.aws_availability_zones.all.zone_ids[0]}"]
}
`)
}

const testAccCheckAwsAvailabilityZonesStateConfig = `
data "aws_availability_zones" "state_filter" {
state = "available"
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
blacklisted_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
blacklisted_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).
blacklisted_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
blacklisted_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.
blacklisted_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.
blacklisted_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
blacklisted_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
blacklisted_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
blacklisted_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
blacklisted_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
blacklisted_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
blacklisted_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
blacklisted_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.
blacklisted_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.
blacklisted_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
blacklisted_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
blacklisted_zone_ids = ["usw2-az4"]
state = "available"
exclude_zone_ids = ["usw2-az4"]
state = "available"

filter {
name = "opt-in-status"
Expand Down
Loading