This example project demonstrates how two services can communicate with each other using public and private ALBs. The following diagram illustrates the high-level architecture.
┌────────────┐
│ │
│ │
│ ALB │
│ Public │
│ │
└────────────┘
│
│
┌─Service─▼────────┐
│ ┌──────────────┐ │
│ │ │ │
│ │ │ │
│ │ app │ │
│ │ container │ │
│ │ │ │
│ │ │ │
│ └──────────────┘ │
└──────────────────┘
│
│
┌──────▼─────┐
│ │
│ │
│ ALB │
│ Private │
│ │
└────────────┘
│
│
┌─Service─▼────────┐
│ ┌──────────────┐ │
│ │ │ │
│ │ │ │
│ │ app │ │
│ │ container │ │
│ │ │ │
│ │ │ │
│ └──────────────┘ │
└──────────────────┘
- Install Node.js 10.x
- Create an S3 bucket where aws cloudformation package uploads the artifacts.
- Choose a unique bucket name, e.g.
BucketName=cfn-modules-$Name-$Region
- Replace
$Name
with a unique name (e.g. your initials or company name) - Replace
$Region
with your AWS default region (e.g.us-east-1
) - Create the bucket
aws s3 mb s3://$BucketName
- Choose a unique bucket name, e.g.
npm i
aws cloudformation package --template-file example.yml --s3-bucket $BucketName --output-template-file packaged.yml
aws cloudformation deploy --template-file packaged.yml --stack-name fargate-alb-service-to-service-example --capabilities CAPABILITY_IAM
aws cloudformation describe-stacks --stack-name fargate-alb-service-to-service-example --query "Stacks[0].Outputs[?OutputKey=='Url'].OutputValue" --output text
Open the URL in your web browser.
Don't forget to delete the stack once you are done with the demo:
aws cloudformation delete-stack --stack-name fargate-alb-service-to-service-example
Find all modules here: https://www.npmjs.com/org/cfn-modules