Skip to content

Commit

Permalink
feat: Devops agent update. moved to next-core (#2037)
Browse files Browse the repository at this point in the history
* moved devops agent to next-core

* fix name
  • Loading branch information
mamari90 authored May 16, 2024
1 parent d83abc2 commit 091099c
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
resource "azurerm_resource_group" "azdo_rg" {
count = var.enable_azdoa ? 1 : 0
name = "${local.project}-azdoa-rg"
count = var.is_feature_enabled.azdoa ? 1 : 0
name = "${local.product}-azdoa-rg"
location = var.location

tags = var.tags
}

module "azdoa_snet" {
source = "git::https://github.com/pagopa/azurerm.git//subnet?ref=v3.5.0"
count = var.enable_azdoa ? 1 : 0
name = "${local.project}-azdoa-snet"
address_prefixes = var.cidr_subnet_azdoa
resource_group_name = azurerm_resource_group.rg_vnet.name
virtual_network_name = module.vnet.name
enforce_private_link_endpoint_network_policies = true
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//subnet?ref=v8.13.0"
count = var.is_feature_enabled.azdoa ? 1 : 0
name = "${local.product}-azdoa-snet"
address_prefixes = var.cidr_subnet_azdoa
resource_group_name = data.azurerm_resource_group.rg_vnet.name
virtual_network_name = data.azurerm_virtual_network.vnet_core.name
private_endpoint_network_policies_enabled = false

service_endpoints = [
"Microsoft.Storage",
]
}


module "azdoa_li_app" {
source = "git::https://github.com/pagopa/azurerm.git//azure_devops_agent?ref=v4.20.0"
count = var.enable_azdoa ? 1 : 0
name = "${local.project}-azdoa-vmss-ubuntu-app"
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//azure_devops_agent?ref=v8.13.0"
count = var.is_feature_enabled.azdoa ? 1 : 0
name = "${local.product}-azdoa-vmss-ubuntu-app"
resource_group_name = azurerm_resource_group.azdo_rg[0].name
subnet_id = module.azdoa_snet[0].id
subscription_name = data.azurerm_subscription.current.display_name
subscription_id = data.azurerm_subscription.current.subscription_id
location = var.location
image_type = "custom" # enables usage of "source_image_name"
Expand All @@ -41,12 +39,11 @@ module "azdoa_li_app" {
}

module "azdoa_li_infra" {
source = "git::https://github.com/pagopa/azurerm.git//azure_devops_agent?ref=v4.20.0"
count = var.enable_azdoa ? 1 : 0
name = "${local.project}-azdoa-vmss-ubuntu-infra"
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//azure_devops_agent?ref=v8.13.0"
count = var.is_feature_enabled.azdoa ? 1 : 0
name = "${local.product}-azdoa-vmss-ubuntu-infra"
resource_group_name = azurerm_resource_group.azdo_rg[0].name
subnet_id = module.azdoa_snet[0].id
subscription_name = data.azurerm_subscription.current.display_name
subscription_id = data.azurerm_subscription.current.subscription_id
location = var.location
image_type = "custom" # enables usage of "source_image_name"
Expand All @@ -64,13 +61,13 @@ module "azdoa_li_infra" {
#

module "loadtest_agent_snet" {
count = var.env_short != "p" ? 1 : 0
source = "git::https://github.com/pagopa/azurerm.git//subnet?ref=v3.5.0"
name = "${local.project}-loadtest-agent-snet"
address_prefixes = var.cidr_subnet_loadtest_agent
resource_group_name = azurerm_resource_group.rg_vnet.name
virtual_network_name = module.vnet.name

count = var.env_short != "p" ? 1 : 0
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//subnet?ref=v8.13.0"
name = "${local.product}-loadtest-agent-snet"
address_prefixes = var.cidr_subnet_loadtest_agent
resource_group_name = data.azurerm_resource_group.rg_vnet.name
virtual_network_name = data.azurerm_virtual_network.vnet_core.name
private_endpoint_network_policies_enabled = true

service_endpoints = [
"Microsoft.Web",
Expand All @@ -79,13 +76,13 @@ module "loadtest_agent_snet" {
]
}


module "azdoa_loadtest_li" {
source = "git::https://github.com/pagopa/azurerm.git//azure_devops_agent?ref=v4.20.0"
source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//azure_devops_agent?ref=v8.13.0"
count = var.env_short != "p" ? 1 : 0
name = "${local.project}-azdoa-vmss-loadtest-li"
name = "${local.product}-azdoa-vmss-loadtest-li"
resource_group_name = azurerm_resource_group.azdo_rg[0].name
subnet_id = module.azdoa_snet[0].id
subscription_name = data.azurerm_subscription.current.display_name
subscription_id = data.azurerm_subscription.current.subscription_id
location = var.location
image_type = "custom" # enables usage of "source_image_name"
Expand All @@ -99,6 +96,7 @@ module "azdoa_loadtest_li" {
tags = var.tags
}


#
# Policy
#
Expand All @@ -112,7 +110,7 @@ data "azurerm_user_assigned_identity" "iac_federated_azdo" {
resource "azurerm_key_vault_access_policy" "azdevops_iac_managed_identities" {
for_each = local.azdo_iac_managed_identities

key_vault_id = module.key_vault.id
key_vault_id = data.azurerm_key_vault.kv_core.id
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = data.azurerm_user_assigned_identity.iac_federated_azdo[each.key].principal_id

Expand Down Expand Up @@ -142,7 +140,7 @@ resource "azurerm_key_vault_access_policy" "azdevops_iac_legacy_policies" {
data.azuread_service_principal.iac_plan_legacy.object_id,
data.azuread_service_principal.iac_deploy_legacy.object_id
])
key_vault_id = module.key_vault.id
key_vault_id = data.azurerm_key_vault.kv_core.id
tenant_id = data.azurerm_client_config.current.tenant_id
object_id = each.key

Expand All @@ -152,3 +150,4 @@ resource "azurerm_key_vault_access_policy" "azdevops_iac_legacy_policies" {

storage_permissions = []
}

4 changes: 4 additions & 0 deletions src/next-core/99_locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ locals {
integration_appgateway_private_ip = ["10.230.10.200"]

msg_resource_group_name = "${local.product}-msg-rg"

azdo_iac_managed_identities = toset(["azdo-${var.env}-pagopa-iac-deploy", "azdo-${var.env}-pagopa-iac-plan"])
azdo_managed_identity_rg_name = "pagopa-${var.env_short}-identity-rg"

}
23 changes: 23 additions & 0 deletions src/next-core/99_variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ variable "is_feature_enabled" {
vpn = optional(bool, false)
dns_forwarder_lb = optional(bool, false)
postgres_private_dns = bool
azdoa = optional(bool, true)
})
description = "Features enabled in this domain"
}
Expand Down Expand Up @@ -682,4 +683,26 @@ variable "node_forwarder_sku" {
default = "P3v3"
}

variable "devops_agent_zones" {
type = list(number)
default = null
description = "(Optional) List of zones in which the scale set for azdo agent will be deployed"
}

variable "devops_agent_balance_zones" {
type = bool
default = false
description = "(Optional) True if the devops agent instances must be evenly balanced between the configured zones"
}

variable "cidr_subnet_azdoa" {
type = list(string)
description = "Azure DevOps agent network address space."
}

variable "cidr_subnet_loadtest_agent" {
type = list(string)
description = "LoadTest Agent Pool address space"
default = null
}

17 changes: 16 additions & 1 deletion src/next-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@
| <a name="module_apimv2"></a> [apimv2](#module\_apimv2) | git::https://github.com/pagopa/terraform-azurerm-v3.git//api_management | v7.67.1 |
| <a name="module_apimv2_snet"></a> [apimv2\_snet](#module\_apimv2\_snet) | git::https://github.com/pagopa/terraform-azurerm-v3.git//subnet | v7.50.0 |
| <a name="module_app_gw_integration"></a> [app\_gw\_integration](#module\_app\_gw\_integration) | git::https://github.com/pagopa/terraform-azurerm-v3.git//app_gateway | v7.50.0 |
| <a name="module_azdoa_li_app"></a> [azdoa\_li\_app](#module\_azdoa\_li\_app) | git::https://github.com/pagopa/terraform-azurerm-v3.git//azure_devops_agent | v8.13.0 |
| <a name="module_azdoa_li_infra"></a> [azdoa\_li\_infra](#module\_azdoa\_li\_infra) | git::https://github.com/pagopa/terraform-azurerm-v3.git//azure_devops_agent | v8.13.0 |
| <a name="module_azdoa_loadtest_li"></a> [azdoa\_loadtest\_li](#module\_azdoa\_loadtest\_li) | git::https://github.com/pagopa/terraform-azurerm-v3.git//azure_devops_agent | v8.13.0 |
| <a name="module_azdoa_snet"></a> [azdoa\_snet](#module\_azdoa\_snet) | git::https://github.com/pagopa/terraform-azurerm-v3.git//subnet | v8.13.0 |
| <a name="module_dns_forwarder_backup_snet"></a> [dns\_forwarder\_backup\_snet](#module\_dns\_forwarder\_backup\_snet) | git::https://github.com/pagopa/terraform-azurerm-v3.git//subnet | v7.76.0 |
| <a name="module_dns_forwarder_backup_vmss_li"></a> [dns\_forwarder\_backup\_vmss\_li](#module\_dns\_forwarder\_backup\_vmss\_li) | git::https://github.com/pagopa/terraform-azurerm-v3.git//dns_forwarder_scale_set_vm | v7.76.0 |
| <a name="module_domain_key_vault_secrets_query"></a> [domain\_key\_vault\_secrets\_query](#module\_domain\_key\_vault\_secrets\_query) | git::https://github.com/pagopa/terraform-azurerm-v3.git//key_vault_secrets_query | v7.50.0 |
| <a name="module_event_hub03"></a> [event\_hub03](#module\_event\_hub03) | git::https://github.com/pagopa/terraform-azurerm-v3.git//eventhub | v7.62.0 |
| <a name="module_event_hub04"></a> [event\_hub04](#module\_event\_hub04) | git::https://github.com/pagopa/terraform-azurerm-v3.git//eventhub | v7.62.0 |
| <a name="module_integration_appgateway_snet"></a> [integration\_appgateway\_snet](#module\_integration\_appgateway\_snet) | git::https://github.com/pagopa/terraform-azurerm-v3.git//subnet | v7.50.0 |
| <a name="module_loadtest_agent_snet"></a> [loadtest\_agent\_snet](#module\_loadtest\_agent\_snet) | git::https://github.com/pagopa/terraform-azurerm-v3.git//subnet | v8.13.0 |
| <a name="module_logos_donation_flows_sa"></a> [logos\_donation\_flows\_sa](#module\_logos\_donation\_flows\_sa) | git::https://github.com/pagopa/terraform-azurerm-v3.git//storage_account | v7.50.0 |
| <a name="module_monitor"></a> [monitor](#module\_monitor) | git::https://github.com/pagopa/azurerm.git//api_management_api | v1.0.90 |
| <a name="module_node_forwarder_app_service"></a> [node\_forwarder\_app\_service](#module\_node\_forwarder\_app\_service) | git::https://github.com/pagopa/terraform-azurerm-v3.git//app_service | v7.69.1 |
Expand Down Expand Up @@ -99,6 +104,8 @@
| [azurerm_container_app_environment.tools_cae](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_app_environment) | resource |
| [azurerm_key_vault_access_policy.api_management_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy) | resource |
| [azurerm_key_vault_access_policy.app_gateway_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy) | resource |
| [azurerm_key_vault_access_policy.azdevops_iac_legacy_policies](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy) | resource |
| [azurerm_key_vault_access_policy.azdevops_iac_managed_identities](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_access_policy) | resource |
| [azurerm_monitor_autoscale_setting.node_forwarder_app_service_autoscale](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_autoscale_setting) | resource |
| [azurerm_monitor_metric_alert.app_service_over_cpu_usage](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_metric_alert) | resource |
| [azurerm_monitor_metric_alert.app_service_over_mem_usage](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_metric_alert) | resource |
Expand All @@ -108,6 +115,7 @@
| [azurerm_private_dns_zone_virtual_network_link.private_db_zone_to_core_vnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_dns_zone_virtual_network_link) | resource |
| [azurerm_public_ip.apimv2_public_ip](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip) | resource |
| [azurerm_public_ip.integration_appgateway_public_ip](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip) | resource |
| [azurerm_resource_group.azdo_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
| [azurerm_resource_group.tools_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | resource |
| [azurerm_role_assignment.data_contributor_role_donations](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) | resource |
| [azurerm_storage_blob.donation_logo10](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_blob) | resource |
Expand All @@ -132,6 +140,8 @@
| [azuread_group.adgroup_developers](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/group) | data source |
| [azuread_group.adgroup_externals](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/group) | data source |
| [azuread_group.adgroup_security](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/group) | data source |
| [azuread_service_principal.iac_deploy_legacy](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/service_principal) | data source |
| [azuread_service_principal.iac_plan_legacy](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/service_principal) | data source |
| [azurerm_api_management.apim](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/api_management) | data source |
| [azurerm_application_insights.application_insights](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/application_insights) | data source |
| [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) | data source |
Expand Down Expand Up @@ -178,6 +188,7 @@
| [azurerm_subnet.node_forwarder_snet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/subnet) | data source |
| [azurerm_subnet.redis_subnet](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_user_assigned_identity.iac_federated_azdo](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/user_assigned_identity) | data source |
| [azurerm_virtual_network.vnet_core](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/virtual_network) | data source |
| [azurerm_virtual_network.vnet_integration](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/virtual_network) | data source |

Expand Down Expand Up @@ -219,12 +230,16 @@
| <a name="input_checkout_enabled"></a> [checkout\_enabled](#input\_checkout\_enabled) | apim named values | `bool` | `true` | no |
| <a name="input_cidr_subnet_apim"></a> [cidr\_subnet\_apim](#input\_cidr\_subnet\_apim) | (Required) APIM v2 subnet cidr | `list(string)` | n/a | yes |
| <a name="input_cidr_subnet_appgateway_integration"></a> [cidr\_subnet\_appgateway\_integration](#input\_cidr\_subnet\_appgateway\_integration) | Address prefixes subnet integration appgateway. | `list(string)` | `null` | no |
| <a name="input_cidr_subnet_azdoa"></a> [cidr\_subnet\_azdoa](#input\_cidr\_subnet\_azdoa) | Azure DevOps agent network address space. | `list(string)` | n/a | yes |
| <a name="input_cidr_subnet_dns_forwarder_backup"></a> [cidr\_subnet\_dns\_forwarder\_backup](#input\_cidr\_subnet\_dns\_forwarder\_backup) | Address prefixes subnet dns forwarder backup. | `list(string)` | `null` | no |
| <a name="input_cidr_subnet_loadtest_agent"></a> [cidr\_subnet\_loadtest\_agent](#input\_cidr\_subnet\_loadtest\_agent) | LoadTest Agent Pool address space | `list(string)` | `null` | no |
| <a name="input_cidr_subnet_tools_cae"></a> [cidr\_subnet\_tools\_cae](#input\_cidr\_subnet\_tools\_cae) | Tool container app env, network address space. | `list(string)` | n/a | yes |
| <a name="input_cidr_subnet_vpn"></a> [cidr\_subnet\_vpn](#input\_cidr\_subnet\_vpn) | VPN network address space. | `list(string)` | <pre>[<br> ""<br>]</pre> | no |
| <a name="input_cidr_vnet_italy"></a> [cidr\_vnet\_italy](#input\_cidr\_vnet\_italy) | Address prefixes for vnet in italy. | `list(string)` | n/a | yes |
| <a name="input_create_redis_multiaz"></a> [create\_redis\_multiaz](#input\_create\_redis\_multiaz) | (Optional) true if a multi az premium instance of redis is required | `bool` | `false` | no |
| <a name="input_default_node_id"></a> [default\_node\_id](#input\_default\_node\_id) | Default NodeId according to default base url | `string` | n/a | yes |
| <a name="input_devops_agent_balance_zones"></a> [devops\_agent\_balance\_zones](#input\_devops\_agent\_balance\_zones) | (Optional) True if the devops agent instances must be evenly balanced between the configured zones | `bool` | `false` | no |
| <a name="input_devops_agent_zones"></a> [devops\_agent\_zones](#input\_devops\_agent\_zones) | (Optional) List of zones in which the scale set for azdo agent will be deployed | `list(number)` | `null` | no |
| <a name="input_dns_forwarder_vm_image_name"></a> [dns\_forwarder\_vm\_image\_name](#input\_dns\_forwarder\_vm\_image\_name) | Image name for dns forwarder | `string` | `null` | no |
| <a name="input_dns_zone_internal_prefix"></a> [dns\_zone\_internal\_prefix](#input\_dns\_zone\_internal\_prefix) | The dns subdomain. | `string` | `null` | no |
| <a name="input_dns_zone_prefix"></a> [dns\_zone\_prefix](#input\_dns\_zone\_prefix) | The dns subdomain. | `string` | `null` | no |
Expand Down Expand Up @@ -254,7 +269,7 @@
| <a name="input_integration_appgateway_private_ip"></a> [integration\_appgateway\_private\_ip](#input\_integration\_appgateway\_private\_ip) | Integration app gateway private ip | `string` | n/a | yes |
| <a name="input_integration_appgateway_zones"></a> [integration\_appgateway\_zones](#input\_integration\_appgateway\_zones) | Integration app gateway private ip | `list(number)` | n/a | yes |
| <a name="input_ip_nodo"></a> [ip\_nodo](#input\_ip\_nodo) | Nodo pagamenti ip | `string` | n/a | yes |
| <a name="input_is_feature_enabled"></a> [is\_feature\_enabled](#input\_is\_feature\_enabled) | Features enabled in this domain | <pre>object({<br> vnet_ita = bool,<br> container_app_tools_cae = optional(bool, false),<br> node_forwarder_ha_enabled = bool<br> vpn = optional(bool, false)<br> dns_forwarder_lb = optional(bool, false)<br> postgres_private_dns = bool<br> })</pre> | n/a | yes |
| <a name="input_is_feature_enabled"></a> [is\_feature\_enabled](#input\_is\_feature\_enabled) | Features enabled in this domain | <pre>object({<br> vnet_ita = bool,<br> container_app_tools_cae = optional(bool, false),<br> node_forwarder_ha_enabled = bool<br> vpn = optional(bool, false)<br> dns_forwarder_lb = optional(bool, false)<br> postgres_private_dns = bool<br> azdoa = optional(bool, true)<br> })</pre> | n/a | yes |
| <a name="input_lb_aks"></a> [lb\_aks](#input\_lb\_aks) | IP load balancer AKS Nexi/SIA | `string` | `"0.0.0.0"` | no |
| <a name="input_location"></a> [location](#input\_location) | One of westeurope, northeurope | `string` | n/a | yes |
| <a name="input_location_ita"></a> [location\_ita](#input\_location\_ita) | Main location | `string` | `"italynorth"` | no |
Expand Down
Loading

0 comments on commit 091099c

Please sign in to comment.