Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Kellen committed Mar 6, 2017
0 parents commit 65ad192
Show file tree
Hide file tree
Showing 11 changed files with 831 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.terraform
*.tfstate.backup
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Bocoup Foundation Inc
> our infrastructure, as code
## Setup
1. Install [AWSCLI] & [Terraform]
2. Log into AWS EC2 console, create a key pair titled "default".
Download the key and add to your ssh-agent: `ssh-add /path/to/key.pem`
3. Ensure `~/.aws/credentials` has a profile with administrative
access keys that match `name` in `terraform.tfvars`
4. Provision your infrastructure: `terraform apply`

[AWSCLI]: http://docs.aws.amazon.com/cli/latest/userguide/installing.html
[Terraform]: https://www.terraform.io/downloads.html
81 changes: 81 additions & 0 deletions terraform.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
variable "name" { }
variable "domain" { }
variable "aws_region" { }
variable "vpc_cidr" { }
variable "azs" { type = "list" }
variable "key_name" { }
variable "subnet_cidrs" { type = "list" }

##
# Provide credentials for AWS from ~/.aws/credentials
# with the correct profile name.
#
provider "aws" {
profile = "${var.name}"
region = "${var.aws_region}"
}

##
# AMI for Ubuntu 16
#
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20170303"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
# Canonical
owners = ["099720109477"]
}

##
# Network for our entire infrastructure.
#
module "vpc" {
source = "./terraform/modules/aws/vpc"
name = "${var.name}"
cidr = "${var.vpc_cidr}"
}

##
# Subnets within our network.
#
module "subnet" {
source = "./terraform/modules/aws/subnet"
name = "${var.name}-public"
azs = "${var.azs}"
vpc_id = "${module.vpc.id}"
cidrs = "${var.subnet_cidrs}"
}

##
# DNS zone for primary domain.
#
resource "aws_route53_zone" "main" {
name = "${var.domain}"
lifecycle {
prevent_destroy = true
}
}

##
# All Bocoup Foundation Inc webites.
#
module "websites" {
source = "./terraform/websites"
domain = "${var.domain}"
domain_zone_id = "${aws_route53_zone.main.id}"
}

##
# All Bocoup Foundation Inc services.
#
module "services" {
source = "./terraform/services"
domain = "${var.domain}"
domain_zone_id = "${aws_route53_zone.main.id}"
}
Loading

0 comments on commit 65ad192

Please sign in to comment.