-
Notifications
You must be signed in to change notification settings - Fork 2
Add new tests for CDN modules #1283
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
base: main
Are you sure you want to change the base?
Changes from all commits
b566760
691d091
99f9035
0b18b2a
3b8e85c
25cc683
73c8f72
557cf12
2275e74
86bbd63
b983fa4
7e1d1ce
27c2f32
6d6e67a
101bfd7
cf1a41e
0ca6f2f
487b996
6d90aae
3609fce
2f1b2a1
ff26d19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "azure_cdn": patch | ||
| --- | ||
|
|
||
| Remove old tests, use new for contracts, integration, unit and e2e |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # advanced | ||
|
|
||
| <!-- BEGIN_TF_DOCS --> | ||
| ## Requirements | ||
|
|
||
| | Name | Version | | ||
| |------|---------| | ||
| | <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.9 | | ||
| | <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | ~> 4.0 | | ||
| | <a name="requirement_dx"></a> [dx](#requirement\_dx) | ~> 0.0.6 | | ||
|
|
||
| ## Modules | ||
|
|
||
| | Name | Source | Version | | ||
| |------|--------|---------| | ||
| | <a name="module_azure_cdn"></a> [azure\_cdn](#module\_azure\_cdn) | ../../ | n/a | | ||
| | <a name="module_storage_account"></a> [storage\_account](#module\_storage\_account) | pagopa-dx/azure-storage-account/azurerm | ~> 2.1 | | ||
|
|
||
| ## Resources | ||
|
|
||
| | Name | Type | | ||
| |------|------| | ||
| | [azurerm_cdn_frontdoor_profile.integration](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/cdn_frontdoor_profile) | data source | | ||
| | [azurerm_resource_group.integration](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) | data source | | ||
| | [azurerm_subnet.pep](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source | | ||
|
|
||
| ## Inputs | ||
|
|
||
| No inputs. | ||
|
|
||
| ## Outputs | ||
|
|
||
| | Name | Description | | ||
| |------|-------------| | ||
| | <a name="output_endpoint_host_name"></a> [endpoint\_host\_name](#output\_endpoint\_host\_name) | CDN endpoint | | ||
| | <a name="output_profile_id"></a> [profile\_id](#output\_profile\_id) | The ID of the CDN profile | | ||
| <!-- END_TF_DOCS --> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| locals { | ||
| environment = { | ||
| prefix = "dx" | ||
| env_short = "d" | ||
| location = "italynorth" | ||
| domain = "e2e" | ||
| app_name = "test" | ||
| instance_number = "01" | ||
| } | ||
|
|
||
| naming_config = { | ||
| prefix = local.environment.prefix, | ||
| environment = local.environment.env_short, | ||
| location = local.environment.location | ||
| name = local.environment.app_name, | ||
| instance_number = tonumber(local.environment.instance_number), | ||
| } | ||
|
|
||
| virtual_network = { | ||
| name = provider::dx::resource_name(merge(local.naming_config, { | ||
| name = "common", | ||
| resource_type = "virtual_network" | ||
| })) | ||
| resource_group_name = provider::dx::resource_name(merge(local.naming_config, { | ||
| name = "network", | ||
| resource_type = "resource_group" | ||
| })) | ||
| } | ||
|
|
||
| tags = { | ||
| CostCenter = "TS000 - Tecnologia e Servizi" | ||
| CreatedBy = "Terraform" | ||
| Environment = "Dev" | ||
| BusinessUnit = "DevEx" | ||
| ManagementTeam = "Developer Experience" | ||
| Source = "https://github.com/pagopa/dx/modules/azure_cdn/examples/e2e" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,71 @@ | ||||||
|
|
||||||
| data "azurerm_resource_group" "integration" { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| name = provider::dx::resource_name(merge(local.naming_config, { | ||||||
| name = "integration", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it's not ideal, but to avoid creating two identical CDNs, I leveraged the existing integration one. Do you think it would be better to create a dedicated one for E2E as well?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed in this morning, I believe it'd be better to have two different infrastructures for the two kind of tests. Keep in mind that also foundational infrastructure (vnet, peps, etc.) is also doubled |
||||||
| resource_type = "resource_group" | ||||||
| })) | ||||||
| } | ||||||
|
|
||||||
| data "azurerm_cdn_frontdoor_profile" "integration" { | ||||||
| name = "dx-d-itn-test-afd-01" | ||||||
| resource_group_name = data.azurerm_resource_group.integration.name | ||||||
| } | ||||||
|
|
||||||
| data "azurerm_subnet" "pep" { | ||||||
| name = provider::dx::resource_name(merge(local.naming_config, { | ||||||
| name = "pep", | ||||||
| resource_type = "subnet" | ||||||
| })) | ||||||
| virtual_network_name = local.virtual_network.name | ||||||
| resource_group_name = local.virtual_network.resource_group_name | ||||||
| } | ||||||
|
|
||||||
| # Create a storage account with static website enabled | ||||||
| module "storage_account" { | ||||||
| source = "pagopa-dx/azure-storage-account/azurerm" | ||||||
| version = "~> 2.1" | ||||||
|
|
||||||
| environment = local.environment | ||||||
|
|
||||||
| resource_group_name = data.azurerm_resource_group.integration.name | ||||||
| use_case = "default" | ||||||
| subnet_pep_id = data.azurerm_subnet.pep.id | ||||||
|
|
||||||
| force_public_network_access_enabled = true # Public network access enabled for CDN origin reachability | ||||||
|
|
||||||
| static_website = { | ||||||
| enabled = true | ||||||
| index_document = "index.html" | ||||||
| } | ||||||
|
|
||||||
| subservices_enabled = { | ||||||
| blob = true | ||||||
| } | ||||||
|
|
||||||
| tags = local.tags | ||||||
| } | ||||||
|
|
||||||
| module "azure_cdn" { | ||||||
| # source = "pagopa-dx/azure-cdn/azurerm" | ||||||
| # version = "~> 0.5" | ||||||
| source = "../../" | ||||||
|
|
||||||
| resource_group_name = data.azurerm_resource_group.integration.name | ||||||
|
|
||||||
| environment = local.environment | ||||||
|
|
||||||
| # Reuse the existing CDN profile created above | ||||||
| existing_cdn_frontdoor_profile_id = data.azurerm_cdn_frontdoor_profile.integration.id | ||||||
|
|
||||||
| # WAF is already enabled on the profile, create security policy for this endpoint | ||||||
| waf_enabled = true | ||||||
|
|
||||||
| origins = { | ||||||
| primary = { | ||||||
| host_name = module.storage_account.primary_web_host | ||||||
| priority = 1 | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| tags = local.tags | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| output "profile_id" { | ||
| description = "The ID of the CDN profile" | ||
| value = module.azure_cdn.id | ||
| } | ||
|
|
||
|
|
||
| output "endpoint_host_name" { | ||
| value = module.azure_cdn.endpoint_hostname | ||
| description = "CDN endpoint" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| terraform { | ||
| required_version = "~> 1.9" | ||
| required_providers { | ||
| azurerm = { | ||
| source = "hashicorp/azurerm" | ||
| version = "~> 4.0" | ||
| } | ||
| dx = { | ||
| source = "pagopa-dx/azure" | ||
| version = "~> 0.0.6" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| provider "azurerm" { | ||
| features {} | ||
| } |
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.