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

Commit

Permalink
manage state remotely, allow totally separate infra per project
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Kellen committed Mar 8, 2017
1 parent 65ad192 commit ac1f690
Show file tree
Hide file tree
Showing 16 changed files with 158 additions and 669 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.terraform
*.tfstate.backup
*.plan
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.PHONY: init plan apply push

init:
cd terraform/states/$(state) && terraform get
cd terraform/states/$(state) && terraform remote config \
-backend=s3 \
-backend-config="bucket=foundation-terraform" \
-backend-config="key=$(state).tfstate" \
-backend-config="profile=foundation" \
-backend-config="region=us-east-1"

plan:
cd terraform/states/$(state) && terraform plan -out $(state).plan -var-file ../../variables.tfvars

apply:
cd terraform/states/$(state) && terraform apply $(state).plan

push:
cd terraform/states/$(state) && terraform remote push
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
# Bocoup Foundation Inc
> our infrastructure, as code
## Setup
## Bootstrapping
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`
access keys that match `profile` in `terraform/variables.tfvars`

## Managing Infrastructure

#### init
Running `state=<name> make init` configures your local environment to access
the terraform state as stored in S3. This is a prequisite before managing any
of our states.

### plan
Running `state=<name> make plan` compares your local configuration to the
actual deployed infrastructure and prepares a plan to reconcile any
differences.

### apply
After verifying your plan, running `state=<name> make apply` will execute
the changes from your last plan.


[AWSCLI]: http://docs.aws.amazon.com/cli/latest/userguide/installing.html
[Terraform]: https://www.terraform.io/downloads.html
81 changes: 0 additions & 81 deletions terraform.tf

This file was deleted.

Loading

0 comments on commit ac1f690

Please sign in to comment.