terraform-provider-ibm icon indicating copy to clipboard operation
terraform-provider-ibm copied to clipboard

How to figure out a subnet_id(s) for a given zone

Open evtimokn opened this issue 1 year ago • 1 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • 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
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Question

I am trying to figure out how to fetch the subnet_id(s) for a given zone, let's say eu-de-1. I cannot find a suitable data source for this. Is it possible to use ibm_is_vpc instead?

New or Affected Resource(s) or Datasource(s)

ibm_is_vpc

  • ibm_1.58.0

evtimokn avatar Dec 11 '23 15:12 evtimokn

data ibm_is_subnets this {
	zone = "${var.region}-1"
}
output "subnet_ids" {
    value = [
    for sub in data.ibm_is_subnets.this.subnets : "${sub.id}"
  ]
}

this would result in

Outputs:

subnet_ids = [
  "subnet-id-1",
  "subnet-id-2",
]

subnets datasource has zone filter https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/is_subnets#zone

ujjwal-ibm avatar Dec 12 '23 14:12 ujjwal-ibm