AWS availability zones error in naming error

0 votes

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.

Jan 14, 2023 in AWS by Tejashwini
• 3,820 points

edited 5 days ago 6 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP