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

Get AvailableIpAddressCount from aws_subnet Data Source #11493

Closed
ghost opened this issue Jan 6, 2020 · 3 comments
Closed

Get AvailableIpAddressCount from aws_subnet Data Source #11493

ghost opened this issue Jan 6, 2020 · 3 comments
Labels
service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@ghost
Copy link

ghost commented Jan 6, 2020

This issue was originally opened by @MMarulla as hashicorp/terraform#23781. It was migrated here as a result of the provider split. The original body of the issue is below.


Current Terraform Version

Terraform v0.12.6
+ provider.aws v2.33.0

Use-cases

Assign new instances to the least subscribed subnet in a VPC.

Proposal

The aws_subnet data source relies on the underlying EC2 describe-subnets API. One of the values returned by that call is the number of available IP addresses in the subnet:

AvailableIpAddressCount -> (integer)
The number of unused private IPv4 addresses in the subnet. The IPv4 addresses for any stopped instances are considered unavailable.

If that field were included in the result attributes of aws_subnet data source, a decision could be made in code as to which subnet to place a new instance.

Note that available-ip-address-count can be passed as a filter value in the aws_subnet data source, but that does not help in finding the least subscribed subnet without repeated trail-and-error calls.

References

https://www.terraform.io/docs/providers/aws/d/subnet.html
https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-subnets.html

@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 6, 2020
@DrFaust92 DrFaust92 added the service/ec2 Issues and PRs that pertain to the ec2 service. label May 21, 2020
@tmarlok88
Copy link
Contributor

#13554

@justinretzolk
Copy link
Member

Closed by #13554

@github-actions github-actions bot removed the needs-triage Waiting for first response or review from a maintainer. label Nov 18, 2021
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

3 participants