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

Networking: expose subnets in network data source #1152

Merged

Conversation

kayrus
Copy link
Collaborator

@kayrus kayrus commented Jan 29, 2021

Can be used to solve the #1150 issue. Less efficient way to list and filter external network subnets:

variable "pattern" {}
  
data "openstack_networking_network_v2" "network" {
  name = "external-network"
}

data "openstack_networking_subnet_v2" "subnet" {
  count     = length(data.openstack_networking_network_v2.network.subnets)
  subnet_id = data.openstack_networking_network_v2.network.subnets[count.index]
}

output "subnet_ids" {
  value = [for x in data.openstack_networking_subnet_v2.subnet : x.id if length(regexall(var.pattern, x.name)) > 0]
}

output "subnet_names" {
  value = [for x in data.openstack_networking_subnet_v2.subnet : x.name if length(regexall(var.pattern, x.name)) > 0]
}

@theopenlab-ci
Copy link

theopenlab-ci bot commented Jan 29, 2021

Build succeeded.

Copy link
Member

@ozerovandrei ozerovandrei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ozerovandrei ozerovandrei merged commit 2d76c4b into terraform-provider-openstack:main Jan 31, 2021
@kayrus kayrus deleted the network-subnets branch January 31, 2021 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants