Upgraded to terraform v0.12.2 and most of the things stopped working straight way. (my bad, I didn't check this page: https://www.terraform.io/upgrade-guides/0-12.html prior to upgrade)
Anyway, fixed most of the things but the variable interpolation of type map
still not working. in pre-v012.x, this would work perfectly:
security_groups.tf
// SecurityGroup: default access
resource "aws_security_group" "default" {
count = "${length(var.s_zones)}"
vpc_id = "${element(aws_vpc.vpcs.*.id, count.index)}"
name = "${var.vpc_names[count.index]}-default"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["${var.vpn_cidrs["lan"]}",
"${var.vpn_cidrs["ovp"]}"]
description = "SSH from vpn"
}
}
vars.tf
// Variable: vpn_cidrs
variable "vpn_cidrs" {
type = "map"
default = {
lan = ["10.0.11.0/28", "10.0.12.0/28"]
ovp = ["10.1.13.0/28", "10.1.14.0/28"]
}
}
With v0.12.2, it returns:
Error: Incorrect attribute value type
on ../../modules/vpc/security_groups.tf line 55, in resource "aws_security_group" "default": 55: cidr_blocks = ["${var.vpn_cidrs["lan"]}",
Inappropriate value for attribute "cidr_blocks": element 0: string required.
I tried using the new constructor:
// Variable: vpn_cidrs
variable "vpn_cidrs" {
type = map(string)
default = {
lan1 = "10.0.11.0/28",
lan2 = "10.0.12.0/28",
ovp1 = "10.1.13.0/28",
ovp2 = "10.1.14.0/28",
}
}
But then I cannot figure out how to use that for SG rules in the module. Anyone knows what am I missing or how to fix that? Really stuck since Friday evening. Any pointed, example-code would be highly appreciated.
-S
[]
either from the variable: vpn_cidrs or the ingress{} rule. Already tried that. Unless I'm terribly missing something here. – MacUsers