Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ ENV ?= staging

apply: apply-remote-state apply-secrets apply-env apply-k8s-utils

apply-remote-state:
apply-remote-state:
pushd terraform/bootstrap/remote-state; \
terraform init; \
terraform apply
terraform apply -var "environment=$(ENV)"

apply-secrets:
apply-secrets:
pushd terraform/bootstrap/secrets; \
terraform init; \
terraform apply

apply-env:
apply-env:
pushd terraform/environments/$(ENV); \
terraform init; \
terraform apply
Expand All @@ -24,15 +24,15 @@ apply-k8s-utils:

teardown: teardown-k8s-utils teardown-env teardown-secrets teardown-remote-state

teardown-remote-state:
teardown-remote-state:
pushd terraform/bootstrap/remote-state; \
terraform destroy;
terraform destroy -auto-approve -var "environment=$(ENV)";

teardown-secrets:
teardown-secrets:
pushd terraform/bootstrap/secrets; \
terraform destroy -auto-approve;

teardown-env:
teardown-env:
pushd terraform/environments/$(ENV); \
terraform destroy -auto-approve;

Expand Down
41 changes: 31 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,53 @@ diagram](./docs/architecture-overview.svg).
**Prerequisites**
- Terraform installed
- Kubectl installed
- Wget installed
- A valid AWS account
- [Set up the AWS CLI](https://docs.aws.amazon.com/polly/latest/dg/setup-aws-cli.html)
- [A domain registered with Route53](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/domain-register.html)
- Note: if you want to use different domain per environment (staging/poduction), you need to have multiple hosted zones. The available zones in Route53 can be found by running this command. `aws route53 list-hosted-zones`

## Getting Started

This is meant to be used with commit0 and not directly. See
the [commit0](https://github.com/commitdev/commit0) repository for more
information. The commit0 tool will parse through configuration and fill in any
This is meant to be used with the commit0 `stack` tool and not directly. See
the [stack](https://github.com/commitdev/stack) repository for more
information. The tool will parse through configuration and fill in any
template variables which need to be encoded into the terraform configuration.
Once that is done you'll have a directory containing the contents of this
repository minus the `.git` directory.

### ⚠️ Edits Required

This repository requires post-template configuration edits to the AMI depending
on the region you chose. To find the appropriate AMI for your region you can use
the following snippet:
To generate the templates you will need to provide some values to fill in.

First get the AMI for your region:
```shell
$ REGION=us-east-1
$ aws ssm get-parameters \
--names /aws/service/eks/optimized-ami/1.15/amazon-linux-2/recommended/image_id \
--region $REGION \
--query "Parameters[0].Value" | cat
--query "Parameters[0].Value"
```

Then get the aws account id:
```shell
aws sts get-caller-identity --query "Account"
```

Then create a `config.yml` file and fill in the appropriate values:

```yaml
name: my-project

params:
region: us-east-1
accountId: <from above>
kubeWorkerAMI: ami-<from above>
productionHost: domain.com
stagingHost: domain-staging.com
```

And run `stack`:
```shell
$ stack -config config.yml commit0-aws-eks-stack/ my-project-infrastructure/
```

### Apply Configuration
Expand All @@ -47,7 +68,7 @@ $ make ENV=<environment>
Configure your k8s context

```shell
$ aws eks update-kubeconfig --name <cluster-name> --region us-west-2
$ aws eks update-kubeconfig --name <cluster-name> --region us-east-1
```

Then talk to Bill.
Expand Down
2 changes: 1 addition & 1 deletion terraform/environments/production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module "production" {

# EKS-Optimized AMI for your region: https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html
# https://us-east-1.console.aws.amazon.com/systems-manager/parameters/%252Faws%252Fservice%252Feks%252Foptimized-ami%252F1.15%252Famazon-linux-2%252Frecommended%252Fimage_id/description?region=us-east-1
eks_worker_ami = "ami-0e710550577202c55"
eks_worker_ami = "<% index .Params `kubeWorkerAMI` %>"

# Hosting configuration
s3_hosting_buckets = [
Expand Down
2 changes: 1 addition & 1 deletion terraform/environments/staging/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module "staging" {

# EKS-Optimized AMI for your region: https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html
# https://us-east-1.console.aws.amazon.com/systems-manager/parameters/%252Faws%252Fservice%252Feks%252Foptimized-ami%252F1.15%252Famazon-linux-2%252Frecommended%252Fimage_id/description?region=us-east-1
eks_worker_ami = "ami-0e710550577202c55"
eks_worker_ami = "<% index .Params `kubeWorkerAMI` %>"

# Hosting configuration
s3_hosting_buckets = [
Expand Down