Skip to content

Instantly share code, notes, and snippets.

@hairyhenderson
Last active January 26, 2016 21:05
Show Gist options
  • Save hairyhenderson/153d0e5c451df4e8c513 to your computer and use it in GitHub Desktop.
Save hairyhenderson/153d0e5c451df4e8c513 to your computer and use it in GitHub Desktop.
provider "aws" {
region = "us-east-1"
}
provider "aws" {
alias = "us-east-1"
region = "us-east-1"
}
provider "aws" {
alias = "eu-west-1"
region = "eu-west-1"
}
provider "aws" {
alias = "us-west-1"
region = "us-west-1"
}
variable "regions" {
default = "us-east-1,eu-west-1,us-west-1"
}
resource "aws_vpc" "vpc" {
count = 3
provider = "aws.${element(split(",",var.regions), count.index)}"
cidr_block = "10.1.${count.index}.0/24"
}
@pll
Copy link

pll commented Jan 26, 2016

This seems to compile without errors:

   variable "count" {
     default = 1
   }

   variable "regions" {
     default = {
        "0" = "us-east-1"
        "1" = "eu-west-2"
        "2" = "us-west-1"
   }

   provider "aws" {
     alias = "0"
     region = "us-east-1"
   }

   provider "aws" {
     alias = "1"
     region = "eu-west-1"
   }

   provider "aws" {
     alias = "2"
     region = "us-west-1" 
   } 

   resource "aws_vpc" "vpc" {
     count = 3
     provider = "aws.aws_${count.index}"
     cidr_block = "10.1.${count.index}.0/24"
   }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment