Skip to content

feat: [PIDM-1151] create checkout front door cdn#3577

Open
dylantangredi-jakala wants to merge 34 commits intomainfrom
PIDM-1151-migrate-checkout-cdn
Open

feat: [PIDM-1151] create checkout front door cdn#3577
dylantangredi-jakala wants to merge 34 commits intomainfrom
PIDM-1151-migrate-checkout-cdn

Conversation

@dylantangredi-jakala
Copy link
Collaborator

@dylantangredi-jakala dylantangredi-jakala commented Jan 13, 2026

depends on #3475
reference PR on ecommerce -> #3427

List of changes

  • created Azure Front Door CDN config for Checkout as new file

NOTE: this does not create the record A or switch DNS as we can see from the attached plan, thanks to the enable_dns_records = false variable setting in the custom_domains array.
Effective switch will happen in a dedicated PR

Motivation and context

This change in needed to migrate the checkout CDN to Azure Front Door as Microsoft CDN Classic is being deprecated by Azure.
Technical analysis -> https://pagopa.atlassian.net/wiki/x/8wCHlg
Historical notes/tests -> https://pagopa.atlassian.net/wiki/x/ngDVmg

Type of changes

  • Add new resources
  • Update configuration to existing resources
  • Remove existing resources

Does this introduce a change to production resources with possible user impact?

  • Yes, users may be impacted applying this change
  • No

Impact Assessment:

  • The CDN migration will replace the existing Classic CDN with Azure Front Door (effective switch will happen with a new PR)
  • During the transition, there may be brief DNS propagation delays (effective switch will happen with a new PR)

Rollout plan:

Does this introduce an unwanted change on infrastructure? Check terraform plan execution result

  • Yes
  • No

Plan Summary: (attached below)

  • Plan: 14 to add, 0 to change, 0 to destroy.

Other information

Note: the PR has not been applied yet in dev. Terraform plan has been executed and validated, but terraform apply has not been run.

  • pre-commit run successful

    image

NOTE: this PR is not currently applicable in DEV since the CDN Classic has been removed from the DEV environment, see Test Migrazione Atomica DEV 2026 01 29

UAT plan:

./terraform.sh plan weu-uat \
    -target="azurerm_resource_group.checkout_fe_rg" \
    -target="module.checkout_cdn" \
    -target="module.checkout_cdn_frontdoor" \
    -target="module.checkout_fe_frontdoor_web_test" \
    -out=uat_checkout_cdn.tfplan

Plan: 14 to add, 0 to change, 0 to destroy.
Saved the plan to: uat_checkout_cdn.tfplan

terraform show -no-color uat_checkout_cdn.tfplan > uat_checkout_cdn_plan_20260203.txt uat_checkout_cdn_plan_20260203.txt


If PR is partially applied, why? (reserved to mantainers)

version = "<= 2.12.0"
version = "<= 2.12.1"
}
azapi = {
Copy link
Collaborator Author

@dylantangredi-jakala dylantangredi-jakala Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: check if this azapi provider is still needed after the migration (not present in ecommerce-app).
Same for azuread and null_resource

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: untouched for now

@dylantangredi-jakala dylantangredi-jakala marked this pull request as ready for review January 13, 2026 17:22
@dylantangredi-jakala dylantangredi-jakala requested review from a team as code owners January 13, 2026 17:22
@infantesimone
Copy link
Contributor

From an initial review, everything generally makes sense. However, looking at this PR, I have concerns about how we plan to handle the Prod rollout. What are the concrete steps to be executed in production?
Applying everything as-is could potentially cause downtime, so I think we should first focus on rollout plan to ensure zero downtime.

  • A few points for consideration:
  • Is it possible to perform the upgrade to v4 first?
  • Can we create the new CDN without removing the existing one, and then switch the DNS afterward?
    Finally, we should also define a clear rollout plan.

@dylantangredi-jakala
Copy link
Collaborator Author

dylantangredi-jakala commented Jan 14, 2026

@infantesimone I'll try to answer here:

  • Is it possible to perform the upgrade to v4 first?
  • Can we create the new CDN without removing the existing one, and then switch the DNS afterward?
  • Finally, we should also define a clear rollout plan.
  • Yes, the dependency is one-way, in the sense that we cannot migrate to Front Door without upgrading to v4 since the cdn_frontdoor module only exists in the v4 module collection at .terraform/modules/__v4__/cdn_frontdoor, but we can upgrade the modules to v4 without necessarily migrating the CDN.
    • for convenience, I will keep this PR/branch for the CDN migration only. I will move the modules upgrade to a new PR that will branch out from main, while this one will branch out from the new one.
      EDIT: a branch with the modules upgrade was already created (thanks @pietro-tota) so I rebased this one onto it ✅
  • Possibly, with more complicated steps. I will write my findings in the jira comment section for this existing task. In general it seems like we could make use of the enable_dns_records param while creating the new CDN/storage account with a different module name from the existing one. This will require a content sync in some way, from the old storage account to the new one, or deploy to both SAs during the migration period. The other option would be to modify the cdn_frontdoor module to support an existing storage account, since by default it can only work if it creates it as new during setup. rif -> (src/domains/ecommerce-app/.terraform/modules/v4/cdn_frontdoor/main.tf) there is count in the module definition so I suppose it always creates a new SA
  • I will check what was the rollout plan for ecommerce, generally speaking this is high impact as I've stated in the Impact Assessment section

@dylantangredi-jakala dylantangredi-jakala changed the base branch from main to PIDM-1151-migrate-checkout-app-to-module-v4 January 14, 2026 14:49
@dylantangredi-jakala dylantangredi-jakala changed the title feat: [PIDM-1151] migrate checkout cdn to front door and tf v4 modules feat: [PIDM-1151] migrate checkout cdn to front door Jan 14, 2026
@dylantangredi-jakala dylantangredi-jakala marked this pull request as draft January 14, 2026 16:49
@pietro-tota
Copy link
Contributor

@infantesimone I'll try to answer here:

  • Is it possible to perform the upgrade to v4 first?
  • Can we create the new CDN without removing the existing one, and then switch the DNS afterward?
  • Finally, we should also define a clear rollout plan.
  • Yes, the dependency is one-way, in the sense that we cannot migrate to Front Door without upgrading to v4 since the cdn_frontdoor module only exists in the v4 module collection at .terraform/modules/__v4__/cdn_frontdoor, but we can upgrade the modules to v4 without necessarily migrating the CDN.

    • for convenience, I will keep this PR/branch for the CDN migration only. I will move the modules upgrade to a new PR that will branch out from main, while this one will branch out from the new one.
      EDIT: a branch with the modules upgrade was already created (thanks @pietro-tota) so I rebased this one onto it ✅
  • Possibly, with more complicated steps. I will write my findings in the jira comment section for this existing task. In general it seems like we could make use of the enable_dns_records param while creating the new CDN/storage account with a different module name from the existing one. This will require a content sync in some way, from the old storage account to the new one, or deploy to both SAs during the migration period. The other option would be to modify the cdn_frontdoor module to support an existing storage account, since by default it can only work if it creates it as new during setup. rif -> (src/domains/ecommerce-app/.terraform/modules/v4/cdn_frontdoor/main.tf) there is count in the module definition so I suppose it always creates a new SA

  • I will check what was the rollout plan for ecommerce, generally speaking this is high impact as I've stated in the Impact Assessment section

An hint for the second point: keep it simple.
As suggested by @infantesimone we can create the new cnd profile (with it's own storage account etc) without custom domains association in the first place, allowing us to deploy to prod without affecting the already existing CDN profile.
Once both SA are aligned we can proceed to DNS switch to make it point to the new CDN (adding custom domains in frontdoor that point to existing dns record) in place of the old one and after checking that no more traffic is handled by the old cdn delete it altogether.

I would leave the double SA during the migration phase (each cdn with it's own sa) as it will be temporary, just for the switch phase. Checkout-fe side we can modify the deploy pipeline to allow to deploy to both the new and the old cnd profiles (see here) allowing us to update the cdn and check that it's working before the switch (using endpoint hostname)

@dylantangredi-jakala
Copy link
Collaborator Author

dylantangredi-jakala commented Jan 15, 2026

Following the suggestions, we now have one branch with the v4 modules upgrade -> #3475 and one branch (the one from the current PR) where a new terraform file is defined, containing the code for the Front Door CDN creation and no custom domains. This will we applied in DEV and tested soon.

A future PR will contain the code to make the actual switch and the file renaming/deletion.

@dylantangredi-jakala dylantangredi-jakala marked this pull request as ready for review January 16, 2026 08:50
@dylantangredi-jakala dylantangredi-jakala changed the title feat: [PIDM-1151] migrate checkout cdn to front door feat: [PIDM-1151] create checkout front door cdn Jan 16, 2026
CianoDanilo
CianoDanilo previously approved these changes Jan 16, 2026
{
action = "Overwrite"
name = local.cdn_frontdoor_csp_header_name
value = format("default-src 'self'; connect-src 'self' https://api.%s.%s https://api-eu.mixpanel.com https://wisp2.pagopa.gov.it https://privacyportalde-cdn.onetrust.com https://privacyportal-de.onetrust.com", var.dns_zone_prefix, var.external_domain)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe https://wisp2.pagopa.gov.it and onetrust are no longer used, but to check with the team @pagopa/pagopa-team-touchpoint

Copy link
Collaborator Author

@dylantangredi-jakala dylantangredi-jakala Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed wisp domain with 543020b after confirming with the team.
TODO check onetrust domains
EDIT: onetrust domains are needed for the correct scritpt loading on checkout terms page here https://github.com/pagopa/pagopa-checkout-fe/blob/1e0219051c645162e8a89eaf0690ce6320c81170/static/terms/it.html#L23

{
action = "Append"
name = local.cdn_frontdoor_csp_header_name
value = "frame-ancestors 'none'; object-src 'none'; frame-src 'self' https://www.google.com *.platform.pagopa.it *.sia.eu *.nexigroup.com *.recaptcha.net recaptcha.net https://recaptcha.google.com;"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to check *.sia.eu

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed with 543020b after confirming with the team

{
action = "Append"
name = local.cdn_frontdoor_csp_header_name
value = "img-src 'self' https://acardste.vaservices.eu:* https://wisp2.pagopa.gov.it https://assets.cdn.io.italia.it www.gstatic.com/recaptcha data: https://assets.cdn.platform.pagopa.it https://privacyportalde-cdn.onetrust.com;"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, removed with 543020b

Base automatically changed from PIDM-1151-migrate-checkout-app-to-module-v4 to main January 27, 2026 11:39
@dylantangredi-jakala dylantangredi-jakala dismissed CianoDanilo’s stale review January 27, 2026 11:39

The base branch was changed.

@dpulls
Copy link

dpulls bot commented Jan 27, 2026

🎉 All dependencies have been resolved !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants