This is the working github repository for the "Learning Live with AWS & HashiCorp" series. We'll discuss the foundations of a microservices architecture, the problem space it solves, where service mesh fits into all of this, and then begin from scratch - setting up a Terraform project, creating a Virtual Private Cloud (VPC), and explaining all of the concepts along the way.
This repo will be updated after each episode!
This repo is split into branches, each representing a part in the series:
- Part 1 - Setting up the Terraform project and creating a VPC
- Part 2 - Creating your first containerized microservice on Amazon ECS with Terraform
- Part 3 - Extending your application with private microservices
- Part 4 - Introducing a Service Mesh with Consul
- Part 5 - Setting Up Your Service Mesh Servers
- Part 6 - Connecting Amazon ECS Services to Consul Servers
- Part-7 (this branch) - Collaboration and CI/CD on Amazon ECS with Terraform
Our first section of episodes will work towards building out the following architecture:
The second section of episodes will work towards refactoring the first section's architecture into using a Service Mesh.
-
Have an AWS Account.
-
Install HashiCorp Terraform.
-
Have the AWS CLI Installed.
-
Create an AWS IAM User with Admin or Power User Permissions.
- this user will only be used locally
- Configure the AWS CLI with the IAM User from Step 4.
- Terraform will read your credentials via the AWS CLI
- Other Authentication Methods with AWS and Terraform
-
Clone this repo to an empty directory.
-
Run
terraform plan
to see what resources will be created. -
Run
terraform apply
to create the infrastructure on AWS! -
Open your Consul Server's Load Balancer (output as
consul_server_endpoint
). -
Run
bash scripts/post-apply.sh
and follow the instructions OR open your terraform statefile and copy your Consul Bootstrap Token. Use this to Login to the Consul UI.
- It may take a few moments for all of the services to come on line.
-
Click on Services in the side navigation.
-
Select our "Client" service and then click on the Topology tab.
-
Find the red arrow lines between the client service and the fruits / vegetables services. Click on one of the red arrows to reveal a dialogue box that will ask if you'd like to create an intention. Click Create.
-
Navigate to your Client Application Load Balancer (output as
client_alb_dns
) to confirm that everything is working.
- It may take a few moments for the new intentions to be recognized.
- Run
terraform destroy
when you're done to get rid of the infrastructure.
Part-7 of this series, which the main
git branch is tied to, sets up our infrastructure on Terraform Cloud instead of running things locally. You'll need to follow the below steps to get it up and running.
The below instructions point to generalized documentation and learn guides in the correct order. For exact instructions using this code base, please see Episode 7 of the series where we cover it.
-
Fork this Repository.
As shown in Episode 7, we can also use Terraform to manage our live Consul Cluster deployed by this code.
The below instructions point to generalized documentation and learn guides in the correct order. For exact instructions using this code base, please see Episode 7 of the series where we cover it.
-
Fork the Consul Configuration Repo
tfc_organization
is the name of your Terraform Cloud Organizationtfc_workspace_tag
is the tag you'd like to organize all of these related project undertfc_workspace
should be the name of the workspace that deployed the consul clusterconsul_token
is theconsul_bootstrap_token
output from the workspace that deployed the consul cluster
Guarding Your TFC Workspaces With HashiCorp Sentinel
We can also insert an addition step between the terraform plan
and terraform apply
phases that checks our code, plan, statefile, and run data using HashiCorp Sentinel.
The below instructions point to generalized documentation and learn guides in the correct order. For exact instructions using this code base, please see Episode 7 of the series where we cover it.
-
Fork the Sentinel Policy Repo
-
Head to Settings in your Terraform Cloud console
-
Click on Policy Sets in the side navigation bar
-
Click on Connect a new policy set in the Policy Sets screen
-
Follow the Connect a Policy Set step-by-step
-
Name the policy set whatever you'd like
-
Under the Workspaces area, select the specific workspaces you'd like this policy to guard.
-
Click Connect policy set
-
Optionally trigger a run in any of your workspaces to view the policy in action.
Reach out to either Jenna Pederson or J. Cole Morrison. Also, feel free to leave any issues you run into on this Github Repo!