Created
September 5, 2018 18:40
-
-
Save djaboxx/d3fda57849c164c522cb7e36793723c4 to your computer and use it in GitHub Desktop.
Simple Terraform Configuration to create 1 ec2 instance with Name tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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