{"id":15716114,"url":"https://github.com/nossbigg/aws-lambda-edge-redirect-example","last_synced_at":"2025-08-01T08:04:54.602Z","repository":{"id":91671783,"uuid":"285229324","full_name":"nossbigg/aws-lambda-edge-redirect-example","owner":"nossbigg","description":"Barebones example of doing URL redirects + request country infromation using AWS Lambda@Edge and Terraform","archived":false,"fork":false,"pushed_at":"2020-10-06T08:38:50.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-05T23:53:00.512Z","etag":null,"topics":["aws","lambda-edge","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nossbigg.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-05T08:34:52.000Z","updated_at":"2020-10-06T08:38:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"f297dbfd-9e59-40f2-a7b0-f7cc07e88eab","html_url":"https://github.com/nossbigg/aws-lambda-edge-redirect-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nossbigg%2Faws-lambda-edge-redirect-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nossbigg%2Faws-lambda-edge-redirect-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nossbigg%2Faws-lambda-edge-redirect-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nossbigg%2Faws-lambda-edge-redirect-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nossbigg","download_url":"https://codeload.github.com/nossbigg/aws-lambda-edge-redirect-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246379378,"owners_count":20767694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","lambda-edge","terraform"],"created_at":"2024-10-03T21:44:06.475Z","updated_at":"2025-03-30T20:43:20.251Z","avatar_url":"https://github.com/nossbigg.png","language":"HCL","readme":"# aws-lambda-edge-redirect-example\n\nThis 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.\n\n## Prerequisites\n\n### 1. AWS\n\n- AWS CLI \n  - Install CLI: [guide](https://aws.amazon.com/cli/)\n  - Configure CLI with API Keys and Profile: [guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)\n  - Change `provider.profile` in `terraform/provider.tf` to match the name of your own profile\n\n### 2. Terraform\n\n- Terraform CLI\n  - Install CLI: [guide](https://learn.hashicorp.com/tutorials/terraform/install-cli)\n  - Configure with API Token: [guide](https://www.terraform.io/docs/commands/login.html)\n- Terraform Organization + Workspace\n  - Create own organization: [guide](https://www.terraform.io/docs/cloud/users-teams-organizations/organizations.html)\n  - Update `organization` value in `terraform/state.tf` to own organization name\n  - Create workspace with name `aws-lambda-edge-redirect-example`: [guide](https://www.terraform.io/docs/cloud/workspaces/creating.html)\n  - Set workspace Execution Mode to `Local`: [guide](https://www.terraform.io/docs/cloud/workspaces/settings.html)\n\n## Usage\n\n- (Optional) You can change the URL to redirect to by changing the `redirectUrl` declared in `lambda_logic/lambda_cf.js`\n- Go to `terraform/` and do `terraform apply` to provision the Lambda@Edge infrastructure\n- Use `aws cloudfront list-distributions` to list all existing distributions\n- Copy the `Item.DomainName` of the newly-provisioned CloudFront distribution\n- Make a request to the URL using a browser\n- You should be redirected to a webpage with a `countryCode` query parameter appended to the end of the URL\n\n## References\n\n- [Customizing Content at the Edge with Lambda@Edge - Amazon CloudFront](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-at-the-edge.html)\n- [Setting IAM Permissions and Roles for Lambda@Edge - Amazon CloudFront](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-edge-permissions.html)\n- [lambda_function | Resources | hashicorp/aws | Terraform Registry](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function)\n- [cloudfront_distribution | Resources | hashicorp/aws | Terraform Registry](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution)\n- [AWS Policy Generator](https://awspolicygen.s3.amazonaws.com/policygen.html)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnossbigg%2Faws-lambda-edge-redirect-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnossbigg%2Faws-lambda-edge-redirect-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnossbigg%2Faws-lambda-edge-redirect-example/lists"}