Skip to content

Commit

Permalink
Merge branch 'main' into add-waf-resource
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-calabrese authored Feb 17, 2025
2 parents a572105 + 187a6e5 commit 8d85f0f
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-phones-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"infrastructure": minor
---

Removed docs-redirect submodule and getting the cloudfront function code from github
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "apps/nextjs-website/.tmp-docs"]
path = apps/nextjs-website/.tmp-docs
url = https://github.com/pagopa/devportal-docs.git
[submodule "apps/docs-redirect"]
path = apps/docs-redirect
url = https://github.com/pagopa/docs-redirect
1 change: 0 additions & 1 deletion apps/docs-redirect
Submodule docs-redirect deleted from f75cb8
19 changes: 19 additions & 0 deletions apps/infrastructure/src/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions apps/infrastructure/src/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ provider "awscc" {
region = var.aws_chatbot_region
}

data "http" "docs_redirect_cf_function_code" {
url = "https://raw.githubusercontent.com/pagopa/docs-redirect/refs/heads/main/src/rewriter.js"

request_headers = {
Accept = "text/plain"
}
}

# Init IaC resources ##########################################################
module "identity" {
source = "./identity"
Expand Down Expand Up @@ -172,6 +180,8 @@ module "docs_redirect" {
aws.us-east-1 = aws.us-east-1
}

cloudfront_function_code = data.http.docs_redirect_cf_function_code.body

environment = var.environment
tags = var.tags
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resource "aws_cloudfront_function" "redirect_viewer_request_handler" {
comment = "Redirects ${var.domain_to_redirect.from} requests to the correct domain"
# publish this version only if the env is true
publish = true
code = file("${path.root}/../../docs-redirect/src/rewriter.js")
code = var.cloudfront_function_code
}

resource "aws_cloudfront_distribution" "redirect" {
Expand Down
5 changes: 5 additions & 0 deletions apps/infrastructure/src/modules/docs_redirect/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ variable "use_custom_certificate" {
type = bool
default = true
description = "Use custom certificate for the cloudfront distribution"
}

variable "cloudfront_function_code" {
type = string
description = "The code of the cloudfront function"
}

0 comments on commit 8d85f0f

Please sign in to comment.