Skip to content

Instantly share code, notes, and snippets.

@kevinlondon
Created April 26, 2016 19:51
Show Gist options
  • Save kevinlondon/efd46ec140786ecf3444d7daabfd5473 to your computer and use it in GitHub Desktop.
Save kevinlondon/efd46ec140786ecf3444d7daabfd5473 to your computer and use it in GitHub Desktop.
DevOps from Scratch tutorial Terraform file
provider "aws" {
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "${var.aws_region}"
}
resource "aws_instance" "hello_world" {
ami = "ami-fce3c696" # Ubuntu 14.04 for us-east-1
instance_type = "t2.micro"
vpc_security_group_ids = ["${aws_security_group.web.id}"]
key_name = "${aws_key_pair.hello_world.id}"
}
resource "aws_security_group" "web" {
name = "web"
description = "Allow HTTP and SSH connections."
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_key_pair" "hello_world" {
key_name = "hello_world"
public_key = "${file(var.public_key_path)}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment