aws / aws/serverless-application-model

How to configure different APIGateway endpoints for lambda versions $LATEST and live AutoPublishAlias

Open
#602 1 comment 1 reaction 0 assignees View on GitHub
area/resource/function maintainer/need-response
Dominant language
Python
Stars
9.6k
Forks
2.5k
Avg merge
1d 11h
Merged PRs (30d)
7

Description

I'm using SAM with AutoPublishAlias [safe lambda deployments](https://awslabs.github.io/serverless-application-model/safe_lambda_deployments.html). However, in the Pre-traffic hook, I'd like to run some initial validation tests by invoking the latest [unvalidated] lambda version through an AWS API Gateway endpoint that's different from the endpoint that points to stable lambda version.

In my case, it's quite challenging to call the lambda function directly by by-passing APIGateway in the pre-traffic hook because the lambda function includes whitelisting and other logic that requires values set by [API Gateway proxy integration](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-set-up-simple-proxy.html
). Ideally, I'd like to have 2 API gateway endpoints that always point to the live & latest versions of the lambda function as follows:

`/api/resource` -> lambdaFunction:**live**

`/api/latest_resource` -> lambdaFunction:**$LATEST**

This way, the pre-traffic hook can always use `/api/latest_resource` while customers use `/api/resource`. So far, I've not been able to figure out a way to configure this in SAM [AWS::Serverless::Function](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction) or [AWS::Severless::Api](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessapi).

Does anyone have an example or idea of how to configure this?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.