-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
Would be good to sort data_aws_subnet_ids by availability zone #3471
Comments
Would it make sense to add a new field that allows you to filter the subnets by zone? This would also mean that you would have to create separate data resources for each zone though. Something like this? https://github.com/kl4w/terraform-provider-aws/tree/filter-subnets-by-az |
I think the sort is more critical, IMHO. Getting this list order to be stable actually makes it useful downstream. Right now you wind up building subnet lists over and over again in anything remotely complicated to ensure that generated plans are consistent. |
Here is a quick and dirty workaround that I was able to use
|
Slight simplification: based on the idea that
|
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
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! |
We are in the process of rebuilding our accounts in AWS and one of the key components is building private and public subnets. As such the private subnets connect out to 0.0.0.0/0 via the a nat gateway. I have something similar to:
data "aws_subnet_ids" "selected_be" {
vpc_id = "${module.mainvpc.vpc_id}"
tags {
Location = "be"
}
}
Which will return three subnets tagged as "backend" - however it appears that these are return sorted by the subnet id. What I'd like to be able to do is get consistency that ${data.aws_subnet_ids.selected_be.ids[0] always returns the same az regardless of the subnetid ordering. So something like:
data "aws_subnet_ids" "selected_be" {
vpc_id = "${module.mainvpc.vpc_id}"
tags {
Location = "be"
}
sort_by = "AZ"
}
where sort_by is optional and will default to the existing behaviour.
The text was updated successfully, but these errors were encountered: