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

Unable to launch multiple EC2 instances in different availability zones using terraform

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

Problem

Whenever I try to launch the instances, I am getting the following error message. Please help with this.

Error: Error applying plan:

3 error(s) occurred:

* aws_instance.example[0]: 1 error(s) occurred:

* aws_instance.example.0: Error launching source instance: InvalidParameterValue: Invalid availability zone: [{us-east-1b]
        status code: 400, request id: 2637e297-236d-4e3b-b5a4-b5afe3df5e67
* aws_instance.example[2]: 1 error(s) occurred:

* aws_instance.example.2: Error launching source instance: InvalidParameterValue: Invalid availability zone: [ us-east-1d}]
        status code: 400, request id: 59244720-ab1c-48c7-a9b8-3eb6a23bd5ae
* aws_instance.example[1]: 1 error(s) occurred:

* aws_instance.example.1: Error launching source instance: InvalidParameterValue: Invalid availability zone: [ us-east-1c]
        status code: 400, request id: 1e335e56-f129-4ea0-a5c6-09b0501b6e18

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Solution

It looks like you're using the wrong brackets? I think you need to use a list:

variable "azs" {
  description = "Run the EC2 Instances in these Availability Zones"
  type = "list"
  default = ["us-east-1a", "us-east-1b", "us-east-1c"]
}


Source

Code Snippets

variable "azs" {
  description = "Run the EC2 Instances in these Availability Zones"
  type = "list"
  default = ["us-east-1a", "us-east-1b", "us-east-1c"]
}

Context

StackExchange DevOps Q#2428, answer score: 1

Revisions (0)

No revisions yet.