HiveBrain v1.2.0
Get Started
← Back to all entries
debugterraformMinor

Terraform AWS AZ error - manually specify AZ?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
errormanuallyawsspecifyterraform

Problem

I'm fairly new to terraform and when creating AWS infrastructure I use the following to fetch the 'available' availability zones for my region (us-east-1) where I'm trying to create an EKS cluster.

data "aws_availability_zones" "available" {}


However when I run a 'terraform apply', it generates the following error because us-east-1a is at capacity.

aws_eks_cluster.demo: error creating EKS Cluster (test-cluster): 
UnsupportedAvailabilityZoneException: Cannot create cluster 'test-cluster' because us-east-1a, the targeted availability zone, does not 
currently have sufficient capacity to support the cluster. Retry and 
choose from these availability zones: us-east-1b, us-east-1c, us-east-1d


Is there any way I can get terraform to handle this automatically or specify that I only want to use 1b,1c,1d etc.

EDIT:

I've realised this is tied with where I create my subnets, which I do using this line:

availability_zone = "${data.aws_availability_zones.available.names[count.index]}"


So I assume I somehow need to skip us-east-1a by doing something here?

Thanks in advance.

Solution

If anyone else has this issue, here's how I got around it.

Specify a variable with the availability zones you want to target

variable "zones" {
  default = ["us-east-1b", "us-east-1c", "us-east-1d"]
}


When creating your subnets, use this line

availability_zone = "${var.zones[count.index]}"

Code Snippets

variable "zones" {
  default = ["us-east-1b", "us-east-1c", "us-east-1d"]
}
availability_zone = "${var.zones[count.index]}"

Context

StackExchange DevOps Q#4322, answer score: 1

Revisions (0)

No revisions yet.