Skip to content

Instantly share code, notes, and snippets.

@matthewglover
Created November 20, 2017 13:55
Show Gist options
  • Save matthewglover/ba5fb07a9082dc10ae747bce201de4c3 to your computer and use it in GitHub Desktop.
Save matthewglover/ba5fb07a9082dc10ae747bce201de4c3 to your computer and use it in GitHub Desktop.
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "example" {
ami = "ami-6057e21a"
instance_type = "t2.micro"
vpc_security_group_ids = ["${aws_security_group.instance.id}"]
key_name = "test-keypair"
tags {
Name = "terraform-example"
}
}
resource "aws_security_group" "instance" {
name = "terraform-example-instance"
ingress {
from_port = 8080
to_port = 8080
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
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 = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
output "public_ip" {
value = "${aws_instance.example.public_ip}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment