Skip to content

Integrates AWS HTTP API Gateway with AWS ECS by VPC Link - A less expensive alternative to ALB for ECS-based workloads in dev environments.

License

Notifications You must be signed in to change notification settings

wheatstalk/cdk-apigatewayv2-ecs

Repository files navigation

ECS Service Discovery Integration

This project provides an AWS HTTP API Gateway integration to your ECS service by VPC Link.

See: Cheap serverless containers using API Gateway

Usage

declare const cluster: aws_ecs.Cluster;
declare const taskDefinition: aws_ecs.FargateTaskDefinition;

// Create your ECS service
const service = new aws_ecs.FargateService(stack, 'Service', {
  cluster,
  taskDefinition,
  // Enable CloudMap service discovery
  cloudMapOptions: {
    name: 'some-service',
    // Ensure that you use SRV-based records
    dnsRecordType: aws_servicediscovery.DnsRecordType.SRV,
  },
})

new aws_apigatewayv2.HttpApi(stack, 'HttpApi', {
  // Connect the HTTP API to your ECS service
  defaultIntegration: new EcsServiceDiscoveryIntegration('Nginx', {
    service,
  }),
});

About

Integrates AWS HTTP API Gateway with AWS ECS by VPC Link - A less expensive alternative to ALB for ECS-based workloads in dev environments.

Resources

License

Stars

Watchers

Forks

Packages

No packages published