hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.82k stars 9.16k forks source link

Ignore/Fix and Enable awsproviderlint AWSAT003: Regions should not be hardcoded, use aws_region and aws_availability_zones data sources instead #12995

Closed breathingdust closed 3 years ago

breathingdust commented 4 years ago

Community Note

Description

To ensure test configurations are region and partition agnostic, any hardcoded AZ identifiers ([a-z]{2}(-[a-z]+)+-[1-9][0-9](-[a-z]+-[1-9][0-9])?[a-z]) should be replaced with the aws_availability_zones data source.

To ensure test configurations are region and partition agnostic, any hardcoded Region identifiers ([a-z]{2}(-[a-z]+)+-[1-9][0-9]*) should be replaced with the aws_region data source.

Flagged Code

In test configuration:

us-west-2
us-west-2a

Passing Code

In test configuration:

data "aws_region" "current" {}
data "aws_availability_zones" "available" {
  # ... configuration ...
}

Definition of Done

YakDriver commented 4 years ago

This was added as AWSAT003. This is the central management issue.

Phase 1 Fixes needed (ended with #14857):

bflad commented 4 years ago

Getting closer! Here's the current list of remaining files:

aws/config_test.go aws/data_source_aws_arn_test.go aws/data_source_aws_cloudtrail_service_account.go aws/data_source_aws_db_instance_test.go aws/data_source_aws_eip.go aws/data_source_aws_eip_test.go aws/data_source_aws_elastic_beanstalk_hosted_zone.go aws/data_source_aws_elastic_beanstalk_hosted_zone_test.go aws/data_source_aws_elb_hosted_zone_id.go aws/data_source_aws_elb_hosted_zone_id_test.go aws/data_source_aws_elb_service_account.go aws/data_source_aws_ip_ranges_test.go aws/data_source_aws_prefix_list_test.go aws/data_source_aws_pricing_product_test.go aws/data_source_aws_redshift_service_account.go aws/data_source_aws_region_test.go aws/data_source_aws_transfer_server_test.go aws/datasync_test.go aws/hosted_zones.go aws/hosted_zones_test.go aws/provider.go aws/provider_test.go aws/resource_aws_api_gateway_domain_name_test.go aws/resource_aws_budgets_budget_test.go aws/resource_aws_cloudfront_distribution_test.go aws/resource_aws_codebuild_project_test.go aws/resource_aws_cognito_user_group_test.go aws/resource_aws_cognito_user_pool_domain_test.go aws/resource_aws_config_aggregate_authorization.go aws/resource_aws_config_aggregate_authorization_test.go aws/resource_aws_datasync_location_smb_test.go aws/resource_aws_db_instance_test.go aws/resource_aws_db_security_group_test.go aws/resource_aws_default_security_group_test.go aws/resource_aws_default_vpc_dhcp_options.go aws/resource_aws_default_vpc_dhcp_options_test.go aws/resource_aws_devicefarm_project.go aws/resource_aws_dynamodb_global_table_test.go aws/resource_aws_ec2_availability_zone_group_test.go aws/resource_aws_ec2_client_vpn_authorization_rule_test.go aws/resource_aws_ec2_client_vpn_network_association_test.go aws/resource_aws_ec2_client_vpn_route_test.go aws/resource_aws_ec2_transit_gateway_route_test.go aws/resource_aws_ec2_transit_gateway_vpc_attachment_accepter_test.go aws/resource_aws_ec2_transit_gateway_vpc_attachment_test.go aws/resource_aws_efs_file_system_test.go aws/resource_aws_eip.go aws/resource_aws_eip_association_test.go aws/resource_aws_eip_test.go aws/resource_aws_eks_fargate_profile_test.go aws/resource_aws_elasticache_cluster_test.go aws/resource_aws_elasticache_security_group_test.go aws/resource_aws_fms_admin_account_test.go aws/resource_aws_gamelift_test.go aws/resource_aws_guardduty_filter_test.go aws/resource_aws_iam_access_key_test.go aws/resource_aws_instance_test.go aws/resource_aws_lambda_permission_test.go aws/resource_aws_lightsail_domain_test.go aws/resource_aws_opsworks_instance_test.go aws/resource_aws_opsworks_stack.go aws/resource_aws_organizations_policy_test.go aws/resource_aws_redshift_security_group_test.go aws/resource_aws_route53_health_check_test.go aws/resource_aws_route53_query_log_test.go aws/resource_aws_route53_record_test.go aws/resource_aws_s3_bucket.go aws/resource_aws_s3_bucket_test.go aws/resource_aws_sagemaker_endpoint_configuration_test.go aws/resource_aws_sagemaker_endpoint_test.go aws/resource_aws_sagemaker_model_test.go aws/resource_aws_security_group_rule_test.go aws/resource_aws_security_group_test.go aws/resource_aws_transfer_server_test.go aws/resource_aws_vpc_dhcp_options_test.go aws/resource_aws_vpn_gateway_test.go aws/resource_aws_waf_web_acl_test.go aws/resource_aws_workspaces_directory_test.go aws/structure_test.go aws/validators_test.go

YakDriver commented 3 years ago

Phase 2!! 💯

ghost commented 3 years ago

This has been released in version 3.25.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

ghost commented 3 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!