terraform-aws-modules / terraform-aws-ec2-instance

Terraform module to create AWS EC2 instance(s) resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/ec2-instance/aws
Apache License 2.0
754 stars 1.87k forks source link

Add availability_zone output #341

Closed lance505 closed 1 year ago

lance505 commented 1 year ago

Is your request related to a new offering from AWS?

No

Is your request related to a problem? Please describe.

The creation of an aws_ebs_volume resource linked to an EC2 requires the instance's availability zone. To this end, the user can set the module's availability_zone input and reuse its value when creating the volume.

However, there are limitations on the number of instances that can be launched in each availability zone. It would be convenient to be able to have the availability zone be randomly assigned by the provider when creating an instance, rather than having to declare it manually.

Describe the solution you'd like.

Add an output block for the availability_zone attribute of the created aws_instance resource.

Describe alternatives you've considered.

Create a map of the different availability zones for the desired region and add a random_shuffle resource block to randomly assign an AZ to each instance.

Additional context

The alternative would be unnecessarily bulky and unreliable, when a simple output block could solve the problem.

This issue is a throwback to #264, and the desired change is exactly that being made by PR #265 from over a year ago, that has been marked as stale and closed without any discussion. If possible, I would appreciate if this PR could be reopened and merged.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

lance505 commented 1 year ago

Comment to keep the issue open

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] commented 1 year ago

This issue was automatically closed because of stale in 10 days

antonbabenko commented 1 year ago

This issue has been resolved in version 5.4.0 :tada:

github-actions[bot] commented 1 year 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.