Skip to content

Commit a57e4e0

Browse files
authored
Merge pull request #19 from commitdev/update-readme
Update the readme with some steps, make worker ami a templated value
2 parents 3c83a24 + 5e38fd1 commit a57e4e0

File tree

4 files changed

+41
-20
lines changed

4 files changed

+41
-20
lines changed

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ ENV ?= staging
22

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

5-
apply-remote-state:
5+
apply-remote-state:
66
pushd terraform/bootstrap/remote-state; \
77
terraform init; \
8-
terraform apply
8+
terraform apply -var "environment=$(ENV)"
99

10-
apply-secrets:
10+
apply-secrets:
1111
pushd terraform/bootstrap/secrets; \
1212
terraform init; \
1313
terraform apply
1414

15-
apply-env:
15+
apply-env:
1616
pushd terraform/environments/$(ENV); \
1717
terraform init; \
1818
terraform apply
@@ -26,15 +26,15 @@ update-k8s-conf: eks --region <% index .Params `region` %> update-kubeconfig --n
2626

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

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

33-
teardown-secrets:
33+
teardown-secrets:
3434
pushd terraform/bootstrap/secrets; \
3535
terraform destroy -auto-approve;
3636

37-
teardown-env:
37+
teardown-env:
3838
pushd terraform/environments/$(ENV); \
3939
terraform destroy -auto-approve;
4040

README.md

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,53 @@ diagram](./docs/architecture-overview.svg).
88
**Prerequisites**
99
- Terraform installed
1010
- Kubectl installed
11+
- Wget installed
1112
- A valid AWS account
1213
- [Set up the AWS CLI](https://docs.aws.amazon.com/polly/latest/dg/setup-aws-cli.html)
1314
- [A domain registered with Route53](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/domain-register.html)
1415
- 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`
1516

1617
## Getting Started
1718

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

25-
### ⚠️ Edits Required
26-
27-
This repository requires post-template configuration edits to the AMI depending
28-
on the region you chose. To find the appropriate AMI for your region you can use
29-
the following snippet:
26+
To generate the templates you will need to provide some values to fill in.
3027

28+
First get the AMI for your region:
3129
```shell
3230
$ REGION=us-east-1
3331
$ aws ssm get-parameters \
3432
--names /aws/service/eks/optimized-ami/1.15/amazon-linux-2/recommended/image_id \
3533
--region $REGION \
36-
--query "Parameters[0].Value" | cat
34+
--query "Parameters[0].Value"
35+
```
36+
37+
Then get the aws account id:
38+
```shell
39+
aws sts get-caller-identity --query "Account"
40+
```
41+
42+
Then create a `config.yml` file and fill in the appropriate values:
43+
44+
```yaml
45+
name: my-project
46+
47+
params:
48+
region: us-east-1
49+
accountId: <from above>
50+
kubeWorkerAMI: ami-<from above>
51+
productionHost: domain.com
52+
stagingHost: domain-staging.com
53+
```
54+
55+
And run `stack`:
56+
```shell
57+
$ stack -config config.yml commit0-aws-eks-stack/ my-project-infrastructure/
3758
```
3859

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

4970
```shell
50-
$ aws eks update-kubeconfig --name <cluster-name> --region us-west-2
71+
$ aws eks update-kubeconfig --name <cluster-name> --region us-east-1
5172
```
5273

5374
Then talk to Bill.

terraform/environments/production/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module "production" {
2929

3030
# EKS-Optimized AMI for your region: https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html
3131
# 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
32-
eks_worker_ami = "ami-0e710550577202c55"
32+
eks_worker_ami = "<% index .Params `kubeWorkerAMI` %>"
3333

3434
# Hosting configuration
3535
s3_hosting_buckets = [

terraform/environments/staging/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module "staging" {
2929

3030
# EKS-Optimized AMI for your region: https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html
3131
# 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
32-
eks_worker_ami = "ami-0e710550577202c55"
32+
eks_worker_ami = "<% index .Params `kubeWorkerAMI` %>"
3333

3434
# Hosting configuration
3535
s3_hosting_buckets = [

0 commit comments

Comments
 (0)