Currently when creating a new S3 bucket or EC2 target group, if the name you chose already exists either in the world or in your current region, the plan will succeed and Terraform will want to create the resource, but in reality the Apply run will fail due to failed API calls to AWS due to "Name already exists" error
When creating S3 buckets or any other resource where the name cannot be reused, such as load balancers or target groups, it would be good if the Terraform Plan would fail if said name already exists. That way we could catch issues like this during the Plan and not during Apply.
I know AWS CLI has the call bucket-exists so maybe something similar could be implemented here
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
Volunteering to Work on This Issue
If you are interested in working on this issue, please leave a comment.
If this would be your first contribution, please review the contribution guide.
Description
Currently when creating a new S3 bucket or EC2 target group, if the name you chose already exists either in the world or in your current region, the plan will succeed and Terraform will want to create the resource, but in reality the Apply run will fail due to failed API calls to AWS due to "Name already exists" error
When creating S3 buckets or any other resource where the name cannot be reused, such as load balancers or target groups, it would be good if the Terraform Plan would fail if said name already exists. That way we could catch issues like this during the Plan and not during Apply.
I know AWS CLI has the call
bucket-exists
so maybe something similar could be implemented hereAffected Resource(s) and/or Data Source(s)
aws_s3_bucket
Potential Terraform Configuration
References
https://github.com/hashicorp/terraform-provider-aws/issues/2187
Would you like to implement a fix?
None