简体   繁体   中英

How to get local_ipv4_network_cidr from aws_vpn_connection resource

I've created a site-2-site vpn in terraform:

resource "aws_vpn_connection" "example" {
  customer_gateway_id = # <cgw id>
  transit_gateway_id  = # <tgw id>

  outside_ip_address_type = "PublicIpv4"
  type                    = "ipsec.1"

  local_ipv4_network_cidr  = "192.168.0.0/18"
  remote_ipv4_network_cidr = "10.0.1.0/24"

  static_routes_only = false

}

Now I want to add a static route in TGW route table:

resource "aws_ec2_transit_gateway_route" "example_route" {
  transit_gateway_route_table_id = # <route table ID>

  destination_cidr_block        = "192.168.0.0/18" # how to replace THIS part with a reference to previous resource??
  transit_gateway_attachment_id = # <attachment ID>
}

I tried to use tolist(aws_vpn_connection.example.routes)[0].destination_cidr_block (as per terraform docs), but apparently it's empty

okay, so apparently that was my misreading of terraform docs - it's not only attributes exported but also arguments . so, as Marko stated, I could use

aws_vpn_connection.example.local_ipv4_network_cidr

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM