terraform resource aws_instance example
Example 1: how to define provider in resource block
# default configuration
provider "google" {
region = "us-central1"
}
# alternate configuration, whose alias is "europe"
provider "google" {
alias = "europe"
region = "europe-west1"
}
resource "google_compute_instance" "example" {
# This "provider" meta-argument selects the google provider
# configuration whose alias is "europe", rather than the
# default configuration.
provider = google.europe
# ...
}
Example 2: repetitive resource use in different region terraform
####Repeat Resource block and launch in multiple regions
provider "aws" {
region = "us-west-1"
access_key = "PUT-ACCESS-KEY"
secret_key = "PUT-SECRET-KEY"
}
provider "aws" {
alias = "mumbai"
region = "ap-south-1"
access_key = "PUT-ACCESS-KEY"
secret_key = "PUT-SECRET-KEY"
}
resource "aws_eip" "eip1" {
vpc = "true"
}
resource "aws_eip" "eip2" {
vpc = "true"
provider = aws.mumbai
}