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
redirectUrldeclared inlambda_logic/lambda_cf.js - Go to
terraform/and doterraform applyto provision the Lambda@Edge infrastructure - Use
aws cloudfront list-distributionsto list all existing distributions - Copy the
Item.DomainNameof the newly-provisioned CloudFront distribution - Make a request to the URL using a browser
- You should be redirected to a webpage with a
countryCodequery parameter appended to the end of the URL