Last active
May 12, 2019 16:17
-
-
Save J00MZ/74ea90621e380376bc4cda8112d1fb12 to your computer and use it in GitHub Desktop.
Resolve terraform list items by key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_vpc" "vpc" { | |
cidr_block = "10.0.0.0/16" | |
} | |
resource "aws_vpn_gateway" "vpn_gateway" { | |
vpc_id = "${aws_vpc.vpc.id}" | |
} | |
resource "aws_customer_gateway" "customer_gateway" { | |
count = "${length(var.vpn_resources)}" | |
bgp_asn = 65000 | |
type = "ipsec.1" | |
ip_address = "${lookup(var.vpn_resources[count.index], "ip")}" | |
tags = { | |
Name = "${lookup(var.vpn_resources[count.index], "name")}" | |
} | |
} | |
resource "aws_vpn_connection" "main" { | |
count = "${length(var.vpn_resources)}" | |
vpn_gateway_id = "${aws_vpn_gateway.vpn_gateway.id}" | |
customer_gateway_id = "${aws_customer_gateway.customer_gateway.*.id}" | |
type = "ipsec.1" | |
static_routes_only = true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "vpn_resources" { | |
type = "list" | |
default = [ | |
{ | |
name = "VPN1_NAME" | |
ip = "VPN1_IP" | |
}, | |
{ | |
name = "VPN2_NAME" | |
ip = "VPN2_IP" | |
}, | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment