Skip to content

guardianproject-ops/terraform-aws-lambdaedge-folder-index

Repository files navigation

terraform-aws-lambdaedge-folder-index

This is a terraform module that deploys a lambda@edge that rewrites origin-requests and routes them to different origins depending on the domain specified in the path.

For example if the lambda is configured with an origin domains list of foobar.com and www.example.org, then requests the following requests would be rewritten

  • /foobar.com/hello/there -> /hello/there (routed to foobar.com origin)
  • /www.example.org/site/feed.xml -> /site/feed.xml (routed to www.example.org origin)
  • /somethingelse.com/page -> 400 invalid origin returned

This project is part of the Guardian Project Ops collection.

Usage

IMPORTANT: The master branch is used in source just as an example. In your code, do not pin to master because there may be breaking changes between releases. Instead pin to the release tag (e.g. ?ref=tags/x.y.z) of one of our latest releases.

module "lambdaedge_folder_index" {
  source = "git::https://gitlab.com/guardianproject-ops/terraform-aws-lambdaedge-folder-index?ref=main"
  context = module.this.context
}

module: lambda-folder-index

This module deploys a lambda@edge that rewrites requests to uris ending in / to /index.html

For example: a request to /foo/bar/ would be rewritten to /foo/bar/index.html

Requirements

Name Version
terraform >= 0.13
aws >= 3.0

Providers

No providers.

Modules

Name Source Version
label cloudposse/label/null 0.24.1
lambda_folder_index terraform-aws-modules/lambda/aws
this cloudposse/label/null 0.24.1

Resources

No resources.

Inputs

Name Description Type Default Required
additional_tag_map Additional tags for appending to tags_as_list_of_maps. Not added to tags. map(string) {} no
attributes Additional attributes (e.g. 1) list(string) [] no
context Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as null to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.
any
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {}
}
no
delimiter Delimiter to be used between namespace, environment, stage, name and attributes.
Defaults to - (hyphen). Set to "" to use no delimiter at all.
string null no
enabled Set to false to prevent the module from creating any resources bool null no
environment Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' string null no
id_length_limit Limit id to this many characters (minimum 6).
Set to 0 for unlimited length.
Set to null for default, which is 0.
Does not affect id_full.
number null no
label_key_case The letter case of label keys (tag names) (i.e. name, namespace, environment, stage, attributes) to use in tags.
Possible values: lower, title, upper.
Default value: title.
string null no
label_order The naming order of the id output and Name tag.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 5 elements, but at least one must be present.
list(string) null no
label_value_case The letter case of output label values (also used in tags and id).
Possible values: lower, title, upper and none (no transformation).
Default value: lower.
string null no
name Solution name, e.g. 'app' or 'jenkins' string null no
namespace Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' string null no
regex_replace_chars Regex to replace chars with empty string in namespace, environment, stage and name.
If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.
string null no
stage Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' string null no
tags Additional tags (e.g. map('BusinessUnit','XYZ') map(string) {} no

Outputs

Name Description
lambda n/a

Share the Love

Like this project? Please give it a ★ on GitLab

Are you using this project or any of our other projects? Let us know at @guardianproject or email us directly

Related Projects

Check out these related projects.

Help

File an issue, send us an email or join us in the Matrix 'verse at #guardianproject:matrix.org or IRC at #guardianproject on Freenode.

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Developing

If you are interested in becoming a contributor, want to get involved in developing this project, other projects, or want to join our team, we would love to hear from you! Shoot us an email.

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

  1. Fork the repo on GitLab
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. Submit a Merge Request so that we can review your changes

NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!

Credits & License

Copyright © 2017-2021 Guardian Project

See LICENSE.md for full details.

Trademarks

All other trademarks referenced herein are the property of their respective owners.

About

This project is maintained and funded by The Guardian Project.

We're a collective of designers and developers focused on useable privacy and security. Everything we do is 100% FOSS. Check out out other ops projects and non-ops projects, follow us on mastadon or twitter, apply for a job, or partner with us.

Contributors

Abel Luck
Abel Luck

About

Terraform module to deploy a lambda@edge that rewrites requests ending in / to /index.html (AWS) (Mirror of https://gitlab.com/guardianproject-ops/terraform-aws-lambdaedge-folder-index)

Resources

License

Stars

0 stars

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors