Skip to content

Instantly share code, notes, and snippets.

variable "name" {
description = "The name for the resource"
default = "example"
}
variable "environment" {
description = "The env of the app"
default = "staging"
}
resource "aws_elb" "elb" {
name = "${var.name}"
security_groups = [ "${aws_security_group.sg.id}" ]
cross_zone_load_balancing = true
instances = ["${aws_instance.example.id}"]
listener {
instance_port = "80"
instance_protocol = "tcp"
lb_port = "80"
resource "aws_security_group" "sg" {
name = "${var.name}-sg"
description = "Allow all inbound traffic"
vpc_id = "${var.vpc_id}"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
@adelsjnr
adelsjnr / example.tf
Last active April 11, 2017 21:37
Terraform basic ec2 creation
provider "aws" {
access_key = "ACCESS_KEY_HERE"
secret_key = "SECRET_KEY_HERE"
region = "us-east-1"
}
resource "aws_instance" "example" {
ami = "ami-c80b0aa2"
instance_type = "t2.micro"
}