Select your cookie preferences

We use cookies and similar tools to enhance your experience, provide our services, deliver relevant advertising, and make improvements. Approved third parties also use these tools to help us deliver advertising and provide certain site features.

Application Load Balancer to API Gateway Private Rest API

Created with SnapAccount AAccount BApplication Load BalancerVPC EndpointAPI GatewayAWS Lambda

Cross Account Private API Access via Public Application Load Balancer.

This sample pattern allows users from one account to access their Private REST APIs present in another account over the internet.
This facilitates abstraction of network resources (like load balancers, virtual private clouds, endpoints) & application resources (like lambda, api gateway) into separate individual management accounts.

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.11.0"
    }
  }
}

variable "region" {}
variable "custom_domain_name_prefix" {}
variable "domain_name" {}

# Configure the AWS Provider
provider "aws" {
 profile = "default"
 region  = "${var.region}"
}
 
#Production account
provider "aws" {
 profile = "crossaccount"
 region  = "${var.region}"
 alias   = "crossaccount"
}

data "aws_caller_identity" "current" {
  provider = aws.crossaccount
}

< Back to all patterns


GitHub icon Visit the GitHub repo for this pattern.

Download

git clone https://github.com/aws-samples/serverless-patterns/ cd serverless-patterns/public-alb-private-api-terraform

Deploy

terraform initterraform apply


Testing

See the repo for additional testing notes.

Cleanup

1. Delete the stack: terraform destroy.
2. Confirm the stack has been deleted: terraform show

Abhishek Agawane

Presented by Abhishek Agawane

I am a Cloud Support Engineer (Serverless) at AWS

Follow on LinkedIn