Skip to content

Instantly share code, notes, and snippets.

@prashanth-sams
Created January 22, 2020 15:06
Show Gist options
  • Save prashanth-sams/f0c6186aae96d73cf0d492efb5aa1d4a to your computer and use it in GitHub Desktop.
Save prashanth-sams/f0c6186aae96d73cf0d492efb5aa1d4a to your computer and use it in GitHub Desktop.
Basic terraform script to create a EC2 instance
provider "aws" {
version = "~> 2.0"
region = "us-west-2"
shared_credentials_file = "~/.aws/credentials"
profile = "prashanth"
}
data "aws_ami" "amazon-linux-2" {
most_recent = true
owners = ["amazon"]
filter {
name = "name"
values = ["amzn2-ami-hvm*"]
}
filter {
name = "architecture"
values = ["x86_64"]
}
}
resource "aws_instance" "test" {
ami = "${data.aws_ami.amazon-linux-2.id}"
associate_public_ip_address = true
instance_type = "t2.micro"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment