Skip to content

Instantly share code, notes, and snippets.

@djaboxx
Created September 5, 2018 18:40
Show Gist options
  • Save djaboxx/d3fda57849c164c522cb7e36793723c4 to your computer and use it in GitHub Desktop.
Save djaboxx/d3fda57849c164c522cb7e36793723c4 to your computer and use it in GitHub Desktop.
Simple Terraform Configuration to create 1 ec2 instance with Name tag
provider "aws" {
region = "us-west-2"
}
variable "instance_name" {
type = "string"
description = "Name of EC2 Instance"
}
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"] # Canonical
}
resource "aws_instance" "web" {
ami = "${data.aws_ami.ubuntu.id}"
instance_type = "t2.micro"
tags {
Name = "${var.instance_name}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment