26 lines
656 B
HCL
26 lines
656 B
HCL
provider "aws" {
|
|
region = "us-east-2"
|
|
}
|
|
|
|
# A local variable that chooses a free-tier instance type depending on region
|
|
locals {
|
|
# In some newer regions, t2.micro isn't available, so we fall back to t3.micro
|
|
free_tier_instance_type = contains(
|
|
["us-east-1", "us-west-1", "us-west-2", "eu-west-1", "ap-southeast-1"],
|
|
var.region
|
|
) ? "t2.micro" : "t3.micro"
|
|
}
|
|
|
|
# Add a variable so you can override region easily if needed
|
|
variable "region" {
|
|
default = "us-east-2"
|
|
}
|
|
|
|
resource "aws_instance" "example" {
|
|
ami = "ami-0fb653ca2d3203ac1"
|
|
instance_type = local.free_tier_instance_type
|
|
|
|
tags = {
|
|
Name = "terraform-example"
|
|
}
|
|
}
|