Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added configurable skip_destroy for destroying lambda@edge #6

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,7 @@ module "lambda" {
patterns = ["!.gitignore"]
}

skip_destroy = var.skip_destroy

depends_on = [local_sensitive_file.config]
}
33 changes: 33 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,38 @@ CloudFront distribution to provide OpenID Connect authentication at edge functio

Currently, the only supported provider is Microsoft AzureAD.

## Usage

<!-- markdownlint-disable -->
```hcl
module "cloudfront_authorizer" {
source = "github.com/chatloop/terraform-aws-cloudfront-auth?ref=v0.1.0"

providers = {
aws = aws.us-east-1 # Ensure you're deploying this module into us-east-1
}

function_name = "lambda-edge-azure-auth" # This must be unique
tenant = "2765a7ba-9519-4636-9669-35f6558266fe" # Azure Tenant ID
client_id = "2d30fa5c-bdbc-4adc-a3fb-86566348159c" # Azure App Client ID
client_secret = var.client_secret # Azure App Client Secret - keep this secret
redirect_uri = "https://${var.domain_name}/_callback" # CloudFront domain name with /_callback suffix

# The duration in hours before re-authenticating
session_duration = 24 # optional: default = 168 (7 days)

# Enables 301 redirects for directory paths not ending in a forward slash. e.g. www.example.com/about -> www.example.com/about/
trailing_slash_redirects_enabled = true # optional: default = false

# Appends index.html on to directory paths (e.g. www.example.com/about/ retrieves www.example.com/about/index.html from a backend s3 origin.)
simple_urls_enabled = true # optional: default = true

# Set to true if you do not wish the function to be deleted at destroy time, and instead just remove the function from the Terraform state.
skip_destroy = true # optional: default = false
}
```
<!-- markdownlint-restore -->

<!-- markdownlint-disable -->
<!-- BEGIN_TF_DOCS -->
## Requirements
Expand Down Expand Up @@ -49,6 +81,7 @@ Currently, the only supported provider is Microsoft AzureAD.
| <a name="input_redirect_uri"></a> [redirect\_uri](#input\_redirect\_uri) | Registered Microsoft Azure AD Application Redirect URI | `string` | n/a | yes |
| <a name="input_session_duration"></a> [session\_duration](#input\_session\_duration) | Authenticated session duration, in hours | `number` | `168` | no |
| <a name="input_simple_urls_enabled"></a> [simple\_urls\_enabled](#input\_simple\_urls\_enabled) | Appends index.html on to directory paths (e.g. www.example.com/about/ retrieves www.example.com/about/index.html from a backend s3 origin.) | `bool` | `true` | no |
| <a name="input_skip_destroy"></a> [skip\_destroy](#input\_skip\_destroy) | Set to true if you do not wish the function to be deleted at destroy time, and instead just remove the function from the Terraform state. | `bool` | `false` | no |
| <a name="input_tenant"></a> [tenant](#input\_tenant) | Microsoft Azure AD Tenant ID | `string` | n/a | yes |
| <a name="input_trailing_slash_redirects_enabled"></a> [trailing\_slash\_redirects\_enabled](#input\_trailing\_slash\_redirects\_enabled) | Enables 301 redirects for directory paths not ending in a forward slash. e.g. www.example.com/about -> www.example.com/about/ | `bool` | `false` | no |

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ variable "simple_urls_enabled" {
default = true
}

variable "skip_destroy" {
description = "Set to true if you do not wish the function to be deleted at destroy time, and instead just remove the function from the Terraform state."
type = bool
default = false
}

variable "tenant" {
description = "Microsoft Azure AD Tenant ID"
type = string
Expand Down