Skip to content

Instantly share code, notes, and snippets.

@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"
}
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"]
}
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"
variable "name" {
description = "The name for the resource"
default = "example"
}
variable "environment" {
description = "The env of the app"
default = "staging"
}
resource "aws_instance" "example" {
ami = "ami-c80b0aa2"
instance_type = "t2.micro"
security_groups = [ "${aws_security_group.sg.id}" ]
}
resource "aws_elb" "elb" {
name = "${var.name}"
security_groups = [ "${aws_security_group.sg.id}" ]
cross_zone_load_balancing = true
module "marketing_web" {
source = "../web-site-module-example/"
name = "marketing-web"
environment = "production"
}
module "finance_web" {
source = "../web-site-module-example/"
name = "finance-web"
environment = "production"
}
module "facilities_web" {
source = "../web-site-module-example/"
name = "facilities-web"
environment = "production"
}
module "finance_web" {
source = "github.com/adelsjnr/terraform_modules.git//terraform_modules"
name = "finance-web"
environment = "production"
}

Keybase proof

I hereby claim:

  • I am adelsjnr on github.
  • I am adelsjnr (https://keybase.io/adelsjnr) on keybase.
  • I have a public key ASDZ_xHHQh-cJEs6eFf9o2fJ5jvive06FkgKAmS3MuVsXgo

To claim this, I am signing this object: