-
Notifications
You must be signed in to change notification settings - Fork 2
Add examples and e2e tests to AppConfiguration modules #1106
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
42eccf9
cb0749d
f9f7bbf
72a3aff
992e0d3
5424c9e
37e4c33
f63ec8c
4693925
155fa19
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,34 @@ | ||
| # git | ||
| .git | ||
| .gitignore | ||
|
|
||
| # node | ||
| node_modules | ||
| .env | ||
| dist | ||
| .pnpm-store | ||
| vite.config.*.timestamp* | ||
| vitest.config.*.timestamp* | ||
|
|
||
| # Go | ||
| terraform-provider-azure | ||
| providers/azure/terraform-provider-azure | ||
|
|
||
| # Terraform | ||
| **/.terraform/* | ||
| *.tfstate | ||
| *.tfstate.* | ||
| override.tf | ||
| override.tf.json | ||
| *_override.tf | ||
| *_override.tf.json | ||
| **/modules/**/.terraform.lock.hcl | ||
| **/_modules/**/.terraform.lock.hcl | ||
|
|
||
| # MacOS | ||
| *.DS_Store | ||
|
|
||
| # NX | ||
| .nx/cache | ||
| .nx/workspace-data | ||
| .github/instructions/nx.instructions.md |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| # Build and publish the application Docker image for the E2E App Configuration - including all scenarios. | ||
|
|
||
| name: Publish E2E App Configuration - All Scenarios | ||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: | ||
| - main | ||
| - CES-1469-aggiungere-esempi-del-modulo-da-usare-per-i-test-e-2-e | ||
| # paths: | ||
| # - "infra/modules/azure_app_configuration/tests/apps/all_scenarios/**" | ||
|
|
||
| env: | ||
| MODULE_NAME: "azure_app_configuration" | ||
|
|
||
| jobs: | ||
| publish: | ||
| name: Build and Push Docker Image | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| attestations: write | ||
| packages: write | ||
| env: | ||
| IMAGE_NAME: "pagopa/e2e-appconfiguration-all-scenarios" | ||
| IMAGE_TAG: "latest" | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | ||
|
|
||
| - name: Docker Build and Push | ||
| id: docker_build | ||
| uses: pagopa/dx/actions/docker-build-push@main | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| dockerfile_path: infra/modules/${{ env.MODULE_NAME }}/tests/apps/all_scenarios/Dockerfile | ||
| dockerfile_context: infra/modules/${{ env.MODULE_NAME }}/tests/apps/all_scenarios/src | ||
| docker_image_name: ${{ env.IMAGE_NAME }} | ||
| docker_image_description: "Web app which exposes endpoints to access App Configuration. Used for E2E tests of the Azure App Configuration Terraform module." | ||
| docker_image_authors: "PagoPA" | ||
| build_platforms: "linux/amd64,linux/arm64" | ||
| push_to_registry: true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # keyvault_integration | ||
|
|
||
| <!-- BEGIN_TF_DOCS --> | ||
| ## Requirements | ||
|
|
||
| | Name | Version | | ||
| |------|---------| | ||
| | <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.13.0 | | ||
| | <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | ~> 4.0 | | ||
| | <a name="requirement_pagopa-dx"></a> [pagopa-dx](#requirement\_pagopa-dx) | ~> 0.8 | | ||
| | <a name="requirement_random"></a> [random](#requirement\_random) | ~> 3.7 | | ||
|
|
||
| ## Modules | ||
|
|
||
| | Name | Source | Version | | ||
| |------|--------|---------| | ||
| | <a name="module_appcs_with_kv"></a> [appcs\_with\_kv](#module\_appcs\_with\_kv) | pagopa-dx/azure-app-configuration/azurerm | ~> 0.0 | | ||
|
|
||
| ## Resources | ||
|
|
||
| | Name | Type | | ||
| |------|------| | ||
| | [azurerm_key_vault.kv](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault) | resource | | ||
| | [azurerm_private_endpoint.kv](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint) | resource | | ||
| | [azurerm_resource_group.e2e_appcs](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource | | ||
| | [random_integer.appcs_instance](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) | resource | | ||
| | [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) | data source | | ||
| | [azurerm_private_dns_zone.kv](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/private_dns_zone) | data source | | ||
| | [azurerm_resource_group.network](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 | | ||
| | [azurerm_subscription.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subscription) | data source | | ||
| | [azurerm_virtual_network.e2e](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/virtual_network) | data source | | ||
|
|
||
| ## Inputs | ||
|
|
||
| No inputs. | ||
|
|
||
| ## Outputs | ||
|
|
||
| | Name | Description | | ||
| |------|-------------| | ||
| | <a name="output_name"></a> [name](#output\_name) | n/a | | ||
| <!-- END_TF_DOCS --> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| data "azurerm_client_config" "current" {} | ||
|
|
||
| data "azurerm_subscription" "current" {} | ||
|
|
||
| data "azurerm_private_dns_zone" "kv" { | ||
| name = "privatelink.vaultcore.azure.net" | ||
| resource_group_name = local.e2e_virtual_network.resource_group_name | ||
| } | ||
|
|
||
| data "azurerm_virtual_network" "e2e" { | ||
| name = local.e2e_virtual_network.name | ||
| resource_group_name = local.e2e_virtual_network.resource_group_name | ||
| } | ||
|
|
||
| data "azurerm_subnet" "pep" { | ||
| name = provider::pagopa-dx::resource_name(merge(local.naming_config, { | ||
| name = "pep", | ||
| resource_type = "subnet" | ||
| })) | ||
| virtual_network_name = data.azurerm_virtual_network.e2e.name | ||
| resource_group_name = data.azurerm_virtual_network.e2e.resource_group_name | ||
| } | ||
|
|
||
| data "azurerm_resource_group" "network" { | ||
| name = provider::pagopa-dx::resource_name(merge(local.naming_config, { | ||
| name = "network" | ||
| resource_type = "resource_group" | ||
| })) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| resource "azurerm_resource_group" "e2e_appcs" { | ||
| name = provider::pagopa-dx::resource_name(merge(local.naming_config, { | ||
| domain = "e2e" | ||
| name = "appcs", | ||
| resource_type = "resource_group" | ||
| })) | ||
| location = local.environment.location | ||
|
|
||
| tags = local.tags | ||
| } | ||
|
|
||
| resource "azurerm_key_vault" "kv" { | ||
| name = provider::dx::resource_name(merge(local.naming_config, { resource_type = "key_vault", domain = "e2e", instance_number = random_integer.appcs_instance.result })) | ||
| location = azurerm_resource_group.e2e_appcs.location | ||
| resource_group_name = azurerm_resource_group.e2e_appcs.name | ||
| tenant_id = data.azurerm_client_config.current.tenant_id | ||
| sku_name = "standard" | ||
| rbac_authorization_enabled = true | ||
| purge_protection_enabled = true | ||
| soft_delete_retention_days = 7 | ||
| public_network_access_enabled = false | ||
| network_acls { | ||
| bypass = "AzureServices" | ||
| default_action = "Deny" | ||
| } | ||
| tags = local.tags | ||
| } | ||
|
|
||
| resource "azurerm_private_endpoint" "kv" { | ||
| name = provider::dx::resource_name(merge(local.naming_config, { resource_type = "key_vault_private_endpoint", domain = "e2e", instance_number = random_integer.appcs_instance.result })) | ||
| location = azurerm_resource_group.e2e_appcs.location | ||
| resource_group_name = azurerm_resource_group.e2e_appcs.name | ||
| subnet_id = data.azurerm_subnet.pep.id | ||
|
|
||
| private_service_connection { | ||
| name = provider::dx::resource_name(merge(local.naming_config, { resource_type = "key_vault_private_endpoint", domain = "e2e", instance_number = random_integer.appcs_instance.result })) | ||
| private_connection_resource_id = azurerm_key_vault.kv.id | ||
| is_manual_connection = false | ||
| subresource_names = ["vault"] | ||
| } | ||
|
|
||
| private_dns_zone_group { | ||
| name = "private-dns-zone-group" | ||
| private_dns_zone_ids = [data.azurerm_private_dns_zone.kv.id] | ||
| } | ||
|
|
||
| tags = local.tags | ||
| } | ||
|
|
||
| resource "dx_available_subnet_cidr" "private_app" { | ||
| virtual_network_id = data.azurerm_virtual_network.e2e.id | ||
| prefix_length = 26 | ||
| } | ||
|
|
||
| resource "azurerm_subnet" "private_app" { | ||
| name = provider::dx::resource_name(merge(local.naming_config, { | ||
| name = "appcs-private", | ||
| resource_type = "container_instance_subnet" | ||
| })) | ||
| resource_group_name = local.e2e_virtual_network.resource_group_name | ||
| virtual_network_name = local.e2e_virtual_network.name | ||
| address_prefixes = [dx_available_subnet_cidr.private_app.cidr_block] | ||
|
|
||
| delegation { | ||
| name = "Microsoft.ContainerInstance/containerGroups" | ||
|
|
||
| service_delegation { | ||
| name = "Microsoft.ContainerInstance/containerGroups" | ||
| actions = [ | ||
| "Microsoft.Network/virtualNetworks/subnets/action", | ||
| ] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource "azurerm_container_group" "private_app" { | ||
| name = provider::dx::resource_name( | ||
| merge(local.naming_config, { name = "appcs-private", resource_type = "container_instance" }) | ||
| ) | ||
| location = local.environment.location | ||
| resource_group_name = azurerm_resource_group.e2e_appcs.name | ||
|
|
||
| identity { type = "SystemAssigned" } | ||
|
|
||
| os_type = "Linux" | ||
|
|
||
| container { | ||
| name = "network-access" | ||
| image = local.docker_image | ||
| cpu = "0.5" | ||
| memory = "1.5" | ||
| ports { | ||
| port = 8080 | ||
| } | ||
| } | ||
|
|
||
| ip_address_type = "Private" | ||
|
|
||
| subnet_ids = [ | ||
| azurerm_subnet.private_app.id | ||
| ] | ||
|
|
||
| diagnostics { | ||
| log_analytics { | ||
| workspace_id = data.azurerm_log_analytics_workspace.e2e.workspace_id | ||
| workspace_key = data.azurerm_log_analytics_workspace.e2e.primary_shared_key | ||
| } | ||
| } | ||
|
|
||
| tags = local.tags | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| locals { | ||
| tags = { | ||
| CostCenter = "TS000 - Tecnologia e Servizi" | ||
| CreatedBy = "Terraform" | ||
| Environment = "Dev" | ||
| BusinessUnit = "DevEx" | ||
| Source = "https://github.com/pagopa/dx/tests/azure_app_configuration" | ||
| ManagementTeam = "Developer Experience" | ||
| TestSuite = "e2e" | ||
| } | ||
|
|
||
| environment = { | ||
| prefix = "dx" | ||
| env_short = "d" | ||
| location = "italynorth" | ||
| app_name = "e2e" | ||
| 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), | ||
| } | ||
|
|
||
| e2e_virtual_network = { | ||
| name = provider::pagopa-dx::resource_name(merge(local.naming_config, { | ||
| name = "e2e", | ||
| resource_type = "virtual_network" | ||
| })) | ||
| resource_group_name = provider::pagopa-dx::resource_name(merge(local.naming_config, { | ||
| name = "e2e", | ||
| resource_type = "resource_group" | ||
| })) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| resource "random_integer" "appcs_instance" { | ||
| min = 1 | ||
| max = 99 | ||
| } | ||
|
|
||
| module "appcs_with_kv" { | ||
| source = "pagopa-dx/azure-app-configuration/azurerm" | ||
| version = "~> 0.0" | ||
|
|
||
| environment = (merge(local.environment, { instance_number = random_integer.appcs_instance.result })) | ||
| resource_group_name = azurerm_resource_group.e2e_appcs.name | ||
|
|
||
| subscription_id = data.azurerm_subscription.current.subscription_id | ||
|
|
||
| subnet_pep_id = data.azurerm_subnet.pep.id | ||
| virtual_network = { | ||
| name = local.e2e_virtual_network.name | ||
| resource_group_name = local.e2e_virtual_network.resource_group_name | ||
| } | ||
|
|
||
| private_dns_zone_resource_group_name = data.azurerm_resource_group.network.name | ||
|
|
||
| key_vault = { | ||
| has_rbac_support = true | ||
|
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. question: what's this for? can we link related docs?
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. it refers to role assignment module. It says whether the indicated keyvault uses access policies or RBAC as access model |
||
| name = azurerm_key_vault.kv.name | ||
| resource_group_name = azurerm_key_vault.kv.resource_group_name | ||
| subscription_id = data.azurerm_subscription.current.subscription_id | ||
| } | ||
|
|
||
| tags = local.tags | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| output "name" { | ||
| value = module.appcs_with_kv.name | ||
| } | ||
|
|
||
| output "private_app_ip_address" { | ||
| value = azurerm_container_group.private_app.ip_address | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.