Skip to content

Instantly share code, notes, and snippets.

@kitsunde
Created December 28, 2015 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitsunde/175e419d2e8eaa991ea5 to your computer and use it in GitHub Desktop.
Save kitsunde/175e419d2e8eaa991ea5 to your computer and use it in GitHub Desktop.
Terraform AWS provision.
# We control the existance of the build-server by setting this to 0 or 1
variable "build_servers" {
}
provider "aws" {
access_key = "<aws_key>"
secret_key = "<aws_secret>"
region = "us-east-1"
}
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/24"
enable_dns_hostnames = true
}
resource "aws_internet_gateway" "default" {
vpc_id = "${aws_vpc.main.id}"
}
resource "aws_route_table" "r" {
vpc_id = "${aws_vpc.main.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.default.id}"
}
}
resource "aws_subnet" "subnet" {
vpc_id = "${aws_vpc.main.id}"
cidr_block = "10.0.0.0/24"
map_public_ip_on_launch = true
tags {
Name = "tf-linkchecker-build-subnet"
}
}
resource "aws_route_table_association" "linkchecker-subnet-association" {
subnet_id = "${aws_subnet.subnet.id}"
route_table_id = "${aws_route_table.r.id}"
}
resource "aws_security_group" "default" {
name = "allow_ssh"
vpc_id = "${aws_vpc.main.id}"
ingress {
from_port = 22
to_port = 22
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_instance" "lambda-build-server" {
count = "${var.build_servers}"
# @todo It would be nice to be able to lookup the ami.
ami = "ami-60b6c60a"
instance_type = "t2.small"
subnet_id = "${aws_subnet.subnet.id}"
key_name = "mediapop-east"
vpc_security_group_ids = [
"${aws_security_group.default.id}"
]
tags {
Name = "lambda-linkchecker-build-server"
}
depends_on = [
"aws_internet_gateway.default"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment