Skip to content

aws-samples/aws-apigw-http-api-private--integrations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Configuring private integrations with Amazon API Gateway HTTP APIs

The following provides AWS CloudFormation templates to three Amazon API Gateway HTTP private integration configurations using either an Application Load Balancer (ALB), Network Load Balancer (NLB) or AWS Cloud Map.

A HTTP API route receives a request and uses a VPC Link to encapsulate connections between Amazon API Gateway and its targeted VPC resources. When a VPC link is created, Amazon API Gateway creates and manages the elastic network interfaces for the VPC link in your account. All three HTTP API private integration methods only allow access via a VPC link to targets on an Amazon ECS cluster.

Each template deploys:

  • A base VPC with Public and Private Subnets across 3 Availability Zones.
  • Internet and NAT gateways.
  • Amazon ECS cluster with resources on underlying EC2 instances in Private Subnets.
  • API Gateway VPC link.
  • HTTP API with integration to either an ALB, NLB or AWS Cloud Map.

alb

alb

alb


Getting Started - Pre-requisites.

NOTE: By default your account will only have five elastic IP addresses unless you have requested an increase. As this demo deploys three NAT Gateways, therefore, three elastic IP addresses must be available.

Each template presumes you have already created an ECR Image which is accessible from your account and region. This is required as an initial input parameter. If not, then install docker and create a docker image of a simple http web application listening on port 80. Then push your image to Amazon Elastic Container Registry (ECR).


Deployment.

1-Download a CloudFormation template from the GitHub repository.

2-From your AWS console, navigate to CloudFormation.

3-Create stack, select With new resources (standard).

4-Select upload template, then Choose file.

5-Under Specify stack details provide a unique stack name.

6-After you provide your ECR Image URI, either leave the below default Parameters, or adjust depending on your requirement.

  • InstanceType: Class of EC2 instance used to host containers. Choose t2 for testing, m5 for general purpose, c5 for CPU intensive services, and r5 for memory intensive services.

  • DesiredCapacity: Number of EC2 instances to launch in your ECS cluster.

  • MaxSize: Maximum number of EC2 instances that can be launched in your ECS cluster.

  • ECSAMI: The Amazon Machine Image ID used for the cluster, leave it as the default value to get the latest AMI.

  • ECRImage: Your Amazon ECR Image URI - example: 111122223333.dkr.ecr.eu-west-2.amazonaws.com/demo-app:latest

  • NumberOfTasks: The Number or ECS task to be deployed into your ECS Cluster.

7-Next.

8-For this demo only, you can then accept the defaults for Configure stack options and Advanced options.

9-Next.

10-Finally, before you create the stack, please remember to tick - "I acknowledge that AWS CloudFormation might create IAM resources."


Note:

Please allow a few minutes after deployment for load balancers to register with their targets, this may take slightly longer with an Network Load Balancer. Also, it may take a few minutes for ECS service discovery to register with AWS Cloud Map and for Amazon Route 53 to create a namespace for your service.


Output.

Once deployed, an API Gateway Invoke URL can be found within the Outputs tab in AWS Cloudformation.


License Summary.

This sample code is made available under the MIT-0 license. See the LICENSE file.


About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published