Skip to content

Instantly share code, notes, and snippets.

@baleyko
Forked from ian-bartholomew/main.tf
Created April 17, 2019 11:13
Show Gist options
  • Save baleyko/197aebbb2eec41b778146c92c5a5ef88 to your computer and use it in GitHub Desktop.
Save baleyko/197aebbb2eec41b778146c92c5a5ef88 to your computer and use it in GitHub Desktop.
Terraform Hello World
provider "aws" {
region = "us-east-1"
}
resource "aws_security_group" "instance" {
name = "terraform-example-instance"
ingress {
from_port = "${var.server_port}"
to_port = "${var.server_port}"
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_instance" "web" {
ami = "ami-2d39803a"
instance_type = "t2.micro"
vpc_security_group_ids = ["${aws_security_group.instance.id}"]
user_data = <<-EOF
#!/bin/bash
echo "Hello world" > index.html
nohup busybox httpd -f -p 8080 &
EOF
tags {
Name = "terraform-example"
}
}
output "public_ip" {
value = "${aws_instance.web.public_ip}"
}
variable "server_port" {
description = "The port the server will use for HTTP requests"
default = 8080
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment