
Give every GitHub pull request its own live preview URL on a Lambda Web Function endpoint, updated on each push and deleted on close.
pr-<number>, comments the URL on the pull request, updates the same URL on every push and deletes the endpoint when the pull request closes. Merging to main deploys the prod endpoint.Disabled auto-deployment keeps serving the revision that you point it at. Every endpoint in this pattern uses Disabled: with the default LatestRevision, production would serve the code of the last pull request that was pushed.pr-* endpoints and can pass only a separate preview execution role, so pull request code cannot touch the production endpoint or run with production permissions. The preview role cannot delete revisions either: the Production workflow deletes the preview revisions that no endpoint routes to.git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-web-pr-previews/nodejs/samGet your repository's OIDC subject prefix with gh api repos/my-org/my-repo/actions/oidc/customization/sub --jq .sub_claim_prefix.Deploy the stack: sam deploy --stack-name lambda-web-pr-previews --region us-east-1 --capabilities CAPABILITY_IAM --parameter-overrides GitHubSubjectPrefix=<prefix>.Deploy production: AWS_REGION=us-east-1 scripts/deploy.sh production. Then copy src, scripts and .github into your repository and set the repository variables described in the GitHub repo.AWS_REGION=us-east-1 scripts/deploy.sh preview 1, or open a pull request in your repository. See the GitHub repo for detailed testing instructions.AWS_REGION=us-east-1 scripts/deploy.sh destroy.sam delete --stack-name lambda-web-pr-previews --region us-east-1 --no-prompts.