Skip to content
This repository was archived by the owner on Oct 7, 2021. It is now read-only.

Commit 2d7422f

Browse files
authored
Introduce Simplified Reference Architecture (#54)
* redo ref arch * Update README * add details
1 parent 5cad9b5 commit 2d7422f

File tree

118 files changed

+41
-3190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+41
-3190
lines changed

Makefile

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,7 @@
11
# Import the cloudposse/build-harness
22
include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness)
3-
include tasks/Makefile.*
4-
5-
# Run time environment passed to terraform
6-
export TF_VAR_artifacts_dir ?= $(CURDIR)/artifacts
7-
export TF_VAR_repos_dir ?= $(CURDIR)/repos
8-
export TF_VAR_templates_dir ?= $(CURDIR)/templates
3+
-include tasks/Makefile.*
94

105
# The target called when calling `make` with no arguments
116
export DEFAULT_HELP_TARGET = help/short
127

13-
# The command we'll use to start the container
14-
export DOCKER_RUN = docker run --rm --privileged -it -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e SSH_KEY=false \
15-
-v $(CURDIR)/artifacts:/artifacts -v $(CURDIR)/scripts:/scripts \
16-
-v $(HOME):/localhost -e LOCAL_HOME=$(HOME)
17-
18-
# The directory containing configs
19-
export CONFIGS ?= configs
20-
21-
## Clean up
22-
clean::
23-
rm -rf repos accounts .terraform *.tfstate* artifacts/*
24-
25-
## Format all terraform code
26-
fmt:
27-
find $(CONFIGS) -type f -name '*.tfvars' -exec terraform fmt {} \;
28-
terraform fmt modules
29-
30-
finalize: root/finalize children/finalize
31-
@exit 0

README.md

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
1-
# reference-architectures
1+
# Reference Architectures
22

33
Get up and running quickly with one of our reference architectures using our fully automated cold-start process.
44

55
**NOTE:** This project is under active development and subject to change. Please [file issues](https://github.com/cloudposse/reference-architectures/issues/new) for all bugs encountered.
66

77
## Table of Contents
88

9-
- [reference-architectures](#reference-architectures)
9+
- [Reference Architectures](#reference-architectures)
1010
- [Table of Contents](#table-of-contents)
1111
- [Known Limitations](#known-limitations)
12-
- [High Level Overview](#high-level-overview)
12+
- [High-Level Overview](#high-level-overview)
1313
- [Architecture](#architecture)
1414
- [Assumptions](#assumptions)
1515
- [Checklist](#checklist)
1616
- [Get Started](#get-started)
17-
- [1. Provision Root Account](#1-provision-root-account)
17+
- [1. Provision Master Account](#1-provision-master-account)
1818
- [2. Provision Subaccounts](#2-provision-subaccounts)
1919
- [3. Delegate DNS](#3-delegate-dns)
2020
- [Next Steps](#next-steps)
2121
- [Getting Help](#getting-help)
2222

2323
## Known Limitations
2424

25-
- **AWS does not support programmatic deletion of accounts.** This means that if you use this project to create the account structure, terraform is not able to completely destroy it.
26-
- **AWS by default only permits one subaccount.** This limit can be easily increased for your organization, but can take up to several days.
27-
- **AWS will rate limit account creation.** This might mean you'll need to restart the provisioning (just re-run `make root`).
25+
- **AWS does not support programmatic deletion of accounts.** This means that if you use this project to create the account structure, but terraform is not able to completely tear it down. Deleting AWS accounts is a long, painful process, because AWS does not want to be on the hook for deleting stuff that it cannot get back.
26+
- **AWS by default only permits one sub-account.** This limit can be easily increased for your organization but can take up to several days.
27+
- **AWS will rate limit account creation.** This might mean you'll need to restart the provisioning.
28+
- **AWS only supports creating member accounts from the master account.** This means you cannot create accounts from within child/member accounts.
29+
- **AWS does not permit email addresses to be reused across accounts.** One key thing is that the email address associated with the account will be forever associated with that account. You will not be able to create a new account with that email address and you will not be able to change the email address later. So before you delete an account, change the email address to something you can consider a throwaway. Gmail and some other providers allow you to use plus-addressing (e.g. `[email protected]`)" to your username to create a unique email that still routes to you, so we suggest you use plus addressing for your accounts.
2830

29-
## High Level Overview
31+
## High-Level Overview
3032

3133
You can provision the basic reference architecture in 3 "easy" steps. =)
3234

33-
All accounts will leverage our [`terraform-root-modules`](https://github.com/cloudposse/terraform-root-modules/) service catalog to get you started. Later, we recommend you fork this and start your own service catalog suitable for your organization.
35+
All accounts will leverage our [`terraform-root-modules`](https://github.com/cloudposse/terraform-root-modules/) service catalog to get you started. Later, we recommend you fork this and start your very own service catalog suitable for your organization.
3436

3537
This process involves using `terraform` to generate the code (`Dockerfile`, `Makefile`, `terraform.tfvar`, etc) that you will use to manage your infrastructure.
3638

37-
This is a "bootstrap" process that gets you running from a cold-start. You do it once and then you literally throw _this_ (e.g. `reference-architectures/`) repo away. This project generates all the pre-configured boilerplate scaffolding you need in the `repos/` directory.
38-
39-
When you're done, in the `repos/` directory you'll have one Git repo for each AWS account. These repos are what you'll want to push up to GitHub. Each repo contains everything necessary to administer that account. We practice a strict "share nothing" approach, which is why each account gets it's own repo, terraform state backend, and DNS zone. This maximally reduces the blast radius of any human errors in one account affecting any other account. Also, because each account has it's own repo, it's _ideally_ suited for larger enterprise or corporate environments where various stakeholders will be responsible for running services in their account.
39+
This repo contains everything necessary to administer this architecture. We strive for a "share nothing" approach, which is why we use multiple AWS accounts and DNS zones. This reduces the blast radius from human errors. This reference architecture is _ideally_ suited for larger enterprise or corporate environments where various stakeholders will be responsible for running services in their account.
4040

4141
See the [Next Steps](#next-steps) section for where to go after this process completes.
4242

4343
### Architecture
4444

4545
Our "reference architecture" is an opinionated approach to architecting accounts for AWS.
4646

47-
This process provisions (7) accounts which have different designations.
47+
This process provisions 7+ accounts that have different designations.
4848

4949
Here is what it includes. Enable the accounts you want.
5050

51-
| Account | Description |
52-
| -------- | ----------------------------------------------------------------------------------------- |
53-
| root | The "root" (parent, billing) account creates all child accounts and is where users login. |
54-
| prod | The "production" is account where you run your most mission critical applications |
55-
| staging | The "staging" account is where you run all of your QA/UAT/Testing |
56-
| dev | The "dev" sandbox account is where you let your developers have fun and break things |
57-
| audit | The "audit" account is where all logs end up |
58-
| corp | The "corp" account is where you run the shared platform services for the company |
59-
| data | The "data" account is where the quants live =) |
60-
| testing | The "testing" account is where to run automated tests of untrusted infrastructure code |
61-
| security | The "security" account is where to run automated security scanning software |
62-
| identity | The "identity" account is where to add users and delegate access to the other accounts |
51+
| Account | Description |
52+
| -------- | ------------------------------------------------------------------------------------------- |
53+
| master | The "master" (parent, billing) account creates all child accounts and is where users login. |
54+
| prod | The "production" is account where you run your most mission critical applications |
55+
| staging | The "staging" account is where you run all of your QA/UAT/Testing |
56+
| dev | The "dev" sandbox account is where you let your developers have fun and break things |
57+
| audit | The "audit" account is where all logs end up |
58+
| corp | The "corp" account is where you run the shared platform services for the company |
59+
| data | The "data" account is where the quants live =) |
60+
| testing | The "testing" account is where to run automated tests of unblessed infrastructure code |
61+
| security | The "security" account is where to run automated security scanning software |
62+
| identity | The "identity" account is where to add users and delegate access to the other accounts |
6363

6464
Each account has its own [terraform state backend](https://github.com/cloudposse/terraform-aws-tfstate-backend), along with a [dedicated DNS zone](https://www.terraform.io/docs/providers/aws/r/route53_zone.html) for service discovery.
6565

66-
The root account owns the top-level DNS zone and then delegates NS authority to each child account.
66+
The master account owns the top-level DNS zone and then delegates NS authority to each child account.
6767

6868
### Assumptions
6969

70-
1. We are starting with a clean AWS environment and a new "root" (top-level) AWS account. This means you need the "root" credentials, since a fresh AWS account doesn't even have any AWS roles that can be assumed.
70+
1. We are starting with a clean AWS environment and a new "master" (top-level) AWS account. This means you need the "master" credentials, since a fresh AWS account doesn't even have any AWS roles that can be assumed.
7171
2. You have administrator access to this account.
7272
3. You have [docker](https://docs.cloudposse.com/tools/docker/) installed on your workstation.
7373
4. You have [terraform](https://www.terraform.io/downloads.html) installed on your workstation.
@@ -81,22 +81,19 @@ Before we get started, make sure you have the following
8181
- [ ] Clone this repo on your workstation.
8282
- [ ] Create a _temporary_ pair of [Access Keys](https://console.aws.amazon.com/iam/home#/security_credential). These should be deleted afterwards.
8383
- [ ] Export your AWS "root" account credentials as `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` (this is _temporary_ for bootstrapping).
84-
- [ ] An available domain we can use for DNS-base service discovery (E.g. `ourcompany.co`). This domain must not be in use elsewhere as the root account will need to be the authoritative name server (`SOA`).
85-
- [ ] Ensure that any users who will be added during this bootstrap process have created their [keybase](http://keybase.io) profile, and have an associated GPG key. You'll need this if setting them up in the `users` section of the [`config/root.tfvars`](https://github.com/cloudposse/reference-architectures/blob/master/configs/root.tfvars). For example you should be able to [verify each user's public key](https://keybase.io/osterman/key.asc) on `keybase.io` by running `curl https://keybase.io/$username/key.asc`.
84+
- [ ] An available domain we can use for DNS-base service discovery (E.g. `ourcompany.co`). This domain must not be in use elsewhere as the master account will need to be the authoritative name server (`SOA`).
8685

8786
## Get Started
8887

89-
### 1. Provision Root Account
90-
91-
The "root" account is the top-most AWS account from which all other AWS accounts are programmatically created.
88+
### 1. Provision Master Account
9289

93-
**WARNING:** Terraform cannot remove an AWS account from an organization. Terraform **cannot** close the account. The child account must be prepared to be a standalone account beforehand. To do this, issue a password reset using the child account's email address. Login and accept the prompts. Then you should be good to go. See the [AWS Organizations documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts_remove.html) for more information.
90+
The "master" account is the top-most AWS account from which all other AWS accounts are programmatically created.
9491

95-
**WARNING:** Do not chain the `make` targets together (e.g. `make root children finalize`) as it is not currently supported.
92+
**WARNING:** Terraform cannot remove an AWS account from an organization. Terraform **cannot** close the account. The child account must be prepared to be a standalone account beforehand. To do this, issue a password reset using the child account's email address. Login and accept the prompts. Then you should be good to go. See the [AWS Organization documentation](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts_remove.html) for more information.
9693

97-
This account is provisioned slightly different from the other subaccounts.
94+
This account is provisioned slightly differently from the other member accounts.
9895

99-
Update the configuration for this account by editing the `configs/root.tfvar` file.
96+
Update the configuration for this account by editing the `configs/master.tfvar` file.
10097

10198
Then to get started, run:
10299

@@ -105,7 +102,7 @@ make root
105102
```
106103

107104
**NOTE:** We need to know each account's `AWS_ACCOUNT_ID` for Step 2.
108-
**NOTE:** Sometimes provisioning of the `account` module fails due to rate limiting by AWS on creating subaccounts. If this happens, just run `make root/provision` to retry. If that works, just continue on to step 2, once it completes.
105+
**NOTE:** Sometimes provisioning of the `account` module fails due to rate limiting by AWS on creating sub-accounts. If this happens, just run `make root/provision` to retry. If that works, just continue on with step 2, once it completes.
109106

110107
<details>
111108
<summary>Here's what that roughly looks like (but entirely automated). </summary>
@@ -121,7 +118,7 @@ make root
121118

122119
### 2. Provision Subaccounts
123120

124-
Subaccounts are created by the root account, but are ultimately provisioned using the subaccount containers.
121+
Subaccounts are created by the master account, but are ultimately provisioned using the subaccount containers.
125122

126123
Update the configuration for all the child accounts by editing the `configs/$stage.tfvar` file (replace `$stage` with the name of the account).
127124

@@ -158,8 +155,8 @@ make finalize
158155
<summary>Here's what that roughly looks like (but entirely automated).</summary>
159156

160157
1. Re-use the docker images from phase (1) and phase (2).
161-
2. Update DNS so that root account delegates DNS zones to the child accounts.
162-
3. Enable cloudtrail log forwarding to audit account.
158+
2. Update DNS so that `master` account delegates DNS zones to the child accounts.
159+
3. Enable cloudtrail log forwarding to `audit` account.
163160

164161
</details>
165162

@@ -171,17 +168,15 @@ At this point, you have everything you need to start terraforming your way to su
171168

172169
All of your account configurations are currently in `repos/`
173170

174-
- [ ] Commit the changes in `repos/`. Open Pull Requests.
171+
- [ ] Commit all the changes made. Open Pull Requests.
175172
- [ ] Ensure that the name servers for the service discovery domain (e.g. `ourcompany.co`) have been configured with your domain registrar (e.g. GoDaddy).
176-
- [ ] Delete your root account credentials. They are no longer needed and should not be used. Instead use the created IAM users.
173+
- [ ] Delete your master account credentials. They are no longer needed and should not be used. Instead, use the created IAM users.
177174
- [ ] Request limits for EC2 instances to be raised in each account corresponding to the region you will be operating in.
178175
- [ ] Set the child account's credentials. To do this, issue a password reset using the child account's email address. Login and accept the prompts. Setup MFA.
179-
- [ ] Ensure you have MFA setup on your root account.
176+
- [ ] Ensure you have MFA setup on your master account.
180177
- [ ] Consider adding some other capabilities from our service catalog.
181178
- [ ] Create your own [`terraform-root-modules`](https://github.com/cloudposse/terraform-root-modules) service catalog for your organization.
182179

183-
**NOTE:** _This_ repo can be deleted once you're all done and pushed your changes in the `repos/` directory to GitHub. The rest of your development should happen inside your infrastructure repos.
184-
185180
## Getting Help
186181

187182
Did you get stuck? Find us on [slack](https://sweetops.cloudposse.com) in the `#geodesic` channel.

codefresh/build.yml

Lines changed: 0 additions & 95 deletions
This file was deleted.

configs/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

configs/audit.tfvars

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)