This repository is a barebones example of using Terraform to provision an AWS Lambda@Edge deployment that performs a redirect and adds CloudFront-Viewer-Country
to the redirected URL.
- AWS CLI
- Terraform CLI
- Terraform Organization + Workspace
- (Optional) You can change the URL to redirect to by changing the
redirectUrl
declared inlambda_logic/lambda_cf.js
- Go to
terraform/
and doterraform apply
to provision the Lambda@Edge infrastructure - Use
aws cloudfront list-distributions
to list all existing distributions - Copy the
Item.DomainName
of the newly-provisioned CloudFront distribution - Make a request to the URL using a browser
- You should be redirected to a webpage with a
countryCode
query parameter appended to the end of the URL