Amazon API Gateway HTTP API to Amazon ECS on AWS Fargate through AWS Cloud Map

Client SigV4 → Amazon API Gateway HTTP API → AWS Cloud Map Service discovery → AWS Fargate ECS tasks

An Amazon API Gateway HTTP API reaches Amazon ECS on AWS Fargate tasks through a VPC link and an AWS Cloud Map service, with no load balancer.

An Amazon API Gateway HTTP API with AWS Identity and Access Management (IAM) authorization uses a VPC link V2 and an AWS Cloud Map service as its private integration target. API Gateway looks up the IP address and port of the healthy instances with DiscoverInstances and distributes requests across them.
The Amazon ECS service registers each AWS Fargate task in AWS Cloud Map with an SRV record, which carries the port that an A record does not. No load balancer sits between API Gateway and the tasks.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/apigw-cloudmap-fargate/typescript/cdk

Deploy

npm installnpx cdk bootstrapnpx cdk deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

npx cdk destroy

Created by:

Nithin Chandran R

Nithin Chandran R

Technical Account Manager at AWS