cdktf / ecs-microservices-cdktf

Testing Infrastructure as Code with the CDK for Terraform (fork of https://github.com/jcolemorrison/ecs-microservices-cdktf)

Home Page:https://www.youtube.com/watch?v=kcmq5SvjVVM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AWS ECS Microservices with CDK for Terraform

This repository was created for demo purposes and will not be kept up-to-date with future releases of CDK for Terraform (CDKTF); as such, it has been archived and is no longer supported in any way by HashiCorp. You are welcome to try out the archived version of the code in this example project, but there are no guarantees that it will continue to work with newer versions of CDKTF. We do not recommend directly using this sample code in production projects without extensive testing, and HashiCorp disclaims any and all liability resulting from use of this code.


This project creates a microservice architecture on AWS ECS Fargate using the CDK for Terraform. It seeks to follow a familiar pattern used by vanilla Terraform projects - flat file structure, declarative paradigm, and simplicity.

Note: The architecture mentions DataDog for monitoring which was removed from this example for simplicity reasons – you can find this in the source repository.

The Architecture

ECS Microservices CDKTF ECS Microservices CDKTF-AWS

All services use Fake Service as placeholders. You can swap them out with your own containerized services. You will need to change around port configurations and security groups to afford your applications' needs.

Getting Started

For this you'll need 4 things:

  • AWS Account and Credentials
  • Terraform
  • Terraform Cloud Account
  • Node.js
  • CDKTF

Instructions below:

1. AWS Account and Credentials

AWS is used to host the infrastructure. Surprise.

  1. Have an AWS Account.

  2. Have the AWS CLI Installed.

  3. Create an AWS IAM User with Admin or Power User Permissions.

  • this user will only be used locally
  1. Configure the AWS CLI with the IAM User from Step 4.

2. Terraform, Terraform Cloud, and the CDK for Terraform

Terraform and CDKT for Terraform are used to provision the infrastructure. Terraform Cloud (free) is used to manage your state.

  1. Install HashiCorp Terraform.

  2. Install Node.js.

  3. Install the CDK for Terraform

  4. Sign up for Terraform Cloud

  • yo its free for 5 team members
  1. Create a Terraform Cloud Organization

  2. Log in to Terraform Cloud from the CLI

  • this will set the credentials locally for the CDKTF to work with it
  1. Export your Terraform Cloud Organization name as an environment variable:
# Don't forget to set this!  Used in main.ts @line 153
$ export CDKTF_ECS_TFC_ORGANIZATION="your TFC organization name"

Deploying the Project

  1. Clone this repo.

  2. Run npm i to install all dependencies.

  3. Run cdktf synth to ensure no errors are occuring.

  4. Run cdktf deploy and accept the deployment.

  5. Grab the URL from your client_service_endpoint Terraform Output and visit it to see the application.

  6. Optionally add /ui to your client_service_endpoint to see a visualization of your services.


About

Testing Infrastructure as Code with the CDK for Terraform (fork of https://github.com/jcolemorrison/ecs-microservices-cdktf)

https://www.youtube.com/watch?v=kcmq5SvjVVM

License:Mozilla Public License 2.0


Languages

Language:TypeScript 78.8%Language:JavaScript 16.3%Language:HCL 2.9%Language:Shell 2.0%