Skip to content

Commit 19cb916

Browse files
committed
DOPS-101 Add bootstrap and backend details to terrform project
Updated README to point to bootstrap project for setting up terraform backend. Updated main terraform project's backend with the S3 and DynamoDB tables generated using default bootstrap values.
1 parent 7e20c4e commit 19cb916

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

README.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ See the branch [demo-20180619](https://github.com/ModusCreateOrg/devops-infra-de
1313
See the branch [demo-20180926](https://github.com/ModusCreateOrg/devops-infra-demo/tree/demo-20180926) for the code for the demo for the [Continuous Delivery NYC talk _Managing Expensive or Destructive Operations in Jenkins CI_](https://www.meetup.com/ContinuousDeliveryNYC/events/254036209/). Slides from this presentation are on [SlideShare](https://www.slideshare.net/RichardBullingtonMcG/managing-expensive-or-destructive-operations-in-jenkins-ci).
1414

1515
See the branch [demo-20181205](https://github.com/ModusCreateOrg/devops-infra-demo/tree/demo-20181205) for the code for the demo for the [Ansible NYC talk _Ansible Image Bakeries: Best Practices & Pitfalls_](https://www.meetup.com/Ansible-NYC/events/256728741/). Slides from this presentation are on [SlideShare](https://www.slideshare.net/RichardBullingtonMcG/ansible-image-bakeries-best-practices-and-pitfalls).
16-
16+
1717
See the branch [demo-20190130](https://github.com/ModusCreateOrg/devops-infra-demo/tree/demo-20190130) for the code for the demo for the [Big Apple DevOps talk _Monitoring and Alerting as code with Terraform and New Relic_](https://www.meetup.com/Big-Apple-DevOps/events/257744262/). Slides from this presentation are on [Slideshare](https://www.slideshare.net/RichardBullingtonMcG/monitoring-and-alerting-as-code-with-terraform-and-new-relic).
18-
18+
1919
See the branch [demo-20191109](https://github.com/ModusCreateOrg/devops-infra-demo/tree/demo-20191109) for the code for the demo for the [BSidesCT 2019 talk _Extensible DevSecOps pipelines with Jenkins, Docker, Terraform, and a kitchen sink full of scanners_](https://bsidesct.org/schedule/). Slides from this presentation are on
2020
[Slideshare](https://www.slideshare.net/RichardBullingtonMcG/extensible-dev-secops-pipelines-with-jenkins-docker-terraform-and-a-kitchen-sink-full-of-scanners)
21-
21+
2222
Instructions
2323
------------
2424

2525
To run the demo end to end, you will need:
26-
26+
2727
* [AWS Account](https://aws.amazon.com/)
2828
* [Google Cloud Account](https://cloud.google.com/)
2929
* [Docker](https://docker.com/) (tested with 18.05.0-ce)
@@ -33,7 +33,7 @@ Instructions
3333

3434
Optionally, you can use Vagrant to test ansible playbooks locally and Jenkins to orchestrate creation of AMIs in conjunction with GitHub branches and pull requests.
3535

36-
You will also need to set a few environment variables. The method of doing so will vary from platform to platform.
36+
You will also need to set a few environment variables. The method of doing so will vary from platform to platform.
3737

3838
```
3939
AWS_PROFILE
@@ -74,20 +74,14 @@ Install [Vagrant](https://www.vagrantup.com/). Change directory into the root of
7474

7575
### Terraform
7676

77-
This Terraform setup stores its state in Amazon S3 and uses DynamoDB for locking. There is a bit of setup required to bootstrap that configuration. You can use [this repository](https://github.com/monterail/terraform-bootstrap-example) to use Terraform to do that bootstrap process. The `backend.tfvars` file in that repo should be modified as follows to work with this project:
77+
This Terraform setup stores its state in Amazon S3 and uses DynamoDB for locking. There is a bit of setup required to bootstrap the configuration. Check out `./terraform/bootstrap/README.md` to setup the resources required for backend.
78+
79+
If you override the default input values (by CLI or using a `.tfvars` file) for bootstrapping, please update the `terraform.backend` section in `./terraform/terraform.tf` to reflect that.
7880

79-
(Replace us-east-1 and XXXXXXXXXXXX with the AWS region and your account ID)
80-
```
81-
bucket = "tf-state.devops-infra-demo.us-east-1.XXXXXXXXXXXX"
82-
dynamodb_table = "TerraformStatelock-devops-infra-demo"
83-
key = "terraform.tfstate"
84-
profile = "terraform"
85-
region = "us-east-1"
86-
```
8781
You'll also need to modify the list of operators who can modify the object in the S3 bucket. Put in the IAM user names of the user into the `setup/variables.tf` file in that project. If your Jenkins instance uses an IAM role to grant access, give it a similar set of permissions to those granted on in the bucket policy to IAM users.
8882

8983
These commands will then set up cloud resources using terraform:
90-
84+
9185
cd terraform
9286
terraform init
9387
terraform get
@@ -112,7 +106,7 @@ The application loads an image from Google storage. To get it loading correctly,
112106

113107
### Auto Scaling Groups
114108

115-
The application in this demo uses an AWS Auto Scaling Group in order to dynamically change the number of servers deployed in response to load. Two policies help guide how many instances are available: a CPU scaling policy that seeks to keep the average CPU load below 40% in the cluster, and a scheduled scaling policy that scales the entire cluster down to 0 instances at 02:00 UTC every night, to minimize the charges should you forget to destroy the cluster. If the cluster is scaled down to 0 instances, you will need to edit the Auto Scaling Group through the console, the CLI, or an API call to set the sizes to non-zero, for example
109+
The application in this demo uses an AWS Auto Scaling Group in order to dynamically change the number of servers deployed in response to load. Two policies help guide how many instances are available: a CPU scaling policy that seeks to keep the average CPU load below 40% in the cluster, and a scheduled scaling policy that scales the entire cluster down to 0 instances at 02:00 UTC every night, to minimize the charges should you forget to destroy the cluster. If the cluster is scaled down to 0 instances, you will need to edit the Auto Scaling Group through the console, the CLI, or an API call to set the sizes to non-zero, for example
116110

117111
### Elastic Load Balancing
118112

terraform/terraform.tf

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
terraform {
2+
#===================================================================
3+
# The S3 bucket and DyanmoDB table used here are created using
4+
# ./bootstrap project. See ./bootstrap/README.md for details.
5+
#===================================================================
26
backend "s3" {
3-
encrypt = true
4-
5-
# We can't specify parameterized config here but if we could it would look like:
6-
# bucket = "tf-state.${project_name}.${aws_region}.${data.aws_caller_identity.current.account_id}"
7-
# dynamodb_table = "TerraformStatelock-${project_name}"
8-
bucket = "my-terraform-bucket"
9-
10-
dynamodb_table = "TerraformStatelock"
7+
bucket = "moduscreate-devops-demo-tf-state-us-east-1"
8+
key = "terraform-state.tfstate"
9+
dynamodb_table = "moduscreate-devops-demo-state-lock"
1110
region = "us-east-1"
12-
key = "terraform.tfstate"
11+
encrypt = "true"
1312
}
1413
}
1514

0 commit comments

Comments
 (0)