From 066eadfa74c32e56f4311db8ea26f7447e39a52d Mon Sep 17 00:00:00 2001 From: David Thornton Date: Fri, 27 Oct 2017 15:07:13 -0400 Subject: [PATCH 1/4] ferts --- aws.sh | 10 ++++++++++ image.json | 24 ++++++++++++++++++++++++ packer/image.json | 24 ++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 aws.sh create mode 100644 image.json create mode 100644 packer/image.json diff --git a/aws.sh b/aws.sh new file mode 100644 index 0000000..b278033 --- /dev/null +++ b/aws.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +export TF_VAR_aws_access_key="$(pass opseng-challenge/access-key)" +export TF_VAR_aws_secret_key="$(pass opseng-challenge/secret-key)" + +export AWS_ACCESS_KEY_ID="${TF_VAR_aws_access_key}" +export AWS_SECRET_ACCESS_KEY="${TF_VAR_aws_secret_key}" + +export TF_date="$(date +%Y%m%d%k%M%S)" + diff --git a/image.json b/image.json new file mode 100644 index 0000000..f0896e0 --- /dev/null +++ b/image.json @@ -0,0 +1,24 @@ +{ + "variables": { + "aws_access_key": "", + "aws_secret_key": "" + }, + "builders": [{ + "type": "amazon-ebs", + "access_key": "{{user `aws_access_key`}}", + "secret_key": "{{user `aws_secret_key`}}", + "region": "us-east-1", + "source_ami_filter": { + "filters": { + "virtualization-type": "hvm", + "name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*", + "root-device-type": "ebs" + }, + "owners": ["099720109477"], + "most_recent": true + }, + "instance_type": "t2.micro", + "ssh_username": "ubuntu", + "ami_name": "packer-example {{timestamp}}" + }] +} diff --git a/packer/image.json b/packer/image.json new file mode 100644 index 0000000..f0896e0 --- /dev/null +++ b/packer/image.json @@ -0,0 +1,24 @@ +{ + "variables": { + "aws_access_key": "", + "aws_secret_key": "" + }, + "builders": [{ + "type": "amazon-ebs", + "access_key": "{{user `aws_access_key`}}", + "secret_key": "{{user `aws_secret_key`}}", + "region": "us-east-1", + "source_ami_filter": { + "filters": { + "virtualization-type": "hvm", + "name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*", + "root-device-type": "ebs" + }, + "owners": ["099720109477"], + "most_recent": true + }, + "instance_type": "t2.micro", + "ssh_username": "ubuntu", + "ami_name": "packer-example {{timestamp}}" + }] +} From 535b47b3a0a06f1889feb056c788b68708791bef Mon Sep 17 00:00:00 2001 From: David Thornton Date: Fri, 27 Oct 2017 16:41:37 -0400 Subject: [PATCH 2/4] in progress --- .gitignore | 1 + packer/ec2_amazon-ebs.pem | 23 +++++++ packer/provision.sh | 14 ++++ packer/rc.local | 5 ++ terraform/main.tf | 89 +++++++++++++++++++++++++ terraform/terraform.tfstate | 87 +++++++++++++++++++++++++ terraform/terraform.tfstate.backup | 101 +++++++++++++++++++++++++++++ terraform/terraform.tfvars | 4 ++ 8 files changed, 324 insertions(+) create mode 100644 .gitignore create mode 100644 packer/ec2_amazon-ebs.pem create mode 100644 packer/provision.sh create mode 100644 packer/rc.local create mode 100644 terraform/main.tf create mode 100644 terraform/terraform.tfstate create mode 100644 terraform/terraform.tfstate.backup create mode 100644 terraform/terraform.tfvars diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3fa8c86 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.terraform diff --git a/packer/ec2_amazon-ebs.pem b/packer/ec2_amazon-ebs.pem new file mode 100644 index 0000000..a1da563 --- /dev/null +++ b/packer/ec2_amazon-ebs.pem @@ -0,0 +1,23 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEAmNKgSFCq543rycKHC76H9Fg8isCbsM1kf00UJIiJJZpV8jjFLG3xyA+xiK8y +gbSa8mPq9fH99OFLKWQzaPRKhxGVG2OzX3T0Vie+66q8K4zH0FzPYapYCk68vGTesL49nhIEgurm +kKQuiqZeA10/uSgzuSdBqYHhbFKyPdgEroFx/riMF7I3MRmGS0+NywGHQkLq7Mw5SGFQ3LtFQWWi +QGk+/K0s2Set9jJlYOLiI3kgom7LQyybj6mAV41ZQyG5wDMu00vr419+3OpqI15uWgrJEqtRwDUf +OYgmnMuxIJK0tawSnDWwRMGFDfdQ4HvUMd7EklM/fEQAJ8f/6bXNMwIDAQABAoIBAC8zjxIG6GKQ +sS0mCjQUa0WLI1fv2aaoKcwv8HLAQSv+GWGxKyVn5+/U+Q6wnjb1o44OUnoYfknudBqauk5GdeZ2 +Bcnp53MqWnVp3UxI9cm1t9mhcORHit3UJ/NAbI/Gkp2KDx6okwJF06I7dHoxiQcVZbRgbaV/WjLs +7+SuHfQPyKxytaAd76gKP1bxSZxIp7q2T4BUA1ideKY4dsNhkZi0cEbi1sTeGcrgB3Z3FNrgqZmw +ickJpY7F9e712KunceeWAaynphf/LdTpudSzgVGjZrPez6CK1viRG3r9a/Vba11p2eUTzl5xz4zZ +2DjoIeA3iBwDClSl0SmOLSZw6dECgYEA1ZARzn4RJjW/NdixA/wY85qWu1Yk29fJ4Pmubb/3PMrk +WOOpEfl/beV78xy9XmQjVu9FpFaOpbou+mTwK7mNztf1lJNXs4M420xu4AtrXTj3Uqo73O2kPbNt +t40yKDI7MJqn2VjiH0r5+WAXXIg3s2ee5q+iv+7lcW2rIT5hVe0CgYEAtzC22hiPSZ2DczY8FljI +TTGtBJSpZIOgp0Jec/NZ2GQqw5r2Uvq184NywWeaDWxAJ9BskSoJtHgS/HamsW0lXQU6hqn4LpDm +zJcKD7dPSdLiIpFXgmNkpeNi5n9psSnxN9vrA6296Lebtha50qtGv66i0AFBWjJvjrWrXfDJS58C +gYAtrGIih1OjmFsMaQtyjrfHYYhbCFFZswy50Kw9TJDTr5Cmcgn2jiVym2Gm3L6jMUddkE6Ulu5r +AyaI5o12zHhHhGhBHkHjYm0GeZI82DRd+5DpXP7wgOJfT8BnQQs5DYUbH/hFw3yYtLBBZQuZ/ofr +Fn4lV+q2oaDwYUP4GB85AQKBgARp5Q3uJ42jgOZGuT3kl7bcaonAtzAXx8gf3jy28UQ4bZtW4XZw +We/rC9nDEEAgio8rA2Kf+6ngdrykczG1KoBKPvW9pKAil5z4SqLETOG/dflVPSGEGYmxp9Fb4oUF +OK2a29ez2O6Bdfv2IjYEMGkv4PZYAWYV7wAmOmHCCmeLAoGAXKubeaaapWHvPa+tlgouen6tRMqB +btTbvPyODYw97VPGff2xc0UNZu17pxdio8KTGLDq8zj8y9/RshfkiXYKdx6aD0c8hyvkxeXQetMS +mPlBCb0xAVnYiOaz6fLJg3TwGCj1QjMC2t11O5JRXvq3nghraUIoFMV35UGU1d9XV4c= +-----END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/packer/provision.sh b/packer/provision.sh new file mode 100644 index 0000000..4325a02 --- /dev/null +++ b/packer/provision.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +sudo apt-get update +sudo apt-get install -y git python-pip +mkdir deploy +cd deploy +git clone https://github.com/wvchallenges/opseng-challenge-app.git +cd opseng-challenge-app +sudo pip install -r requirements.txt +# gunicorn app:app --bind 0.0.0.0:8000 + +sudo cp /home/ubuntu/rc.local /etc/rc.local + + diff --git a/packer/rc.local b/packer/rc.local new file mode 100644 index 0000000..347195d --- /dev/null +++ b/packer/rc.local @@ -0,0 +1,5 @@ +#!/bin/bash + +cd /home/ubuntu/deploy/opseng-challenge-app +gunicorn app:app --bind 0.0.0.0:8000 + diff --git a/terraform/main.tf b/terraform/main.tf new file mode 100644 index 0000000..cdbedd1 --- /dev/null +++ b/terraform/main.tf @@ -0,0 +1,89 @@ +variable "ami" {} + +variable "project" {} +variable "env" {} +variable "key_name" {} + + +provider "aws" { + region = "us-east-1" +} + + +resource "aws_vpc" "main" { + cidr_block = "10.0.0.0/16" +} + +/* +resource "aws_lb_target_group" "target_group" { + name = "${var.project}-${var.env}-tg" + port = 80 + protocol = "HTTP" + vpc_id = "${aws_vpc.main.id}" +} +*/ + +resource "aws_security_group" "allow_all" { + name = "allow_all" + description = "Allow all inbound traffic" + vpc_id = "${aws_vpc.main.id}" + + ingress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + prefix_list_ids = ["pl-12c4e678"] + } +} + +resource "aws_instance" "web" { + ami = "${var.ami}" + instance_type = "t2.micro" + key_name = "dthornton" + security_groups = ["allow_all"] + + tags { + Name = "${var.project}-${var.env}" + } +} + +/* +resource "aws_placement_group" "placementgroup" { + name = "${var.project}-${var.env}-pg" + strategy = "cluster" +} +*/ + +/* +resource "aws_launch_configuration" "launchconfig" { + name = "${var.project}-${var.env}-launch-config" + image_id = "${var.ami}" + instance_type = "t2.micro" + key_name = "dthornton" +} +*/ + +/* +resource "aws_autoscaling_group" "asg" { + availability_zones = ["us-east-1a","us-east-1b"] + name = "${var.project}-${var.env}" + max_size = 5 + min_size = 2 + health_check_grace_period = 300 + health_check_type = "ELB" + desired_capacity = 4 + force_delete = true + placement_group = "${aws_placement_group.placementgroup.id}" + launch_configuration = "${aws_launch_configuration.launchconfig.name}" +} +*/ + + diff --git a/terraform/terraform.tfstate b/terraform/terraform.tfstate new file mode 100644 index 0000000..9d124c1 --- /dev/null +++ b/terraform/terraform.tfstate @@ -0,0 +1,87 @@ +{ + "version": 3, + "terraform_version": "0.10.6", + "serial": 2, + "lineage": "b9159207-da2c-4e98-910d-877619982f1f", + "modules": [ + { + "path": [ + "root" + ], + "outputs": {}, + "resources": { + "aws_security_group.allow_all": { + "type": "aws_security_group", + "depends_on": [ + "aws_vpc.main" + ], + "primary": { + "id": "sg-822772f0", + "attributes": { + "description": "Allow all inbound traffic", + "egress.#": "1", + "egress.3910175877.cidr_blocks.#": "1", + "egress.3910175877.cidr_blocks.0": "0.0.0.0/0", + "egress.3910175877.description": "", + "egress.3910175877.from_port": "0", + "egress.3910175877.ipv6_cidr_blocks.#": "0", + "egress.3910175877.prefix_list_ids.#": "1", + "egress.3910175877.prefix_list_ids.0": "pl-12c4e678", + "egress.3910175877.protocol": "-1", + "egress.3910175877.security_groups.#": "0", + "egress.3910175877.self": "false", + "egress.3910175877.to_port": "0", + "id": "sg-822772f0", + "ingress.#": "1", + "ingress.482069346.cidr_blocks.#": "1", + "ingress.482069346.cidr_blocks.0": "0.0.0.0/0", + "ingress.482069346.description": "", + "ingress.482069346.from_port": "0", + "ingress.482069346.ipv6_cidr_blocks.#": "0", + "ingress.482069346.protocol": "-1", + "ingress.482069346.security_groups.#": "0", + "ingress.482069346.self": "false", + "ingress.482069346.to_port": "0", + "name": "allow_all", + "vpc_id": "vpc-4cee4f34" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "" + }, + "aws_vpc.main": { + "type": "aws_vpc", + "depends_on": [], + "primary": { + "id": "vpc-4cee4f34", + "attributes": { + "assign_generated_ipv6_cidr_block": "false", + "cidr_block": "10.0.0.0/16", + "default_network_acl_id": "acl-2be8b253", + "default_route_table_id": "rtb-11a7dd6b", + "default_security_group_id": "sg-d73267a5", + "dhcp_options_id": "dopt-7fe61d1a", + "enable_classiclink": "false", + "enable_classiclink_dns_support": "false", + "enable_dns_hostnames": "false", + "enable_dns_support": "true", + "id": "vpc-4cee4f34", + "instance_tenancy": "default", + "main_route_table_id": "rtb-11a7dd6b", + "tags.%": "0" + }, + "meta": { + "schema_version": "1" + }, + "tainted": false + }, + "deposed": [], + "provider": "" + } + }, + "depends_on": [] + } + ] +} diff --git a/terraform/terraform.tfstate.backup b/terraform/terraform.tfstate.backup new file mode 100644 index 0000000..b43777c --- /dev/null +++ b/terraform/terraform.tfstate.backup @@ -0,0 +1,101 @@ +{ + "version": 3, + "terraform_version": "0.10.6", + "serial": 2, + "lineage": "b9159207-da2c-4e98-910d-877619982f1f", + "modules": [ + { + "path": [ + "root" + ], + "outputs": {}, + "resources": { + "aws_instance.web": { + "type": "aws_instance", + "depends_on": [], + "primary": { + "id": "i-0411b998dfd5f4de1", + "attributes": { + "ami": "ami-58d37322", + "associate_public_ip_address": "true", + "availability_zone": "us-east-1b", + "disable_api_termination": "false", + "ebs_block_device.#": "0", + "ebs_optimized": "false", + "ephemeral_block_device.#": "0", + "iam_instance_profile": "", + "id": "i-0411b998dfd5f4de1", + "instance_state": "running", + "instance_type": "t2.micro", + "ipv6_addresses.#": "0", + "key_name": "dthornton", + "monitoring": "false", + "network_interface.#": "0", + "network_interface_id": "eni-42fd57cf", + "primary_network_interface_id": "eni-42fd57cf", + "private_dns": "ip-172-31-52-53.ec2.internal", + "private_ip": "172.31.52.53", + "public_dns": "ec2-54-167-160-222.compute-1.amazonaws.com", + "public_ip": "54.167.160.222", + "root_block_device.#": "1", + "root_block_device.0.delete_on_termination": "true", + "root_block_device.0.iops": "100", + "root_block_device.0.volume_size": "8", + "root_block_device.0.volume_type": "gp2", + "security_groups.#": "1", + "security_groups.3814588639": "default", + "source_dest_check": "true", + "subnet_id": "subnet-2f4b6604", + "tags.%": "1", + "tags.Name": "opseng-challenge-dev", + "tenancy": "default", + "volume_tags.%": "0", + "vpc_security_group_ids.#": "0" + }, + "meta": { + "e2bfb730-ecaa-11e6-8f88-34363bc7c4c0": { + "create": 600000000000, + "delete": 600000000000, + "update": 600000000000 + }, + "schema_version": "1" + }, + "tainted": false + }, + "deposed": [], + "provider": "" + }, + "aws_vpc.main": { + "type": "aws_vpc", + "depends_on": [], + "primary": { + "id": "vpc-4cee4f34", + "attributes": { + "assign_generated_ipv6_cidr_block": "false", + "cidr_block": "10.0.0.0/16", + "default_network_acl_id": "acl-2be8b253", + "default_route_table_id": "rtb-11a7dd6b", + "default_security_group_id": "sg-d73267a5", + "dhcp_options_id": "dopt-7fe61d1a", + "enable_classiclink": "false", + "enable_classiclink_dns_support": "false", + "enable_dns_hostnames": "false", + "enable_dns_support": "true", + "id": "vpc-4cee4f34", + "instance_tenancy": "default", + "main_route_table_id": "rtb-11a7dd6b", + "tags.%": "0" + }, + "meta": { + "schema_version": "1" + }, + "tainted": false + }, + "deposed": [], + "provider": "" + } + }, + "depends_on": [] + } + ] +} diff --git a/terraform/terraform.tfvars b/terraform/terraform.tfvars new file mode 100644 index 0000000..1909e14 --- /dev/null +++ b/terraform/terraform.tfvars @@ -0,0 +1,4 @@ +project="opseng-challenge" +ami="ami-58d37322" +env="dev" +key_name="dthornton" From 2c9f41878796901a242a508bde750c21c8c74981 Mon Sep 17 00:00:00 2001 From: David Thornton Date: Fri, 27 Oct 2017 17:40:06 -0400 Subject: [PATCH 3/4] more work --- packer/ec2_amazon-ebs.pem | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 packer/ec2_amazon-ebs.pem diff --git a/packer/ec2_amazon-ebs.pem b/packer/ec2_amazon-ebs.pem deleted file mode 100644 index a1da563..0000000 --- a/packer/ec2_amazon-ebs.pem +++ /dev/null @@ -1,23 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEogIBAAKCAQEAmNKgSFCq543rycKHC76H9Fg8isCbsM1kf00UJIiJJZpV8jjFLG3xyA+xiK8y -gbSa8mPq9fH99OFLKWQzaPRKhxGVG2OzX3T0Vie+66q8K4zH0FzPYapYCk68vGTesL49nhIEgurm -kKQuiqZeA10/uSgzuSdBqYHhbFKyPdgEroFx/riMF7I3MRmGS0+NywGHQkLq7Mw5SGFQ3LtFQWWi -QGk+/K0s2Set9jJlYOLiI3kgom7LQyybj6mAV41ZQyG5wDMu00vr419+3OpqI15uWgrJEqtRwDUf -OYgmnMuxIJK0tawSnDWwRMGFDfdQ4HvUMd7EklM/fEQAJ8f/6bXNMwIDAQABAoIBAC8zjxIG6GKQ -sS0mCjQUa0WLI1fv2aaoKcwv8HLAQSv+GWGxKyVn5+/U+Q6wnjb1o44OUnoYfknudBqauk5GdeZ2 -Bcnp53MqWnVp3UxI9cm1t9mhcORHit3UJ/NAbI/Gkp2KDx6okwJF06I7dHoxiQcVZbRgbaV/WjLs -7+SuHfQPyKxytaAd76gKP1bxSZxIp7q2T4BUA1ideKY4dsNhkZi0cEbi1sTeGcrgB3Z3FNrgqZmw -ickJpY7F9e712KunceeWAaynphf/LdTpudSzgVGjZrPez6CK1viRG3r9a/Vba11p2eUTzl5xz4zZ -2DjoIeA3iBwDClSl0SmOLSZw6dECgYEA1ZARzn4RJjW/NdixA/wY85qWu1Yk29fJ4Pmubb/3PMrk -WOOpEfl/beV78xy9XmQjVu9FpFaOpbou+mTwK7mNztf1lJNXs4M420xu4AtrXTj3Uqo73O2kPbNt -t40yKDI7MJqn2VjiH0r5+WAXXIg3s2ee5q+iv+7lcW2rIT5hVe0CgYEAtzC22hiPSZ2DczY8FljI -TTGtBJSpZIOgp0Jec/NZ2GQqw5r2Uvq184NywWeaDWxAJ9BskSoJtHgS/HamsW0lXQU6hqn4LpDm -zJcKD7dPSdLiIpFXgmNkpeNi5n9psSnxN9vrA6296Lebtha50qtGv66i0AFBWjJvjrWrXfDJS58C -gYAtrGIih1OjmFsMaQtyjrfHYYhbCFFZswy50Kw9TJDTr5Cmcgn2jiVym2Gm3L6jMUddkE6Ulu5r -AyaI5o12zHhHhGhBHkHjYm0GeZI82DRd+5DpXP7wgOJfT8BnQQs5DYUbH/hFw3yYtLBBZQuZ/ofr -Fn4lV+q2oaDwYUP4GB85AQKBgARp5Q3uJ42jgOZGuT3kl7bcaonAtzAXx8gf3jy28UQ4bZtW4XZw -We/rC9nDEEAgio8rA2Kf+6ngdrykczG1KoBKPvW9pKAil5z4SqLETOG/dflVPSGEGYmxp9Fb4oUF -OK2a29ez2O6Bdfv2IjYEMGkv4PZYAWYV7wAmOmHCCmeLAoGAXKubeaaapWHvPa+tlgouen6tRMqB -btTbvPyODYw97VPGff2xc0UNZu17pxdio8KTGLDq8zj8y9/RshfkiXYKdx6aD0c8hyvkxeXQetMS -mPlBCb0xAVnYiOaz6fLJg3TwGCj1QjMC2t11O5JRXvq3nghraUIoFMV35UGU1d9XV4c= ------END RSA PRIVATE KEY----- \ No newline at end of file From 2c42b2cb296c7363951f50d810e83911dfe6de2a Mon Sep 17 00:00:00 2001 From: David Thornton Date: Fri, 27 Oct 2017 18:55:39 -0400 Subject: [PATCH 4/4] seems functional, needs testing. --- README.md | 84 ++++---- aws-app.sh | 12 ++ image.json | 24 --- packer/image.json | 19 +- terraform/main.tf | 122 +++++++++--- terraform/terraform.tfstate | 307 ++++++++++++++++++++++++++--- terraform/terraform.tfstate.backup | 238 +++++++++++++++++++--- terraform/terraform.tfvars | 6 +- 8 files changed, 670 insertions(+), 142 deletions(-) create mode 100755 aws-app.sh delete mode 100644 image.json diff --git a/README.md b/README.md index ac59dab..602e33a 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,66 @@ -# Wave Operations Engineering Development Challenge +# Overview -Applicants for the [Operations Engineering team](https://wave.bamboohr.co.uk/jobs/) at Wave must complete the following challenge, and submit a solution prior to the interviewing process. +This repo has two parts: -The purpose of this exercise is to create something that we can discuss during the on-site interview, and that's representative of the kind of things we do here on a daily basis. +1. The packer dir. It has everything to make an AWS EC2 image that has the app "baked in". The product of this dir is an AMI. -There isn't a hard deadline for this exercise; take as long as you need to complete it. However, in terms of total time spent actively working on the challenge, we ask that you not spend more than a few hours, as we value your time and expect to leave things open to discussion in the on-site interview. +2. the terraform dir . This is where some infrastucture gets lit up running that app. At this time it's just a lone vpc-less intance. -Send your completed submission to your contact at Wave. Feel free to email [ops.careers@waveapps.com](ops.careers@waveapps.com) if you have any questions. +I tried to keep this as simple as I could whle being functional. I also thorugh about security, usablity , and scalability -## Submission Instructions +aws.sh populates your environment with your aws creds. -1. Fork this project on GitHub - you'll need to create an account if you don't already have one -1. Complete the project as described below within your fork -1. Push all of your changes to your fork on GitHub and submit a pull request -1. Email your contact at Wave to let them know you have submitted a solution, and make sure to include your GitHub username in your email (so we can match applicants with pull requests) +# Packer -## Alternate Submission Instructions (if you don't want to publicize completing the challenge) +There are three parts that make this up. -1. Clone the repository -1. Complete your project as described below within your local repository -1. Email a patch file to your contact at Wave +image.json + the packer template + references the two files before. -## Project Description +provision.sh + a script run at ami build time that gets the app installed. + supprting software install is in this file. -There's a basic Python app available [here](https://github.com/wvchallenges/opseng-challenge-app). Your task is to host this app on AWS, using the current `HEAD` of the `master` branch as of when we test your submission. +rc.local + a start up script that ensures that the services is running as the instance comes up. + startup options are in this file. -The OS used for hosting, and the tools & techniques used to accomplish this are up to you. Once you're done, please submit a paragraph or two in your `README` about what you're particularly proud of in your implementation, and why. Be deliberate in your choices and design, as we'll use them as a starting point for our discussions. +# Terraform -### Deliverables +Just a lone instance at this time. -You should provide at least an executable bash script called `aws-app.sh`. You're welcome to include other files and install/use other tools in your repo as needed, but `aws-app.sh` is what we'll run to test your submission (see the evaluation section). +You need to make your own key pair and specify it in terraform.tfvars. -#### Notes +In tfvars you also need to enter the ami id of the ami created by packer above. -* **Do not check AWS keys or any other secret credentials into git** -* Prefix all of your AWS resources (when possible) with your first name (example: joanne.domain.com) -## Evaluation +# Pre-requisites and Requirements -We'll do the following, using on a stock OSX machine with Python 2.7.10 or higher (but <3.0), the `awscli` Python package installed, and appropriate AWS environment variables set: -``` -$ git clone / # Or we'll apply your patch file to a checked-out branch -$ cd -$ ./aws-app.sh -``` -We expect that this will output a URL, and we'll then visit that URL to confirm it has the output generated by the current `HEAD` of the `master` branch of the repo linked to above. +1. put your aws api keys into pass in: ( https://www.passwordstore.org/ ) -When we're evaluating your submission, some of the questions we'll be asking are: +pass opseng-challenge/access-key +pass opseng-challenge/secret-key + +2. packer from hashicorp ( https://www.packer.io/ ) + +3. terraform from hashicorp ( https://www.terraform.io/ ) + +# To Do + +Security +Auto Scaling +Try making this a docker image and using AWS ECS. + +# Bugs + +A temporary ssh key was committed to the repo and has since been removed form the repo and the cloud itself. + +The terraform data lookup for the ami will choose the latest image, you might want more granular control. + +Deployment process. There is no elegant way to get a new version deployed. + At this time the process would be: + 1. rerun packer to make a new image. + 2. rerun terraform for it to see the more recent ami. -* If we follow the steps above, do we end up with a working app at the URL specified? -* Does the working app reflect what's at the `HEAD` of the `master` branch right now, or at a point in the past? -* If we wanted to push out an updated version of the app's code, how much work would that be? -* Which application(s) and OS were chosen to host the app, and why? -* Which hosting strategy was selected, and did you have a good reason to pick that one? -* Are the decisions and strengths/weaknesses of this strategy discussed? -* How much of the hosting infrastructure is created when calling `aws-app.sh`, and how much does the script assume already exists or is created by hand in the console? diff --git a/aws-app.sh b/aws-app.sh new file mode 100755 index 0000000..a2f87ad --- /dev/null +++ b/aws-app.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +owd=`pwd` +cd packer +packer build image.json +cd ../terraform +terraform init +terraform get +terraform apply + +# Bugs: no error checking. + diff --git a/image.json b/image.json deleted file mode 100644 index f0896e0..0000000 --- a/image.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "variables": { - "aws_access_key": "", - "aws_secret_key": "" - }, - "builders": [{ - "type": "amazon-ebs", - "access_key": "{{user `aws_access_key`}}", - "secret_key": "{{user `aws_secret_key`}}", - "region": "us-east-1", - "source_ami_filter": { - "filters": { - "virtualization-type": "hvm", - "name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*", - "root-device-type": "ebs" - }, - "owners": ["099720109477"], - "most_recent": true - }, - "instance_type": "t2.micro", - "ssh_username": "ubuntu", - "ami_name": "packer-example {{timestamp}}" - }] -} diff --git a/packer/image.json b/packer/image.json index f0896e0..a42c9be 100644 --- a/packer/image.json +++ b/packer/image.json @@ -1,7 +1,7 @@ { "variables": { - "aws_access_key": "", - "aws_secret_key": "" + "aws_access_key": "{{env `TF_VAR_aws_access_key`}}", + "aws_secret_key": "{{env `TF_VAR_aws_secret_key`}}" }, "builders": [{ "type": "amazon-ebs", @@ -19,6 +19,17 @@ }, "instance_type": "t2.micro", "ssh_username": "ubuntu", - "ami_name": "packer-example {{timestamp}}" - }] + "ami_name": "opseng-challenge-app {{timestamp}}" + }], + "provisioners": [ + { + "type": "file", + "source": "./rc.local", + "destination": "/home/ubuntu/rc.local" + }, + { + "type": "shell", + "script": "./provision.sh" + } + ] } diff --git a/terraform/main.tf b/terraform/main.tf index cdbedd1..994f7b1 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -1,27 +1,34 @@ -variable "ami" {} - variable "project" {} variable "env" {} variable "key_name" {} - +variable "vpc_cidr" {} +variable "cidrs" {} +variable "azs" {} provider "aws" { region = "us-east-1" } +data "aws_ami" "appimage" { + most_recent = true + owners = ["505545132866"] + filter { + name = "name" + values = ["opseng-challenge-app*"] + } +} resource "aws_vpc" "main" { - cidr_block = "10.0.0.0/16" -} + cidr_block = "${var.vpc_cidr}" -/* -resource "aws_lb_target_group" "target_group" { - name = "${var.project}-${var.env}-tg" - port = 80 - protocol = "HTTP" - vpc_id = "${aws_vpc.main.id}" + lifecycle { + create_before_destroy = true + } + + tags { + Name = "${var.project}-${var.env}-vpc" + } } -*/ resource "aws_security_group" "allow_all" { name = "allow_all" @@ -36,24 +43,89 @@ resource "aws_security_group" "allow_all" { } egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - prefix_list_ids = ["pl-12c4e678"] + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] } } +resource "aws_internet_gateway" "igw" { + vpc_id = "${aws_vpc.main.id}" +} + +resource "aws_subnet" "public" { + vpc_id = "${aws_vpc.main.id}" + cidr_block = "${element(split(",", var.cidrs), count.index)}" + availability_zone = "${element(split(",", var.azs), count.index)}" + count = "${length(split(",", var.cidrs))}" + + tags { + Name = "public_subnet" + } + + lifecycle { + create_before_destroy = true + } + + map_public_ip_on_launch = true + + tags { + Name = "${var.project}-${var.env}-subnet" + } +} + +resource "aws_route_table" "public" { + vpc_id = "${aws_vpc.main.id}" + + route { + cidr_block = "0.0.0.0/0" + gateway_id = "${aws_internet_gateway.igw.id}" + } + + lifecycle { + create_before_destroy = true + ignore_changes = ["route"] + } + + tags { + Name = "${var.project}-${var.env}-${element(split(",", var.azs), count.index)}" + } +} + +resource "aws_route_table_association" "public_assoc" { + count = "${length(split(",", var.cidrs))}" + subnet_id = "${element(aws_subnet.public.*.id, count.index)}" + route_table_id = "${aws_route_table.public.id}" +} + resource "aws_instance" "web" { - ami = "${var.ami}" - instance_type = "t2.micro" - key_name = "dthornton" - security_groups = ["allow_all"] + count = 1 + ami = "${data.aws_ami.appimage.id}" + instance_type = "t2.micro" + key_name = "dthornton" + availability_zone = "us-east-1a" + security_groups = ["${aws_security_group.allow_all.id}"] + subnet_id = "${element(aws_subnet.public.*.id, count.index)}" + + lifecycle { + create_before_destroy = true + } tags { - Name = "${var.project}-${var.env}" + Name = "${var.project}-${var.env}-${count.index}" } + +} + +/* +resource "aws_lb_target_group" "target_group" { + name = "${var.project}-${var.env}-tg" + port = 80 + protocol = "HTTP" + vpc_id = "${aws_vpc.main.id}" } +*/ /* resource "aws_placement_group" "placementgroup" { @@ -65,7 +137,7 @@ resource "aws_placement_group" "placementgroup" { /* resource "aws_launch_configuration" "launchconfig" { name = "${var.project}-${var.env}-launch-config" - image_id = "${var.ami}" + image_id = "${data.aws_ami.appimage.id}" instance_type = "t2.micro" key_name = "dthornton" } @@ -86,4 +158,6 @@ resource "aws_autoscaling_group" "asg" { } */ - +output "url" { + value = "http://${aws_instance.web.public_ip}:8000" +} diff --git a/terraform/terraform.tfstate b/terraform/terraform.tfstate index 9d124c1..8a151de 100644 --- a/terraform/terraform.tfstate +++ b/terraform/terraform.tfstate @@ -1,37 +1,183 @@ { "version": 3, "terraform_version": "0.10.6", - "serial": 2, + "serial": 10, "lineage": "b9159207-da2c-4e98-910d-877619982f1f", "modules": [ { "path": [ "root" ], - "outputs": {}, + "outputs": { + "url": { + "sensitive": false, + "type": "string", + "value": "http://34.237.144.72:8000" + } + }, "resources": { + "aws_instance.web": { + "type": "aws_instance", + "depends_on": [], + "primary": { + "id": "i-0092d4dfcffee7906", + "attributes": { + "ami": "ami-58d37322", + "associate_public_ip_address": "true", + "availability_zone": "us-east-1a", + "disable_api_termination": "false", + "ebs_block_device.#": "0", + "ebs_optimized": "false", + "ephemeral_block_device.#": "0", + "iam_instance_profile": "", + "id": "i-0092d4dfcffee7906", + "instance_state": "running", + "instance_type": "t2.micro", + "ipv6_addresses.#": "0", + "key_name": "dthornton", + "monitoring": "false", + "network_interface.#": "0", + "network_interface_id": "eni-9b936a8d", + "primary_network_interface_id": "eni-9b936a8d", + "private_dns": "ip-10-10-1-14.ec2.internal", + "private_ip": "10.10.1.14", + "public_dns": "", + "public_ip": "34.237.144.72", + "root_block_device.#": "1", + "root_block_device.0.delete_on_termination": "true", + "root_block_device.0.iops": "100", + "root_block_device.0.volume_size": "8", + "root_block_device.0.volume_type": "gp2", + "security_groups.#": "0", + "source_dest_check": "true", + "subnet_id": "subnet-36c54a52", + "tags.%": "1", + "tags.Name": "david-opseng-challenge-dev-0", + "tenancy": "default", + "volume_tags.%": "0", + "vpc_security_group_ids.#": "1", + "vpc_security_group_ids.1011343189": "sg-288adf5a" + }, + "meta": { + "e2bfb730-ecaa-11e6-8f88-34363bc7c4c0": { + "create": 600000000000, + "delete": 600000000000, + "update": 600000000000 + }, + "schema_version": "1" + }, + "tainted": false + }, + "deposed": [], + "provider": "" + }, + "aws_internet_gateway.igw": { + "type": "aws_internet_gateway", + "depends_on": [ + "aws_vpc.main" + ], + "primary": { + "id": "igw-ffb60386", + "attributes": { + "id": "igw-ffb60386", + "tags.%": "0", + "vpc_id": "vpc-21ce6f59" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "" + }, + "aws_route_table.public": { + "type": "aws_route_table", + "depends_on": [ + "aws_internet_gateway.igw", + "aws_vpc.main" + ], + "primary": { + "id": "rtb-e7f18b9d", + "attributes": { + "id": "rtb-e7f18b9d", + "propagating_vgws.#": "0", + "route.#": "1", + "route.2793025681.cidr_block": "0.0.0.0/0", + "route.2793025681.egress_only_gateway_id": "", + "route.2793025681.gateway_id": "igw-ffb60386", + "route.2793025681.instance_id": "", + "route.2793025681.ipv6_cidr_block": "", + "route.2793025681.nat_gateway_id": "", + "route.2793025681.network_interface_id": "", + "route.2793025681.vpc_peering_connection_id": "", + "tags.%": "1", + "tags.Name": "david-opseng-challenge-dev-us-east-1a", + "vpc_id": "vpc-21ce6f59" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "" + }, + "aws_route_table_association.public_assoc.0": { + "type": "aws_route_table_association", + "depends_on": [ + "aws_route_table.public", + "aws_subnet.public.*" + ], + "primary": { + "id": "rtbassoc-1781266a", + "attributes": { + "id": "rtbassoc-1781266a", + "route_table_id": "rtb-e7f18b9d", + "subnet_id": "subnet-36c54a52" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "" + }, + "aws_route_table_association.public_assoc.1": { + "type": "aws_route_table_association", + "depends_on": [ + "aws_route_table.public", + "aws_subnet.public.*" + ], + "primary": { + "id": "rtbassoc-33882f4e", + "attributes": { + "id": "rtbassoc-33882f4e", + "route_table_id": "rtb-e7f18b9d", + "subnet_id": "subnet-140ae23b" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "" + }, "aws_security_group.allow_all": { "type": "aws_security_group", "depends_on": [ "aws_vpc.main" ], "primary": { - "id": "sg-822772f0", + "id": "sg-288adf5a", "attributes": { "description": "Allow all inbound traffic", "egress.#": "1", - "egress.3910175877.cidr_blocks.#": "1", - "egress.3910175877.cidr_blocks.0": "0.0.0.0/0", - "egress.3910175877.description": "", - "egress.3910175877.from_port": "0", - "egress.3910175877.ipv6_cidr_blocks.#": "0", - "egress.3910175877.prefix_list_ids.#": "1", - "egress.3910175877.prefix_list_ids.0": "pl-12c4e678", - "egress.3910175877.protocol": "-1", - "egress.3910175877.security_groups.#": "0", - "egress.3910175877.self": "false", - "egress.3910175877.to_port": "0", - "id": "sg-822772f0", + "egress.482069346.cidr_blocks.#": "1", + "egress.482069346.cidr_blocks.0": "0.0.0.0/0", + "egress.482069346.description": "", + "egress.482069346.from_port": "0", + "egress.482069346.ipv6_cidr_blocks.#": "0", + "egress.482069346.prefix_list_ids.#": "0", + "egress.482069346.protocol": "-1", + "egress.482069346.security_groups.#": "0", + "egress.482069346.self": "false", + "egress.482069346.to_port": "0", + "id": "sg-288adf5a", "ingress.#": "1", "ingress.482069346.cidr_blocks.#": "1", "ingress.482069346.cidr_blocks.0": "0.0.0.0/0", @@ -43,7 +189,9 @@ "ingress.482069346.self": "false", "ingress.482069346.to_port": "0", "name": "allow_all", - "vpc_id": "vpc-4cee4f34" + "owner_id": "505545132866", + "tags.%": "0", + "vpc_id": "vpc-21ce6f59" }, "meta": {}, "tainted": false @@ -51,26 +199,77 @@ "deposed": [], "provider": "" }, + "aws_subnet.public.0": { + "type": "aws_subnet", + "depends_on": [ + "aws_vpc.main" + ], + "primary": { + "id": "subnet-36c54a52", + "attributes": { + "assign_ipv6_address_on_creation": "false", + "availability_zone": "us-east-1a", + "cidr_block": "10.10.1.0/24", + "id": "subnet-36c54a52", + "map_public_ip_on_launch": "true", + "tags.%": "1", + "tags.Name": "david-opseng-challenge-dev-subnet", + "vpc_id": "vpc-21ce6f59" + }, + "meta": { + "schema_version": "1" + }, + "tainted": false + }, + "deposed": [], + "provider": "" + }, + "aws_subnet.public.1": { + "type": "aws_subnet", + "depends_on": [ + "aws_vpc.main" + ], + "primary": { + "id": "subnet-140ae23b", + "attributes": { + "assign_ipv6_address_on_creation": "false", + "availability_zone": "us-east-1b", + "cidr_block": "10.10.2.0/24", + "id": "subnet-140ae23b", + "map_public_ip_on_launch": "true", + "tags.%": "1", + "tags.Name": "david-opseng-challenge-dev-subnet", + "vpc_id": "vpc-21ce6f59" + }, + "meta": { + "schema_version": "1" + }, + "tainted": false + }, + "deposed": [], + "provider": "" + }, "aws_vpc.main": { "type": "aws_vpc", "depends_on": [], "primary": { - "id": "vpc-4cee4f34", + "id": "vpc-21ce6f59", "attributes": { "assign_generated_ipv6_cidr_block": "false", - "cidr_block": "10.0.0.0/16", - "default_network_acl_id": "acl-2be8b253", - "default_route_table_id": "rtb-11a7dd6b", - "default_security_group_id": "sg-d73267a5", + "cidr_block": "10.10.0.0/16", + "default_network_acl_id": "acl-527c592a", + "default_route_table_id": "rtb-10eb916a", + "default_security_group_id": "sg-a188ddd3", "dhcp_options_id": "dopt-7fe61d1a", "enable_classiclink": "false", "enable_classiclink_dns_support": "false", "enable_dns_hostnames": "false", "enable_dns_support": "true", - "id": "vpc-4cee4f34", + "id": "vpc-21ce6f59", "instance_tenancy": "default", - "main_route_table_id": "rtb-11a7dd6b", - "tags.%": "0" + "main_route_table_id": "rtb-10eb916a", + "tags.%": "1", + "tags.Name": "david-opseng-challenge-dev-vpc" }, "meta": { "schema_version": "1" @@ -79,6 +278,66 @@ }, "deposed": [], "provider": "" + }, + "data.aws_ami.appimage": { + "type": "aws_ami", + "depends_on": [], + "primary": { + "id": "ami-58d37322", + "attributes": { + "architecture": "x86_64", + "block_device_mappings.#": "3", + "block_device_mappings.1634610537.device_name": "/dev/sdb", + "block_device_mappings.1634610537.ebs.%": "0", + "block_device_mappings.1634610537.no_device": "", + "block_device_mappings.1634610537.virtual_name": "ephemeral0", + "block_device_mappings.2547816212.device_name": "/dev/sda1", + "block_device_mappings.2547816212.ebs.%": "6", + "block_device_mappings.2547816212.ebs.delete_on_termination": "true", + "block_device_mappings.2547816212.ebs.encrypted": "false", + "block_device_mappings.2547816212.ebs.iops": "0", + "block_device_mappings.2547816212.ebs.snapshot_id": "snap-069c82e03b2dfec05", + "block_device_mappings.2547816212.ebs.volume_size": "8", + "block_device_mappings.2547816212.ebs.volume_type": "gp2", + "block_device_mappings.2547816212.no_device": "", + "block_device_mappings.2547816212.virtual_name": "", + "block_device_mappings.3850042718.device_name": "/dev/sdc", + "block_device_mappings.3850042718.ebs.%": "0", + "block_device_mappings.3850042718.no_device": "", + "block_device_mappings.3850042718.virtual_name": "ephemeral1", + "creation_date": "2017-10-27T20:11:58.000Z", + "filter.#": "1", + "filter.763425321.name": "name", + "filter.763425321.values.#": "1", + "filter.763425321.values.0": "opseng-challenge-app*", + "hypervisor": "xen", + "id": "ami-58d37322", + "image_id": "ami-58d37322", + "image_location": "505545132866/opseng-challenge-app 1509134953", + "image_type": "machine", + "most_recent": "true", + "name": "opseng-challenge-app 1509134953", + "owner_id": "505545132866", + "owners.#": "1", + "owners.0": "505545132866", + "product_codes.#": "0", + "public": "false", + "root_device_name": "/dev/sda1", + "root_device_type": "ebs", + "root_snapshot_id": "snap-069c82e03b2dfec05", + "sriov_net_support": "simple", + "state": "available", + "state_reason.%": "2", + "state_reason.code": "UNSET", + "state_reason.message": "UNSET", + "tags.%": "0", + "virtualization_type": "hvm" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "" } }, "depends_on": [] diff --git a/terraform/terraform.tfstate.backup b/terraform/terraform.tfstate.backup index b43777c..4d378e7 100644 --- a/terraform/terraform.tfstate.backup +++ b/terraform/terraform.tfstate.backup @@ -1,56 +1,64 @@ { "version": 3, "terraform_version": "0.10.6", - "serial": 2, + "serial": 10, "lineage": "b9159207-da2c-4e98-910d-877619982f1f", "modules": [ { "path": [ "root" ], - "outputs": {}, + "outputs": { + "url": { + "sensitive": false, + "type": "string", + "value": "http://34.237.1.135:8000" + } + }, "resources": { "aws_instance.web": { "type": "aws_instance", - "depends_on": [], + "depends_on": [ + "aws_security_group.allow_all", + "aws_subnet.public.*" + ], "primary": { - "id": "i-0411b998dfd5f4de1", + "id": "i-085dc8a6b01f04dc0", "attributes": { "ami": "ami-58d37322", "associate_public_ip_address": "true", - "availability_zone": "us-east-1b", + "availability_zone": "us-east-1a", "disable_api_termination": "false", "ebs_block_device.#": "0", "ebs_optimized": "false", "ephemeral_block_device.#": "0", "iam_instance_profile": "", - "id": "i-0411b998dfd5f4de1", + "id": "i-085dc8a6b01f04dc0", "instance_state": "running", "instance_type": "t2.micro", "ipv6_addresses.#": "0", "key_name": "dthornton", "monitoring": "false", "network_interface.#": "0", - "network_interface_id": "eni-42fd57cf", - "primary_network_interface_id": "eni-42fd57cf", - "private_dns": "ip-172-31-52-53.ec2.internal", - "private_ip": "172.31.52.53", - "public_dns": "ec2-54-167-160-222.compute-1.amazonaws.com", - "public_ip": "54.167.160.222", + "network_interface_id": "eni-2b936a3d", + "primary_network_interface_id": "eni-2b936a3d", + "private_dns": "ip-10-10-1-252.ec2.internal", + "private_ip": "10.10.1.252", + "public_dns": "", + "public_ip": "34.237.1.135", "root_block_device.#": "1", "root_block_device.0.delete_on_termination": "true", "root_block_device.0.iops": "100", "root_block_device.0.volume_size": "8", "root_block_device.0.volume_type": "gp2", - "security_groups.#": "1", - "security_groups.3814588639": "default", + "security_groups.#": "0", "source_dest_check": "true", - "subnet_id": "subnet-2f4b6604", - "tags.%": "1", - "tags.Name": "opseng-challenge-dev", + "subnet_id": "subnet-36c54a52", + "tags.%": "0", "tenancy": "default", "volume_tags.%": "0", - "vpc_security_group_ids.#": "0" + "vpc_security_group_ids.#": "1", + "vpc_security_group_ids.1011343189": "sg-288adf5a" }, "meta": { "e2bfb730-ecaa-11e6-8f88-34363bc7c4c0": { @@ -65,26 +73,204 @@ "deposed": [], "provider": "" }, + "aws_internet_gateway.igw": { + "type": "aws_internet_gateway", + "depends_on": [ + "aws_vpc.main" + ], + "primary": { + "id": "igw-ffb60386", + "attributes": { + "id": "igw-ffb60386", + "vpc_id": "vpc-21ce6f59" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "" + }, + "aws_route_table.public": { + "type": "aws_route_table", + "depends_on": [ + "aws_internet_gateway.igw", + "aws_vpc.main" + ], + "primary": { + "id": "rtb-e7f18b9d", + "attributes": { + "id": "rtb-e7f18b9d", + "propagating_vgws.#": "0", + "route.#": "1", + "route.2793025681.cidr_block": "0.0.0.0/0", + "route.2793025681.egress_only_gateway_id": "", + "route.2793025681.gateway_id": "igw-ffb60386", + "route.2793025681.instance_id": "", + "route.2793025681.ipv6_cidr_block": "", + "route.2793025681.nat_gateway_id": "", + "route.2793025681.network_interface_id": "", + "route.2793025681.vpc_peering_connection_id": "", + "tags.%": "1", + "tags.Name": "david-opseng-challenge-dev-us-east-1a", + "vpc_id": "vpc-21ce6f59" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "" + }, + "aws_route_table_association.public_assoc.0": { + "type": "aws_route_table_association", + "depends_on": [ + "aws_route_table.public", + "aws_subnet.public.*" + ], + "primary": { + "id": "rtbassoc-1781266a", + "attributes": { + "id": "rtbassoc-1781266a", + "route_table_id": "rtb-e7f18b9d", + "subnet_id": "subnet-36c54a52" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "" + }, + "aws_route_table_association.public_assoc.1": { + "type": "aws_route_table_association", + "depends_on": [ + "aws_route_table.public", + "aws_subnet.public.*" + ], + "primary": { + "id": "rtbassoc-33882f4e", + "attributes": { + "id": "rtbassoc-33882f4e", + "route_table_id": "rtb-e7f18b9d", + "subnet_id": "subnet-140ae23b" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "" + }, + "aws_security_group.allow_all": { + "type": "aws_security_group", + "depends_on": [ + "aws_vpc.main" + ], + "primary": { + "id": "sg-288adf5a", + "attributes": { + "description": "Allow all inbound traffic", + "egress.#": "1", + "egress.482069346.cidr_blocks.#": "1", + "egress.482069346.cidr_blocks.0": "0.0.0.0/0", + "egress.482069346.description": "", + "egress.482069346.from_port": "0", + "egress.482069346.ipv6_cidr_blocks.#": "0", + "egress.482069346.prefix_list_ids.#": "0", + "egress.482069346.protocol": "-1", + "egress.482069346.security_groups.#": "0", + "egress.482069346.self": "false", + "egress.482069346.to_port": "0", + "id": "sg-288adf5a", + "ingress.#": "1", + "ingress.482069346.cidr_blocks.#": "1", + "ingress.482069346.cidr_blocks.0": "0.0.0.0/0", + "ingress.482069346.description": "", + "ingress.482069346.from_port": "0", + "ingress.482069346.ipv6_cidr_blocks.#": "0", + "ingress.482069346.protocol": "-1", + "ingress.482069346.security_groups.#": "0", + "ingress.482069346.self": "false", + "ingress.482069346.to_port": "0", + "name": "allow_all", + "owner_id": "505545132866", + "tags.%": "0", + "vpc_id": "vpc-21ce6f59" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "" + }, + "aws_subnet.public.0": { + "type": "aws_subnet", + "depends_on": [ + "aws_vpc.main" + ], + "primary": { + "id": "subnet-36c54a52", + "attributes": { + "assign_ipv6_address_on_creation": "false", + "availability_zone": "us-east-1a", + "cidr_block": "10.10.1.0/24", + "id": "subnet-36c54a52", + "map_public_ip_on_launch": "true", + "tags.%": "1", + "tags.Name": "david-opseng-challenge-dev-subnet", + "vpc_id": "vpc-21ce6f59" + }, + "meta": { + "schema_version": "1" + }, + "tainted": false + }, + "deposed": [], + "provider": "" + }, + "aws_subnet.public.1": { + "type": "aws_subnet", + "depends_on": [ + "aws_vpc.main" + ], + "primary": { + "id": "subnet-140ae23b", + "attributes": { + "assign_ipv6_address_on_creation": "false", + "availability_zone": "us-east-1b", + "cidr_block": "10.10.2.0/24", + "id": "subnet-140ae23b", + "map_public_ip_on_launch": "true", + "tags.%": "1", + "tags.Name": "david-opseng-challenge-dev-subnet", + "vpc_id": "vpc-21ce6f59" + }, + "meta": { + "schema_version": "1" + }, + "tainted": false + }, + "deposed": [], + "provider": "" + }, "aws_vpc.main": { "type": "aws_vpc", "depends_on": [], "primary": { - "id": "vpc-4cee4f34", + "id": "vpc-21ce6f59", "attributes": { "assign_generated_ipv6_cidr_block": "false", - "cidr_block": "10.0.0.0/16", - "default_network_acl_id": "acl-2be8b253", - "default_route_table_id": "rtb-11a7dd6b", - "default_security_group_id": "sg-d73267a5", + "cidr_block": "10.10.0.0/16", + "default_network_acl_id": "acl-527c592a", + "default_route_table_id": "rtb-10eb916a", + "default_security_group_id": "sg-a188ddd3", "dhcp_options_id": "dopt-7fe61d1a", "enable_classiclink": "false", "enable_classiclink_dns_support": "false", "enable_dns_hostnames": "false", "enable_dns_support": "true", - "id": "vpc-4cee4f34", + "id": "vpc-21ce6f59", "instance_tenancy": "default", - "main_route_table_id": "rtb-11a7dd6b", - "tags.%": "0" + "main_route_table_id": "rtb-10eb916a", + "tags.%": "1", + "tags.Name": "david-opseng-challenge-dev-vpc" }, "meta": { "schema_version": "1" diff --git a/terraform/terraform.tfvars b/terraform/terraform.tfvars index 1909e14..d28979a 100644 --- a/terraform/terraform.tfvars +++ b/terraform/terraform.tfvars @@ -1,4 +1,6 @@ -project="opseng-challenge" -ami="ami-58d37322" +project="david-opseng-challenge" env="dev" key_name="dthornton" +vpc_cidr="10.10.0.0/16" +cidrs="10.10.1.0/24,10.10.2.0/24" +azs="us-east-1a,us-east-1b"