Answers: <p>If anyone else has this issue, here's how I got around it.</p>
  
  <p>Specify a variable with the availability zones you want to target</p>
  
  <pre><code>variable "zones" {
    default = ["us-east-1b", "us-east-1c", "us-east-1d"]
  }
  </code></pre>
  
  <p>When creating your subnets, use this line</p>
  
  <pre><code>availability_zone = "${var.zones[count.index]}"
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2018-06-18T10:17:22.263Z
Answers: 2018-06-18T10:17:22.263Z
Answers: Caledonia91
Answers: <p>You could use AWS ClI for consult availability zones:</p>
  
  <pre><code>aws ec2 describe-availability-zones
  </code></pre>
  
  <p>With this result you could prepare a script to take the first result.</p>
  
Answers: CC BY-SA 4.0
Answers: 2018-08-17T17:54:12.353Z
Answers: 2018-08-18T05:37:21.080Z
Answers: 2018-08-18T05:37:21.080Z
Answers: Yunier Saborit Ramírez
Answers: <p>I know this is an old question but I came across this same issue, and solved it in a different way. Rather than hardcoding the availability zones like the accepted answer, I think it is better to filter out those availability zones that do not support EKS. This approach makes it easier to move to a new region because the data is coming from aws, and not a hardcoded list.</p>
  <p><a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones#exclude_names" rel="nofollow noreferrer">https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones#exclude_names</a></p>
  <pre><code>data &quot;aws_availability_zones&quot; &quot;available&quot; {
      # List of availability zones that do not support EKS
      exclude_names = [&quot;us-east-1e&quot;]
  }
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2021-07-18T21:41:34.690Z
Answers: 2021-07-18T21:41:34.690Z
Answers: draxiom
Body: <p>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.</p>
  
  <pre><code>data "aws_availability_zones" "available" {}
  </code></pre>
  
  <p>However when I run a 'terraform apply', it generates the following error because us-east-1a is at capacity.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Is there any way I can get terraform to handle this automatically or specify that I only want to use 1b,1c,1d etc.</p>
  
  <p>EDIT:</p>
  
  <p>I've realised this is tied with where I create my subnets, which I do using this line:</p>
  
  <pre><code> availability_zone = "${data.aws_availability_zones.available.names[count.index]}"
  </code></pre>
  
  <p>So I assume I somehow need to skip us-east-1a by doing something here?</p>
  
  <p>Thanks in advance.</p>
  
Tags: <amazon-web-services><terraform>
Title: Terraform AWS AZ error - manually specify AZ?
UserDisplayName: Caledonia91
ThreadText: # Terraform AWS AZ error - manually specify AZ?
  
  (Asked by: username_0 on 2018-06-18)
  
  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.
  
  **Tags:** amazon-web-services, terraform
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2018-06-18. Score: 1
  
  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]}"
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2018-08-17. Score: 0
  
  You could use AWS ClI for consult availability zones:
  
  ```
  aws ec2 describe-availability-zones
  
  ```
  
  With this result you could prepare a script to take the first result.
  
  
  ---
  
  ### Answer by username_2 on 2021-07-18. Score: 0
  
  I know this is an old question but I came across this same issue, and solved it in a different way. Rather than hardcoding the availability zones like the accepted answer, I think it is better to filter out those availability zones that do not support EKS. This approach makes it easier to move to a new region because the data is coming from aws, and not a hardcoded list.
  
  <https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones#exclude_names>
  
  ```
  data "aws_availability_zones" "available" {
      # List of availability zones that do not support EKS
      exclude_names = ["us-east-1e"]
  }
  
  ```
  
  
  ---
  
  