Skip to content
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

[CES-21] Refactoring resource groups in Core configuration #1179

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

Krusty93
Copy link
Contributor

@Krusty93 Krusty93 commented Sep 20, 2024

List of changes

All resource groups shared among domains are defined in core and set as output of it.

Motivation and context

Grouping shared resource groups in core configuration

Type of changes

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

Env to apply

  • DEV
  • UAT
  • PROD

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

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

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

  • Yes
  • No

Other information


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

How to apply

After PR is approved

  1. run deploy pipeline from Azure DevOps io-platform-iac-projects
  2. select PR branch
  3. wait for approval

@Krusty93 Krusty93 requested a review from a team as a code owner September 20, 2024 15:33
@github-actions github-actions bot added the core label Sep 20, 2024
@Krusty93 Krusty93 force-pushed the CES-21-migrazione-resource-groups-core branch from 3676721 to 6016958 Compare September 27, 2024 16:27
@Krusty93 Krusty93 changed the title [CES-21] Refactoring resource groups [CES-21] Refactoring resource groups in Core configuration Sep 27, 2024
Copy link

Copy link

📖 Terraform Plan ('src/core/prod') - success

Terraform Plan
azurerm_resource_group.external_weu: Preparing import... [id=/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-external]
azurerm_resource_group.common_weu: Preparing import... [id=/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-common]
azurerm_resource_group.internal_weu: Preparing import... [id=/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-internal]
azurerm_resource_group.linux_weu: Preparing import... [id=/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-linux]
azurerm_resource_group.assets_cdn_weu: Preparing import... [id=/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-assets-cdn-rg]
azurerm_resource_group.sec_weu: Preparing import... [id=/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-sec-rg]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create
  ~ update in-place

Terraform will perform the following actions:

  # azurerm_resource_group.acr_weu will be updated in-place
  # (moved from module.container_registry.azurerm_resource_group.container_registry)
  ~ resource "azurerm_resource_group" "acr_weu" {
        id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-container-registry-rg"
        name     = "io-p-container-registry-rg"
      ~ tags     = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
          ~ "Source"      = "https://github.com/pagopa/io-infra" -> "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
        # (1 unchanged attribute hidden)
    }

  # azurerm_resource_group.assets_cdn_weu will be updated in-place
  # (imported from "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-assets-cdn-rg")
  ~ resource "azurerm_resource_group" "assets_cdn_weu" {
        id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-assets-cdn-rg"
        location = "westeurope"
        name     = "io-p-assets-cdn-rg"
      ~ tags     = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
          ~ "Source"      = "https://github.com/pagopa/io-infra/blob/main/src/common/prod" -> "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
    }

  # azurerm_resource_group.vnet has moved to azurerm_resource_group.common_itn
    resource "azurerm_resource_group" "common_itn" {
        id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-common-rg-01"
        name     = "io-p-itn-common-rg-01"
        tags     = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
            "Source"      = "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
        # (1 unchanged attribute hidden)
    }

  # azurerm_resource_group.common_weu will be updated in-place
  # (imported from "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-common")
  ~ resource "azurerm_resource_group" "common_weu" {
        id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-common"
        location = "westeurope"
        name     = "io-p-rg-common"
      ~ tags     = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
          ~ "Source"      = "https://github.com/pagopa/io-infra" -> "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
    }

  # azurerm_resource_group.dashboards_itn will be created
  + resource "azurerm_resource_group" "dashboards_itn" {
      + id       = (known after apply)
      + location = "italynorth"
      + name     = "io-p-itn-common-dashboards-rg-01"
      + tags     = {
          + "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
          + "CreatedBy"   = "Terraform"
          + "Environment" = "Prod"
          + "Owner"       = "IO"
          + "Source"      = "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
    }

  # azurerm_resource_group.external_weu will be updated in-place
  # (imported from "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-external")
  ~ resource "azurerm_resource_group" "external_weu" {
        id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-external"
        location = "westeurope"
        name     = "io-p-rg-external"
      ~ tags     = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
          ~ "Source"      = "https://github.com/pagopa/io-infra" -> "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
    }

  # azurerm_resource_group.github_managed_identity_itn will be created
  + resource "azurerm_resource_group" "github_managed_identity_itn" {
      + id       = (known after apply)
      + location = "italynorth"
      + name     = "io-p-itn-github-id-rg-01"
      + tags     = {
          + "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
          + "CreatedBy"   = "Terraform"
          + "Environment" = "Prod"
          + "Owner"       = "IO"
          + "Source"      = "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
    }

  # azurerm_resource_group.internal_weu will be updated in-place
  # (imported from "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-internal")
  ~ resource "azurerm_resource_group" "internal_weu" {
        id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-internal"
        location = "westeurope"
        name     = "io-p-rg-internal"
      ~ tags     = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
          ~ "Source"      = "https://github.com/pagopa/io-infra" -> "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
    }

  # azurerm_resource_group.linux_weu will be updated in-place
  # (imported from "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-linux")
  ~ resource "azurerm_resource_group" "linux_weu" {
        id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-linux"
        location = "westeurope"
        name     = "io-p-rg-linux"
      ~ tags     = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
          ~ "Source"      = "https://github.com/pagopa/io-infra/blob/main/src/common/prod" -> "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
    }

  # azurerm_resource_group.role_assignment_itn will be created
  + resource "azurerm_resource_group" "role_assignment_itn" {
      + id       = (known after apply)
      + location = "italynorth"
      + name     = "default-roleassignment-rg"
      + tags     = {
          + "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
          + "CreatedBy"   = "Terraform"
          + "Environment" = "Prod"
          + "Owner"       = "IO"
          + "Source"      = "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
    }

  # azurerm_resource_group.sec_weu will be imported
    resource "azurerm_resource_group" "sec_weu" {
        id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-sec-rg"
        location = "westeurope"
        name     = "io-p-sec-rg"
        tags     = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
            "Source"      = "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
    }

  # module.container_registry.azurerm_container_registry.this will be updated in-place
  ~ resource "azurerm_container_registry" "this" {
        id                            = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-container-registry-rg/providers/Microsoft.ContainerRegistry/registries/iopcommonacr"
        name                          = "iopcommonacr"
      ~ tags                          = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
          ~ "Source"      = "https://github.com/pagopa/io-infra" -> "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
        # (16 unchanged attributes hidden)
    }

 # module.key_vault_weu.azurerm_resource_group.sec will no longer be managed by Terraform, but will not be destroyed
 # (destroy = false is set in the configuration)
 . resource "azurerm_resource_group" "sec" {
        id       = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-sec-rg"
        name     = "io-p-sec-rg"
        tags     = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
            "Source"      = "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
        # (1 unchanged attribute hidden)
    }

Plan: 6 to import, 3 to add, 7 to change, 0 to destroy.

Changes to Outputs:
  - azure_devops_agent = {
      - itn = null
      - weu = {
          - snet = {
              - address_prefixes = [
                  - "10.0.250.0/24",
                ]
              - id               = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-common/providers/Microsoft.Network/virtualNetworks/io-p-vnet-common/subnets/azure-devops"
              - name             = "azure-devops"
            }
        }
    } -> null
  + resource_groups    = {
      + italynorth = {
          + common         = "io-p-itn-common-rg-01"
          + dashboards     = "io-p-itn-common-dashboards-rg-01"
          + github_id      = "io-p-itn-github-id-rg-01"
          + location_short = "itn"
        }
      + westeurope = {
          + acr            = "io-p-container-registry-rg"
          + assets_cdn     = "io-p-assets-cdn-rg"
          + common         = "io-p-rg-common"
          + external       = "io-p-rg-external"
          + internal       = "io-p-rg-internal"
          + linux          = "io-p-rg-linux"
          + location_short = "weu"
          + sec            = "io-p-sec-rg"
        }
    }

Warning: Some objects will no longer be managed by Terraform

If you apply this plan, Terraform will discard its tracking information for
the following objects, but it will not delete them:
 - module.key_vault_weu.azurerm_resource_group.sec

After applying this plan, Terraform will no longer manage these objects. You
will need to import them into Terraform to manage them again.

Warning: Deprecated attribute

  on ../_modules/vpn/main.tf line 27, in module "vpn":
  27:       aad_audience          = data.azuread_application.vpn_app.application_id

The attribute "application_id" is deprecated. Refer to the provider
documentation for details.

(and one more similar warning elsewhere)

Warning: Argument is deprecated

  with module.azdoa_weu.module.azdoa_snet.azurerm_subnet.this,
  on .terraform/modules/azdoa_weu.azdoa_snet/subnet/main.tf line 23, in resource "azurerm_subnet" "this":
  23:   private_endpoint_network_policies_enabled     = var.private_endpoint_network_policies_enabled

`private_endpoint_network_policies_enabled` will be removed in favour of the
property `private_endpoint_network_policies` in version 4.0 of the AzureRM
Provider

(and 14 more similar warnings elsewhere)

─────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't
guarantee to take exactly these actions if you run "terraform apply" now.

Copy link
Contributor

@christian-calabrese christian-calabrese left a comment

Choose a reason for hiding this comment

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

LGTM

@Krusty93 Krusty93 merged commit 3d2e7f8 into main Sep 30, 2024
6 of 7 checks passed
@Krusty93 Krusty93 deleted the CES-21-migrazione-resource-groups-core branch September 30, 2024 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants