Skip to content

Commit 994ccc5

Browse files
authored
Add PSN GitHub environments and secrets with Managed Identities (#603)
This pull request introduces significant enhancements to the infrastructure provisioning for the production environment, primarily to support a new "psn-prod" environment. The changes add a new Azure subscription/provider configuration, manage new user-assigned identities and federated credentials, and automate the creation of GitHub Actions environment secrets for the "psn-prod" environment. Additionally, the repository module is configured to recognize the new environment. Resolves: CES-1567
1 parent 7f02c53 commit 994ccc5

File tree

11 files changed

+410
-17
lines changed

11 files changed

+410
-17
lines changed

.github/workflows/release_psn_infra.yaml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ name: PR PSN Infrastructure Release - Prod
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
hub:
7+
description: 'Plan in Hub'
8+
required: false
9+
type: boolean
10+
default: false
11+
spoke:
12+
description: 'Plan in Spoke'
13+
required: false
14+
type: boolean
15+
default: false
16+
resources:
17+
description: 'Plan in Resources PSN'
18+
required: false
19+
type: boolean
20+
default: false
521
# TBD: Uncomment after permissions are set on identity
622
# push:
723
# branches:
@@ -47,11 +63,25 @@ jobs:
4763
if: github.event_name == 'workflow_dispatch'
4864
id: all
4965
run: |
50-
echo 'changes=["core/psn/hub", "core/psn/spoke", "resources/psn"]' >> $GITHUB_OUTPUT
66+
modules=()
67+
if [ "${{ inputs.hub }}" == "true" ]; then
68+
modules+=("core/psn/hub")
69+
fi
70+
if [ "${{ inputs.spoke }}" == "true" ]; then
71+
modules+=("core/psn/spoke")
72+
fi
73+
if [ "${{ inputs.resources }}" == "true" ]; then
74+
modules+=("resources/psn")
75+
fi
76+
if [ ${#modules[@]} -eq 0 ]; then
77+
modules=("core/psn/hub" "core/psn/spoke" "resources/psn")
78+
fi
79+
json_array=$(printf '%s\n' "${modules[@]}" | jq -R . | jq -s -c .)
80+
echo "changes=$json_array" >> $GITHUB_OUTPUT
5181
5282
release_prod:
5383
needs: changes
54-
uses: pagopa/dx/.github/workflows/infra_apply.yaml@support/psn-adaptation #main - Temporary, to be removed when using specific psn environment
84+
uses: pagopa/dx/.github/workflows/infra_apply.yaml@main
5585
name: Infrastructure Release
5686
secrets: inherit
5787

@@ -64,6 +94,6 @@ jobs:
6494
environment: prod
6595
base_path: infra/${{ matrix.infra }}
6696
use_private_agent: true
67-
override_github_environment: infra-prod
97+
override_github_environment: infra-psn-prod
6898
use_labels: true
6999
override_labels: psn

.github/workflows/support_function_deploy_psn.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ permissions:
1616
jobs:
1717
deploy:
1818
name: Deploy
19-
uses: pagopa/dx/.github/workflows/release-azure-appsvc-v1.yaml@support/psn-adaptation #main - Temporary, to be removed when using specific psn environment
19+
uses: pagopa/dx/.github/workflows/release-azure-appsvc-v1.yaml@main
2020
secrets: inherit
2121
with:
2222
workspace_name: io-wallet-support-func
23-
environment: app-prod
23+
environment: app-psn-prod
2424
resource_group_name: iw-p-itn-wallet-rg-01
2525
web_app_name: iw-p-itn-support-func-01
2626
disable_auto_staging_deploy: true

.github/workflows/user_function_deploy_psn.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ permissions:
1616
jobs:
1717
deploy:
1818
name: Deploy
19-
uses: pagopa/dx/.github/workflows/release-azure-appsvc-v1.yaml@support/psn-adaptation #main - Temporary, to be removed when using specific psn environment
19+
uses: pagopa/dx/.github/workflows/release-azure-appsvc-v1.yaml@main
2020
secrets: inherit
2121
with:
2222
workspace_name: io-wallet-user-func
23-
environment: app-prod
23+
environment: app-psn-prod
2424
resource_group_name: iw-p-itn-wallet-rg-01
2525
web_app_name: iw-p-itn-user-func-01
2626
disable_auto_staging_deploy: true

.github/workflows/user_uat_function_deploy_psn.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ permissions:
1616
jobs:
1717
deploy:
1818
name: Deploy
19-
uses: pagopa/dx/.github/workflows/release-azure-appsvc-v1.yaml@support/psn-adaptation #main - Temporary, to be removed when using specific psn environment
19+
uses: pagopa/dx/.github/workflows/release-azure-appsvc-v1.yaml@main
2020
secrets: inherit
2121
with:
2222
workspace_name: io-wallet-user-func
23-
environment: app-prod
23+
environment: app-psn-prod
2424
resource_group_name: iw-p-itn-wallet-rg-01
2525
web_app_name: iw-u-itn-user-func-01
2626
disable_auto_staging_deploy: true

.github/workflows/validate_psn_infra.yaml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ name: PR PSN Infrastructure Plan - Prod
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
hub:
7+
description: 'Plan in Hub'
8+
required: false
9+
type: boolean
10+
default: false
11+
spoke:
12+
description: 'Plan in Spoke'
13+
required: false
14+
type: boolean
15+
default: false
16+
resources:
17+
description: 'Plan in Resources PSN'
18+
required: false
19+
type: boolean
20+
default: false
521
# TBD: Uncomment after permissions are set on identity
622
# pull_request:
723
# types:
@@ -48,11 +64,25 @@ jobs:
4864
if: github.event_name == 'workflow_dispatch'
4965
id: all
5066
run: |
51-
echo 'changes=["core/psn/hub", "core/psn/spoke", "resources/psn"]' >> $GITHUB_OUTPUT # removed for tests
67+
modules=()
68+
if [ "${{ inputs.hub }}" == "true" ]; then
69+
modules+=("core/psn/hub")
70+
fi
71+
if [ "${{ inputs.spoke }}" == "true" ]; then
72+
modules+=("core/psn/spoke")
73+
fi
74+
if [ "${{ inputs.resources }}" == "true" ]; then
75+
modules+=("resources/psn")
76+
fi
77+
if [ ${#modules[@]} -eq 0 ]; then
78+
modules=("core/psn/hub" "core/psn/spoke" "resources/psn")
79+
fi
80+
json_array=$(printf '%s\n' "${modules[@]}" | jq -R . | jq -s -c .)
81+
echo "changes=$json_array" >> $GITHUB_OUTPUT
5282
5383
plan_prod:
5484
needs: changes
55-
uses: pagopa/dx/.github/workflows/infra_plan.yaml@support/psn-adaptation #main - Temporary, to be removed when using specific psn environment
85+
uses: pagopa/dx/.github/workflows/infra_plan.yaml@main
5686
name: Infrastructure Plan
5787
secrets: inherit
5888

@@ -66,6 +96,6 @@ jobs:
6696
environment: prod
6797
base_path: infra/${{ matrix.infra }}
6898
use_private_agent: true
69-
override_github_environment: infra-prod
99+
override_github_environment: infra-psn-prod
70100
use_labels: true
71101
override_labels: psn

infra/bootstrapper/prod/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
|------|---------|
1717
| <a name="provider_azuread"></a> [azuread](#provider\_azuread) | 3.1.0 |
1818
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 4.21.1 |
19+
| <a name="provider_azurerm.psn"></a> [azurerm.psn](#provider\_azurerm.psn) | 4.21.1 |
20+
| <a name="provider_github"></a> [github](#provider\_github) | 6.6.0 |
1921

2022
## Modules
2123

@@ -27,16 +29,40 @@
2729

2830
| Name | Type |
2931
|------|------|
32+
| [azurerm_federated_identity_credential.github_app_psn_cd](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/federated_identity_credential) | resource |
33+
| [azurerm_federated_identity_credential.github_app_psn_ci](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/federated_identity_credential) | resource |
34+
| [azurerm_federated_identity_credential.github_infra_cd](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/federated_identity_credential) | resource |
35+
| [azurerm_federated_identity_credential.github_infra_ci](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/federated_identity_credential) | resource |
36+
| [azurerm_federated_identity_credential.github_infra_psn_cd](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/federated_identity_credential) | resource |
37+
| [azurerm_federated_identity_credential.github_infra_psn_ci](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/federated_identity_credential) | resource |
38+
| [azurerm_federated_identity_credential.github_opex_psn_cd](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/federated_identity_credential) | resource |
39+
| [azurerm_federated_identity_credential.github_opex_psn_ci](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/federated_identity_credential) | resource |
40+
| [azurerm_user_assigned_identity.app_psn_cd](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/user_assigned_identity) | resource |
41+
| [azurerm_user_assigned_identity.app_psn_ci](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/user_assigned_identity) | resource |
42+
| [azurerm_user_assigned_identity.infra_psn_cd](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/user_assigned_identity) | resource |
43+
| [azurerm_user_assigned_identity.infra_psn_ci](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/user_assigned_identity) | resource |
44+
| [azurerm_user_assigned_identity.opex_psn_cd](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/user_assigned_identity) | resource |
45+
| [azurerm_user_assigned_identity.opex_psn_ci](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/user_assigned_identity) | resource |
46+
| [github_actions_environment_secret.app_psn_cd](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_environment_secret) | resource |
47+
| [github_actions_environment_secret.app_psn_ci](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_environment_secret) | resource |
48+
| [github_actions_environment_secret.infra_cd](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_environment_secret) | resource |
49+
| [github_actions_environment_secret.infra_ci](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_environment_secret) | resource |
50+
| [github_actions_environment_secret.infra_psn_cd](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_environment_secret) | resource |
51+
| [github_actions_environment_secret.infra_psn_ci](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_environment_secret) | resource |
52+
| [github_actions_environment_secret.opex_psn_cd](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_environment_secret) | resource |
53+
| [github_actions_environment_secret.opex_psn_ci](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_environment_secret) | resource |
3054
| [azuread_group.admins](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/group) | data source |
3155
| [azuread_group.developers](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/group) | data source |
3256
| [azurerm_api_management.apim](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/api_management) | data source |
3357
| [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) | data source |
58+
| [azurerm_client_config.psn](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) | data source |
3459
| [azurerm_container_app_environment.runner](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/container_app_environment) | data source |
3560
| [azurerm_key_vault.common](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault) | data source |
3661
| [azurerm_resource_group.common_itn](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) | data source |
3762
| [azurerm_resource_group.dashboards](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) | data source |
3863
| [azurerm_resource_group.dns_zones](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) | data source |
3964
| [azurerm_subscription.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subscription) | data source |
65+
| [azurerm_subscription.psn](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subscription) | data source |
4066
| [azurerm_virtual_network.common](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/virtual_network) | data source |
4167

4268
## Inputs

infra/bootstrapper/prod/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ provider "azurerm" {
3131
storage_use_azuread = true
3232
}
3333

34+
provider "azurerm" {
35+
features {}
36+
alias = "psn"
37+
storage_use_azuread = true
38+
resource_provider_registrations = "none"
39+
subscription_id = "725dede2-879b-45c5-82fa-eb816875b10c"
40+
}
41+
3442
provider "github" {
3543
owner = "pagopa"
3644
}

0 commit comments

Comments
 (0)