Skip to content

agawanea/terraform_projects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless cross account ALB->PrivateAPI use-case using AWS Lambda, API Gateway, Application Load Balancer, VPC Endpoint

This serverless 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.

Pattern

Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the AWS Pricing page for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.

Requirements

  • Create two AWS accounts if you do not already have, create them and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.
  • AWS CLI installed and configured
  • Git Installed
  • Terraform installed

Deployment Instructions

  1. Create a new directory, navigate to that directory in a terminal and clone the GitHub repository:

    git clone https://github.com/aws-samples/serverless-pattern
    
  2. Change directory to the pattern directory:

    cd public-alb-private-api-terraform
    
  3. From the command line, initialize terraform to to downloads and installs the providers defined in the configuration:

    terraform init
    
  4. From the command line, apply the configuration in the main.tf file:

    terraform apply
    
  5. During the prompts:

    var.custom_domain_name_prefix

    • Enter a value: {enter only your domain name prefix}

    var.domain_name

    • Enter a value: {enter your domain name}

    var.region

    • Enter a value: {enter the region for deployment}
  6. Note the outputs from the deployment process. It contain the full url link which can be used for testing.

Testing

  1. Run the following curl command to invoke the cross account Private Rest API:
curl https://<custom_domain>/<stage-name> -H 'Host:<execute-api-invoke-url>'
  1. Observe the output of the Private API response from the integrated backend Lambda function:
Run the below command 

Cleanup

  1. Change directory to the pattern directory:

    cd serverless-patterns/public-alb-private-api-terraform
    
  2. Delete all created resources

    terraform destroy
  3. During the prompts:

    • Enter all details same as entered during creation.
  4. Confirm all created resources has been deleted

    terraform show

Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: MIT-0

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages