Closed muresan closed 2 years ago
@muresan Thanks for opening the issue. Have you seen cloudamqp_account_vpcs
? It was added to address this use-case: https://github.com/cloudamqp/terraform-provider-cloudamqp/blob/v1.18.0/docs/data-sources/account_vpcs.md
@muresan Thanks for opening the issue. Have you seen
cloudamqp_account_vpcs
? It was added to address this use-case: https://github.com/cloudamqp/terraform-provider-cloudamqp/blob/v1.18.0/docs/data-sources/account_vpcs.md
This indeed exposes the vpc_id and vpc_name and can be used to lookup the vpc_id by knowing the vpc_name, but you have to admit that it's more elegant to just use the vpc_info data sources.
The example is a bit misleading vpc_name
refers (in my case) to the CloudAMQP internal vpc name (which in most cases you don't know beforehand and try to find out) and what you know is the name
attribute.
data "cloudamqp_account_vpcs" "vpc_list" {
id = "noId"
vpcs = [
{
id = 192936
name = "bfc-poc-rmq-vpc-peering"
region = "google-compute-engine::us-east4"
subnet = "10.128.0.0/24"
tags = []
vpc_name = "vpc-zuxvih0r"
},
]
}
resource "cloudamqp_vpc" "this" {
id = "192936"
name = "bfc-poc-rmq-vpc-peering"
region = "google-compute-engine::us-east4"
subnet = "10.128.0.0/24"
tags = []
vpc_name = "vpc-zuxvih0r"
}
So IMO the example should be:
locals {
vpc_name = "bfc-poc-rmq-vpc-peering"
vpc_id = [for vpc in data.cloudamqp_account_vpcs.vpc_list.vpcs : vpc.id if vpc.name == local.vpc_name][0]
}
or similar.
Thank you for the info anyway, helped me simplify a Terraform module by allowing it to autodetect the vpc_id based on vpc name.
You're right, the docs could be more clear. I've made https://github.com/cloudamqp/terraform-provider-cloudamqp/pull/160, feel free to give it a review.
LGTM
Thanks, can we close this issue? Even if there's a more elegant solution to be had, I think it is unlikely we can prioritise that over other things needing to be done.
Sure.
Allow data source
cloudamqp_vpc_gcp_info
andcloudamqp_vpc_info
to lookup thevpc_id
using the VPCname
.Currenlty if the VPC is created in an infrastructure deploy pipeline there is no way to discover the
vpc_id
from another pipeline that has access to the same credentials as the ones used to deploy the VPC, thevpc_id
needs to be passed in one way or another.Use case:
cloudamqp_vpc
,cloudamqp_vpc_gcp_peering
,google_compute_network_peering
(in the same project or in a shared vpc project) this happens only once for multiple clusters.vpc_id
is not discoverable based on the VPC name which makes this workflow cumbersome, the vpc_id needs to be shared between deploy pipelines.