AWS

main.tf configuration

provider "aws" {
  region = "us-east-1"
  access_key = "access-key"
  secret_key = "secret-key"
  # Access and Secret Key is taken from security credential under AWS/<profilename>
}

resource "<provider>_<resource_type>" "name" {
  config options
  key = "value"
  key2 = "value2"
}

EC2 Instance

  • Amazon Machine Image

# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance
resource "aws_instance" "myserver" {
  # AMI get from AWS EC2 portal
  ami           = "ami-0006abfd85caddf82"
  instance_type = "t3.micro"
  architecture_type = "arm64"

  user_data = <<-EOF
  sudo apt update -y
  sudo apt install apache2 -y
  EOF>>

}

Sample configuration to deploy AWS resources

Last updated