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-155] Updated static_analysis.yaml with new action and pre-commit updated #1225

Merged
merged 26 commits into from
Oct 8, 2024

Conversation

mamu0
Copy link
Contributor

@mamu0 mamu0 commented Oct 3, 2024

Motivation and Context

The static_analysis.yaml action is changed to avoid docker use and update the action with more recent form.
Updated pre-commit to a more recent one:

  1. added trivy instead of tfsec
  2. added tflint
  3. added terraform provider command to enable lock for different machines

Major Changes

static_analysis.yaml now call the dx template.
pre-commit work as before, but tfsec was deprecated in favor of trivy and now there is also tflint for another check.
For the correct work of the new static analysis action there is a new pre commit hook that execute the command

  terraform providers lock \
    -platform=windows_amd64 \
    -platform=darwin_amd64 \
    -platform=darwin_arm64 \
    -platform=linux_amd64

for each .terraform.lock.hcl file with a change.

Dependencies

Testing

Documentation

Other Considerations

@mamu0 mamu0 requested a review from a team as a code owner October 3, 2024 10:24
Copy link

sonarqubecloud bot commented Oct 8, 2024

Copy link

github-actions bot commented Oct 8, 2024

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

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

Terraform will perform the following actions:

  # 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/blob/main/src/core/prod"
        }
        # (16 unchanged attributes hidden)
    }

  # module.azdoa_weu.module.azdoa_li_infra.azurerm_linux_virtual_machine_scale_set.this will be updated in-place
  ~ resource "azurerm_linux_virtual_machine_scale_set" "this" {
        id                                                = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-azdoa-rg/providers/Microsoft.Compute/virtualMachineScaleSets/io-p-azdoa-vmss-li-infra"
      ~ instances                                         = 2 -> 0
        name                                              = "io-p-azdoa-vmss-li-infra"
        tags                                              = {
            "__AzureDevOpsElasticPool"          = "io-prod-linux"
            "__AzureDevOpsElasticPoolTimeStamp" = "10/8/2024 9:39:12 AM"
        }
        # (24 unchanged attributes hidden)

        # (6 unchanged blocks hidden)
    }

  # module.azdoa_weu.module.azdoa_li_infra.tls_private_key.this_key will be updated in-place
  ~ resource "tls_private_key" "this_key" {
        id                            = "14531208910692e84fa5c5e2c5c127aa067bccf8"
        # (10 unchanged attributes hidden)
    }

  # module.azdoa_weu.module.azdoa_loadtest_li.azurerm_linux_virtual_machine_scale_set.this will be updated in-place
  ~ resource "azurerm_linux_virtual_machine_scale_set" "this" {
        id                                                = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-azdoa-rg/providers/Microsoft.Compute/virtualMachineScaleSets/io-p-azdoa-vmss-loadtest-li"
        name                                              = "io-p-azdoa-vmss-loadtest-li"
        tags                                              = {
            "__AzureDevOpsElasticPool"          = "io-prod-loadtest-linux"
            "__AzureDevOpsElasticPoolTimeStamp" = "2/3/2024 10:56:53 AM"
        }
        # (25 unchanged attributes hidden)

        # (6 unchanged blocks hidden)
    }

  # module.azdoa_weu.module.azdoa_loadtest_li.tls_private_key.this_key will be updated in-place
  ~ resource "tls_private_key" "this_key" {
        id                            = "8feb8c752be6808a3393f79ad8fd66c378e54420"
        # (10 unchanged attributes hidden)
    }

  # module.vpn_weu.module.dns_forwarder.azurerm_container_group.this will be updated in-place
  ~ resource "azurerm_container_group" "this" {
        id                          = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-common/providers/Microsoft.ContainerInstance/containerGroups/io-p-dns-forwarder"
        name                        = "io-p-dns-forwarder"
        tags                        = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
            "Source"      = "https://github.com/pagopa/io-infra/blob/main/src/core/prod"
        }
        # (11 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 6 to change, 0 to destroy.

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

github-actions bot commented Oct 8, 2024

📖 Terraform Plan ('src/legacy-apim/prod') - success

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

Terraform will perform the following actions:

  # azurerm_api_management_named_value.io_fn3_eucovidcert_url_alt_v2 will be updated in-place
  ~ resource "azurerm_api_management_named_value" "io_fn3_eucovidcert_url_alt_v2" {
        id                  = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-internal/providers/Microsoft.ApiManagement/service/io-p-apim-v2-api/namedValues/io-fn3-eucovidcert-url-alt"
        name                = "io-fn3-eucovidcert-url-alt"
        tags                = []
        # (5 unchanged attributes hidden)
    }

  # azurerm_api_management_named_value.io_fn3_services_url_v2 will be updated in-place
  ~ resource "azurerm_api_management_named_value" "io_fn3_services_url_v2" {
        id                  = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-internal/providers/Microsoft.ApiManagement/service/io-p-apim-v2-api/namedValues/io-fn3-services-url"
        name                = "io-fn3-services-url"
        tags                = []
        # (5 unchanged attributes hidden)
    }

Plan: 0 to add, 2 to change, 0 to destroy.

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

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

github-actions bot commented Oct 8, 2024

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

Terraform Plan
data.azurerm_linux_function_app.function_profile[0]: Still reading... [10s elapsed]
data.azurerm_linux_function_app.app_messages_xl[0]: Still reading... [10s elapsed]
data.azurerm_linux_function_app.function_profile[1]: Still reading... [10s elapsed]
data.azurerm_linux_function_app.app_messages_xl[1]: Still reading... [10s elapsed]
data.azurerm_linux_function_app.wallet_user: Still reading... [10s elapsed]
data.azurerm_linux_web_app.firmaconio_selfcare_web_app: Still reading... [10s elapsed]
module.application_gateway_weu.data.azurerm_linux_web_app.fims_op_app: Still reading... [10s elapsed]
data.azurerm_linux_function_app.function_cgn: Still reading... [10s elapsed]
module.application_gateway_weu.data.azurerm_linux_web_app.session_manager_03: Still reading... [10s elapsed]
module.application_gateway_weu.data.azurerm_linux_web_app.session_manager_04: Still reading... [10s elapsed]
data.azurerm_linux_function_app.wallet_user: Still reading... [20s elapsed]
module.application_gateway_weu.data.azurerm_linux_web_app.appservice_devportal_be: Still reading... [10s elapsed]
data.azurerm_linux_function_app.function_assets_cdn: Still reading... [10s elapsed]
data.azurerm_linux_function_app.eucovidcert: Still reading... [10s elapsed]
module.application_gateway_weu.data.azurerm_linux_web_app.cms_backoffice_app_itn: Still reading... [10s elapsed]
data.azurerm_linux_function_app.io_sign_user: Still reading... [10s elapsed]
data.azurerm_linux_function_app.lollipop_function: Still reading... [10s elapsed]
module.application_gateway_weu.data.azurerm_linux_web_app.appservice_continua: Still reading... [10s elapsed]
data.azurerm_linux_function_app.services_app_backend_function_app: Still reading... [10s elapsed]
module.application_gateway_weu.data.azurerm_linux_web_app.appservice_selfcare_be: Still reading... [10s elapsed]

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

Terraform will perform the following actions:

  # module.application_gateway_weu.azurerm_web_application_firewall_policy.api_app will be updated in-place
  ~ resource "azurerm_web_application_firewall_policy" "api_app" {
        id                  = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-external/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/io-p-waf-appgateway-api-app-policy"
        name                = "io-p-waf-appgateway-api-app-policy"
        tags                = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
            "Source"      = "https://github.com/pagopa/io-infra"
        }
        # (4 unchanged attributes hidden)

      ~ policy_settings {
          ~ request_body_inspect_limit_in_kb          = 0 -> 128
            # (6 unchanged attributes hidden)
        }

        # (1 unchanged block hidden)
    }

  # module.cosmos_api_weu.azurerm_cosmosdb_sql_container.these["message-status"] will be updated in-place
  ~ resource "azurerm_cosmosdb_sql_container" "these" {
        id                  = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-internal/providers/Microsoft.DocumentDB/databaseAccounts/io-p-cosmos-api/sqlDatabases/db/containers/message-status"
        name                = "message-status"
        # (8 unchanged attributes hidden)

      ~ autoscale_settings {
          ~ max_throughput = 67000 -> 200000
        }

        # (2 unchanged blocks hidden)
    }

  # module.cosmos_api_weu.azurerm_cosmosdb_sql_container.these["messages"] will be updated in-place
  ~ resource "azurerm_cosmosdb_sql_container" "these" {
        id                  = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-internal/providers/Microsoft.DocumentDB/databaseAccounts/io-p-cosmos-api/sqlDatabases/db/containers/messages"
        name                = "messages"
        # (8 unchanged attributes hidden)

      ~ autoscale_settings {
          ~ max_throughput = 46000 -> 100000
        }

        # (2 unchanged blocks hidden)
    }

  # module.cosmos_api_weu.azurerm_cosmosdb_sql_container.these["profiles"] will be updated in-place
  ~ resource "azurerm_cosmosdb_sql_container" "these" {
        id                  = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-internal/providers/Microsoft.DocumentDB/databaseAccounts/io-p-cosmos-api/sqlDatabases/db/containers/profiles"
        name                = "profiles"
        # (7 unchanged attributes hidden)

      ~ autoscale_settings {
          ~ max_throughput = 48000 -> 100000
        }

        # (2 unchanged blocks hidden)
    }

  # module.app_backend_weu["3"].module.appservice_app_backend.azurerm_linux_web_app.this will be updated in-place
  ~ resource "azurerm_linux_web_app" "this" {
        id                                             = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-linux/providers/Microsoft.Web/sites/io-p-app-appbackendl3"
        name                                           = "io-p-app-appbackendl3"
        tags                                           = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
            "Source"      = "https://github.com/pagopa/io-infra/blob/main/src/common/prod"
        }
        # (22 unchanged attributes hidden)

      ~ site_config {
          ~ health_check_eviction_time_in_min       = 0 -> 2
            # (25 unchanged attributes hidden)

            # (16 unchanged blocks hidden)
        }

        # (1 unchanged block hidden)
    }

  # module.application_gateway_weu.module.app_gw.azurerm_application_gateway.this will be updated in-place
  ~ resource "azurerm_application_gateway" "this" {
        id                                = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-rg-external/providers/Microsoft.Network/applicationGateways/io-p-appgateway"
        name                              = "io-p-appgateway"
        tags                              = {
            "CostCenter"  = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"   = "Terraform"
            "Environment" = "Prod"
            "Owner"       = "IO"
            "Source"      = "https://github.com/pagopa/io-infra"
        }
        # (7 unchanged attributes hidden)

      ~ autoscale_configuration {
          ~ max_capacity = 50 -> 100
          ~ min_capacity = 10 -> 20
        }

        # (86 unchanged blocks hidden)
    }

Plan: 0 to add, 6 to change, 0 to destroy.

Warning: Argument is deprecated

  with module.application_gateway_weu.azurerm_web_application_firewall_policy.api_app,
  on ../_modules/application_gateway/firewall.tf line 60, in resource "azurerm_web_application_firewall_policy" "api_app":
  60:       rule_group_override {

`disabled_rules` will be removed in favour of the `rule` property in version
4.0 of the AzureRM Provider.

(and 50 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.

@mamu0 mamu0 merged commit a88bae1 into main Oct 8, 2024
15 of 21 checks passed
@mamu0 mamu0 deleted the CES-155-update-static-analysis-action branch October 8, 2024 10:55
Copy link

github-actions bot commented Oct 8, 2024

📖 Terraform Plan ('src/domains/elt/prod') - success

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

Terraform will perform the following actions:

  # module.function_apps.module.function_elt.azurerm_linux_function_app.this will be updated in-place
  ~ resource "azurerm_linux_function_app" "this" {
      ~ app_settings                                   = {
          ~ "COSMOSDB_REPLICA_LOCATION"                                                          = "West Europe" -> "North Europe"
          ~ "COSMOSDB_REPLICA_URI"                                                               = "https://io-p-cosmos-api-westeurope.documents.azure.com:443/" -> "https://io-p-cosmos-api-northeurope.documents.azure.com:443/"
            # (94 unchanged elements hidden)
        }
        id                                             = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-elt-rg/providers/Microsoft.Web/sites/io-p-fn-elt"
        name                                           = "io-p-fn-elt"
        tags                                           = {
            "CostCenter"                                     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"                                      = "Terraform"
            "Environment"                                    = "Prod"
            "ManagementTeam"                                 = "IO Platform"
            "Owner"                                          = "IO"
            "Source"                                         = "https://github.com/pagopa/io-infra/blob/main/src/domains/elt/prod"
        }
        # (27 unchanged attributes hidden)

      ~ site_config {
          ~ health_check_eviction_time_in_min       = 2 -> 10
            # (24 unchanged attributes hidden)

            # (8 unchanged blocks hidden)
        }

        # (1 unchanged block hidden)
    }

  # module.function_apps.module.function_elt.azurerm_monitor_metric_alert.function_app_health_check[0] will be updated in-place
  ~ resource "azurerm_monitor_metric_alert" "function_app_health_check" {
        id                  = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-elt-rg/providers/Microsoft.Insights/metricAlerts/[IO-COMMONS | io-p-fn-elt] Health Check Failed"
        name                = "[IO-COMMONS | io-p-fn-elt] Health Check Failed"
        tags                = {}
        # (8 unchanged attributes hidden)

      + action {
          + action_group_id = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-itn-msgs-rg-01/providers/Microsoft.Insights/actionGroups/io-p-com-error-ag-01"
        }

        # (2 unchanged blocks hidden)
    }

  # module.function_apps.module.function_elt.azurerm_service_plan.this[0] will be updated in-place
  ~ resource "azurerm_service_plan" "this" {
        id                           = "/subscriptions/ec285037-c673-4f58-b594-d7c480da4e8b/resourceGroups/io-p-elt-rg/providers/Microsoft.Web/serverFarms/io-p-plan-fnelt"
      ~ maximum_elastic_worker_count = 20 -> 1
        name                         = "io-p-plan-fnelt"
        tags                         = {
            "CostCenter"     = "TS310 - PAGAMENTI & SERVIZI"
            "CreatedBy"      = "Terraform"
            "Environment"    = "Prod"
            "ManagementTeam" = "IO Platform"
            "Owner"          = "IO"
            "Source"         = "https://github.com/pagopa/io-infra/blob/main/src/domains/elt/prod"
        }
        # (9 unchanged attributes hidden)
    }

Plan: 0 to add, 3 to change, 0 to destroy.

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

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.

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.

3 participants