This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "environment" { | |
default = "staging" | |
} | |
variable "key_name" { | |
description = "The aws keypair to use" | |
} | |
variable "region" { | |
description = "Region that the instances will be created" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module "web" { | |
source = "../modules/web" | |
web_instance_count = "${var.web_instance_count}" | |
region = "${var.region}" | |
instance_type = "t2.micro" | |
private_subnet_id = "${module.networking.private_subnet_id}" | |
public_subnet_id = "${module.networking.public_subnet_id}" | |
vpc_sg_id = "${module.networking.default_sg_id}" | |
key_name = "${var.key_name}" | |
environment = "${var.environment}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output "elb.hostname" { | |
value = "${aws_elb.web.dns_name}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
apt-get update -y | |
apt-get install -y nginx > /var/nginx.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Security group for the web */ | |
resource "aws_security_group" "web_server_sg" { | |
name = "${var.environment}-web-server-sg" | |
description = "Security group for web that allows web traffic from internet" | |
vpc_id = "${var.vpc_id}" | |
ingress { | |
from_port = 22 | |
to_port = 22 | |
protocol = "tcp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "web_instance_count" { | |
description = "The total of web instances to run" | |
} | |
variable "region" { | |
description = "The region to launch the instances" | |
} | |
variable "amis" { | |
default = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
environment = "staging" | |
key_name = "test" | |
region = "us-west-1" | |
availability_zone = "us-west-1a" | |
# vpc | |
vpc_cidr = "10.0.0.0/16" | |
public_subnet_cidr = "10.0.1.0/24" | |
private_subnet_cidr = "10.0.2.0/24" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "aws" { | |
region = "${var.region}" | |
} | |
resource "aws_key_pair" "key" { | |
key_name = "${var.key_name}" | |
public_key = "${file("staging_key.pub")}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "environment" { | |
default = "staging" | |
} | |
variable "key_name" { | |
description = "The aws keypair to use" | |
} | |
variable "region" { | |
description = "Region that the instances will be created" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module "networking" { | |
source = "../modules/networking" | |
environment = "${var.environment}" | |
vpc_cidr = "${var.vpc_cidr}" | |
public_subnet_cidr = "${var.public_subnet_cidr}" | |
private_subnet_cidr = "${var.private_subnet_cidr}" | |
region = "${var.region}" | |
availability_zone = "${var.availability_zone}" | |
key_name = "${var.key_name}" | |
} |