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

Commit 125ce75

Browse files
ostermanaknysh
authored andcommitted
Upgrade readme (#1)
* Upgrade readme * Add missing files * Update README.yaml * Add Dockerfile
1 parent 8e9623c commit 125ce75

12 files changed

+553
-10
lines changed

.dockerignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
**/.terraform
2+
.git
3+
.gitignore
4+
.editorconfig
5+
6+
# Compiled files
7+
*.tfstate
8+
*.tfstate.backup
9+
.terraform.tfstate.lock.info
10+
11+
# Module directory
12+
.terraform/
13+
.idea
14+
*.iml
15+
16+
# Build Harness
17+
.build-harness
18+
build-harness/

.editorconfig

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
# Unix-style newlines with a newline ending every file
5+
[*]
6+
end_of_line = lf
7+
insert_final_newline = true
8+
9+
# Override for Makefile
10+
[{Makefile, makefile, GNUmakefile}]
11+
indent_style = tab
12+
indent_size = 4
13+
14+
[Makefile.*]
15+
indent_style = tab
16+
indent_size = 4
17+
18+
[shell]
19+
indent_style = tab
20+
indent_size = 4
21+
22+
[*.sh]
23+
indent_style = tab
24+
indent_size = 4

.gitignore

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
# Local .terraform directories
2-
**/.terraform/*
3-
4-
# .tfstate files
1+
# Compiled files
52
*.tfstate
6-
*.tfstate.*
3+
*.tfstate.backup
4+
.terraform.tfstate.lock.info
5+
6+
# Module directory
7+
.terraform/
8+
.idea
9+
*.iml
710

8-
# .tfvars files
9-
*.tfvars
11+
# Build Harness
12+
.build-harness
13+
build-harness/

Dockerfile

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
FROM cloudposse/terraform-root-modules:0.4.7 as terraform-root-modules
2+
3+
FROM cloudposse/geodesic:0.11.6
4+
5+
ENV DOCKER_IMAGE="cloudposse/dev.cloudposse.co"
6+
ENV DOCKER_TAG="latest"
7+
8+
# Geodesic banner
9+
ENV BANNER="dev.cloudposse.co"
10+
11+
# AWS Region
12+
ENV AWS_REGION="us-west-2"
13+
14+
# Terraform vars
15+
ENV TF_VAR_region="${AWS_REGION}"
16+
ENV TF_VAR_account_id="838456590850"
17+
ENV TF_VAR_namespace="cpco"
18+
ENV TF_VAR_stage="dev"
19+
ENV TF_VAR_domain_name="dev.cloudposse.co"
20+
ENV TF_VAR_zone_name="dev.cloudposse.co."
21+
22+
# chamber KMS config
23+
ENV CHAMBER_KMS_KEY_ALIAS="alias/${TF_VAR_namespace}-${TF_VAR_stage}-chamber"
24+
25+
# Terraform State Bucket
26+
ENV TF_BUCKET_REGION="${AWS_REGION}"
27+
ENV TF_BUCKET="${TF_VAR_namespace}-${TF_VAR_stage}-terraform-state"
28+
ENV TF_DYNAMODB_TABLE="${TF_VAR_namespace}-${TF_VAR_stage}-terraform-state-lock"
29+
30+
# Default AWS Profile name
31+
ENV AWS_DEFAULT_PROFILE="${TF_VAR_namespace}-${TF_VAR_stage}-admin"
32+
33+
# Copy root modules
34+
COPY --from=terraform-root-modules /aws/tfstate-backend/ /conf/tfstate-backend/
35+
COPY --from=terraform-root-modules /aws/account-dns/ /conf/account-dns/
36+
COPY --from=terraform-root-modules /aws/acm/ /conf/acm/
37+
COPY --from=terraform-root-modules /aws/backing-services/ /conf/backing-services/
38+
COPY --from=terraform-root-modules /aws/chamber/ /conf/chamber/
39+
COPY --from=terraform-root-modules /aws/cloudtrail/ /conf/cloudtrail/
40+
COPY --from=terraform-root-modules /aws/kops/ /conf/kops/
41+
COPY --from=terraform-root-modules /aws/kops-aws-platform/ /conf/kops-aws-platform/
42+
43+
# Filesystem entry for tfstate
44+
RUN s3 fstab '${TF_BUCKET}' '/' '/secrets/tf'
45+
46+
# kops config
47+
ENV KUBERNETES_VERSION="1.9.6"
48+
ENV KOPS_CLUSTER_NAME="us-west-2.dev.cloudposse.co"
49+
ENV KOPS_DNS_ZONE=${KOPS_CLUSTER_NAME}
50+
ENV KOPS_STATE_STORE="s3://${TF_VAR_namespace}-${TF_VAR_stage}-kops-state"
51+
ENV KOPS_STATE_STORE_REGION="us-west-2"
52+
ENV KOPS_AVAILABILITY_ZONES="us-west-2a,us-west-2b,us-west-2c"
53+
ENV KOPS_BASTION_PUBLIC_NAME="bastion"
54+
ENV BASTION_MACHINE_TYPE="t2.medium"
55+
ENV MASTER_MACHINE_TYPE="t2.medium"
56+
ENV NODE_MACHINE_TYPE="t2.medium"
57+
ENV NODE_MAX_SIZE="2"
58+
ENV NODE_MIN_SIZE="2"
59+
60+
# Generate kops manifest
61+
RUN build-kops-manifest
62+
63+
WORKDIR /conf/

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2018 Cloud Posse, LLC
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

Makefile

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export CLUSTER ?= dev.cloudposse.co
2+
export DOCKER_ORG ?= cloudposse
3+
export DOCKER_IMAGE ?= $(DOCKER_ORG)/$(CLUSTER)
4+
export DOCKER_TAG ?= latest
5+
export DOCKER_IMAGE_NAME ?= $(DOCKER_IMAGE):$(DOCKER_TAG)
6+
export DOCKER_BUILD_FLAGS =
7+
export README_DEPS ?= docs/targets.md docs/terraform.md
8+
9+
-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness)
10+
11+
## Initialize build-harness, install deps, build docker container, install wrapper script and run shell
12+
all: init deps build install run
13+
@exit 0
14+
15+
## Install dependencies (if any)
16+
deps:
17+
@exit 0
18+
19+
## Build docker image
20+
build:
21+
@make --no-print-directory docker/build
22+
23+
## Push docker image to registry
24+
push:
25+
docker push $(DOCKER_IMAGE)
26+
27+
## Install wrapper script from geodesic container
28+
install:
29+
@docker run --rm $(DOCKER_IMAGE_NAME) | sudo bash -s $(DOCKER_TAG)
30+
31+
## Start the geodesic shell by calling wrapper script
32+
run:
33+
$(CLUSTER)

README.md

+144-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,144 @@
1-
# dev.cloudposse.co
2-
Example Terraform Reference Architecture for Geodesic Module Development Sandbox Organization in AWS.
1+
<!-- This file was automatically generated by the `build-harness`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->
2+
3+
[![Cloud Posse](https://cloudposse.com/logo-300x69.svg)](https://cloudposse.com)
4+
5+
# dev.cloudposse.co [![Codefresh Build Status](https://g.codefresh.io/api/badges/build?repoOwner=cloudposse&repoName=dev.cloudposse.co&branch=master&pipelineName=dev.cloudposse.co&accountName=cloudposse&type=cf-1)](https://g.codefresh.io/pipelines/dev.cloudposse.co/builds) [![Latest Release](https://img.shields.io/github/release/cloudposse/dev.cloudposse.co.svg)](https://github.com/cloudposse/dev.cloudposse.co/releases) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
6+
7+
8+
Terraform/Kubernetes Reference Infrastructure for Cloud Posse Development Sandbox Organization in AWS.
9+
10+
This account is intended for developers to provision and test their own AWS infrastructure.
11+
12+
__NOTE:__ Before creating the Development infrastructure, you need to provision the [Parent ("Root") Organization](https://github.com/cloudposse/root.cloudposse.co) in AWS (because it creates resources needed for all other accounts). Follow the steps in [README](https://github.com/cloudposse/root.cloudposse.co) first. You need to do it only once.
13+
14+
15+
---
16+
17+
This project is part of our comprehensive ["SweetOps"](https://docs.cloudposse.com) approach towards DevOps.
18+
19+
20+
It's 100% Open Source and licensed under the [APACHE2](LICENSE).
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
## Introduction
31+
32+
We use [geodesic](https://github.com/cloudposse/geodesic) to define and build world-class cloud infrastructures backed by AWS and powered by Kubernetes.
33+
34+
`geodesic` exposes many tools that can be used to define and provision AWS and Kubernetes resources.
35+
36+
Here is the list of tools we use to provision the `dev.cloudposse.co` infrastructure:
37+
38+
* [aws-vault](https://github.com/99designs/aws-vault)
39+
* [chamber](https://github.com/segmentio/chamber)
40+
* [terraform](https://www.terraform.io/)
41+
42+
43+
## Quick Start
44+
45+
46+
### Setup AWS Role
47+
48+
__NOTE:__ You need to do it only once.
49+
50+
Configure AWS profile in `~/.aws/config`. Make sure to change username ([email protected]) to your own.
51+
52+
```bash
53+
[profile cpco-dev-admin]
54+
region=us-west-2
55+
role_arn=arn:aws:iam::590638247571:role/OrganizationAccountAccessRole
56+
mfa_serial=arn:aws:iam::681280261279:mfa/[email protected]
57+
source_profile=cpco
58+
```
59+
60+
### Install and setup aws-vault
61+
62+
__NOTE:__ You need to do it only once.
63+
64+
We use [aws-vault](https://docs.cloudposse.com/tools/aws-vault/) to store IAM credentials in your operating system's secure keystore and then generates temporary credentials from those to expose to your shell and applications.
65+
66+
Install [aws-vault](https://docs.cloudposse.com/tools/aws-vault/) on your local computer first.
67+
68+
On MacOS, you may use `homebrew cask`
69+
70+
```bash
71+
brew cask install aws-vault
72+
```
73+
74+
Then setup your secret credentials for AWS in `aws-vault`
75+
```bash
76+
aws-vault add --backend file cpco
77+
```
78+
79+
__NOTE:__ You should set `AWS_VAULT_BACKEND=file` in your shell rc config (e.g. `~/.bashrc`) so it persists.
80+
81+
For more info, see [aws-vault](https://docs.cloudposse.com/tools/aws-vault/)
82+
83+
84+
## Examples
85+
86+
### Build Docker Image
87+
88+
```
89+
# Initialize the project's build-harness
90+
make init
91+
92+
# Build docker image
93+
make docker/build
94+
```
95+
96+
### Install the wrapper shell
97+
```bash
98+
make install
99+
```
100+
101+
### Run the shell
102+
```bash
103+
dev.cloudposse.co
104+
```
105+
106+
### Login to AWS with your MFA device
107+
```bash
108+
assume-role
109+
```
110+
111+
__NOTE:__ Before provisioning AWS resources with Terraform, you need to create `tfstate-backend` first (S3 bucket to store Terraform state and DynamoDB table for state locking).
112+
113+
Follow the steps in this [README](https://github.com/cloudposse/terraform-root-modules/blob/master/aws/tfstate-backend/). You need to do it only once.
114+
115+
After `tfstate-backend` has been provisioned, follow the rest of the instructions in the order shown below.
116+
117+
118+
### Provision `dns` with Terraform
119+
120+
Change directory to `dns` folder
121+
```bash
122+
cd /conf/dns
123+
```
124+
125+
Run Terraform
126+
```bash
127+
init-terraform
128+
terraform plan
129+
terraform apply
130+
```
131+
132+
For more info, see [geodesic-with-terraform](https://docs.cloudposse.com/geodesic/module/with-terraform/)
133+
134+
### Provision `cloudtrail` with Terraform
135+
136+
```bash
137+
cd /conf/cloudtrail
138+
init-terraform
139+
terraform plan
140+
terraform apply
141+
```
142+
143+
144+

0 commit comments

Comments
 (0)