Any idea why I am getting this error? error creating EC2 Subnet: InvalidParameterValue: Value ({var.region}c) for parameter availabilityZoneId is invalid. Subnets can currently only be created in the following availability zones: usw2-az1, usw2-az2, usw2-az3, usw2-az4.
It used to work before when I specify Availability zones in Terraform code as, azs = ["{var.region}a","{var.region}b","{var.region}c"]
The full module is:
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 3.0"
name = var.vpc_name
cidr = var.vpc_cidr
azs = ["{var.region}a","{var.region}b","{var.region}c"]
private_subnets = var.private_subnets_cidr
public_subnets = var.public_subnets_cidr
create_egress_only_igw = true
enable_nat_gateway = true
single_nat_gateway = true
enable_dns_hostnames = true
enable_flow_log = true
create_flow_log_cloudwatch_iam_role = true
create_flow_log_cloudwatch_log_group = true
tags = local.tags
}
But now the code is failing with the above error.
CodePudding user response:
You have incorrect string interpolation in your azs
attribute. $
is missing.
Please update your code to
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
[....]
azs = ["${var.region}a","${var.region}b","${var.region}c"]
[....]
CodePudding user response:
azs = ["${var.region}a","${var.region}b","${var.region}c"]