You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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
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:
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
The text was updated successfully, but these errors were encountered: