Skip to main content

Using DX Azure Terraform Provider

The DX Azure Terraform provider simplifies the creation and management of Azure resources by enforcing standardized naming conventions and configurations. This provider is maintained by the PagoPA organization and is available in the Terraform Registry under the namespace pagopa-dx.

note

This documentation is relevant for all individual contributors using the DX Azure Terraform provider.

Why Use the DX Azure Provider?

The DX Azure provider offers several advantages for managing Azure resources:

  • Consistency: Ensures resources follow a unified naming convention, reducing errors and improving maintainability.
  • Ease of Use: Abstracts complex configurations into reusable functions, simplifying resource creation.
  • Integration: Seamlessly integrates with Terraform workflows and pipelines, enabling efficient infrastructure management.

Installation

To use the DX Azure provider, include it in your Terraform configuration as follows:

terraform {
required_providers {
dx = {
source = "pagopa-dx/azure"
version = "~> 0.0"
}
}
}

provider "dx" {}

Provider Configuration

The DX Azure provider accepts the following inputs (all currently optional):

NameTypeRequiredDescription
prefixStringNoTwo-character project prefix.
environmentStringNoDeployment environment (d, u, or p).
locationStringNoDeployment location (itn/italynorth or weu/westeurope).
domainStringNoOptional domain for naming.

Functions

The DX Azure provider includes a resource_name function to generate standardized resource names.

resource_name Function

Generates a resource name based on the standardized prefix and additional parameters.

Inputs

NameTypeRequiredDescription
prefixStringYesPrefix that defines the repository domain.
environmentStringYesDeployment environment (d, u, or p).
locationStringYesDeployment location (itn, weu, italynorth or westeurope).
domainStringNoOptional value specifying the domain.
nameStringYesName of the resource.
resource_typeStringYesType of the resource. The list of supported resource types can be found in the documentation table.
instance_numberIntegerYesInstance number of the resource.

Example

output "resource_name" {
value = provider::dx::resource_name({
prefix = "dx",
environment = "d",
location = "itn",
domain = "test",
name = "app",
resource_type = "api_management",
instance_number = 1,
})
}

Output: dx-d-itn-app-apim-pep-01

note

To call a function, use the syntax: provider::PROVIDER_NAME::FUNCTION_NAME(...).

Semantic Versioning

The DX Azure provider follows semantic versioning, which ensures compatibility and stability across updates. When specifying the provider version in your Terraform configuration, use the ~> operator to allow updates within the same major version:

version = "~> 0.0"

This ensures that breaking changes are avoided while allowing minor updates and patches. For example:

  • ~> 0.0 allows updates to 0.x.x but not 1.0.0.

When publishing a new release, ensure the version tag starts with a v (e.g., v0.1.0) as required by the Terraform Registry.

Getting Support

For assistance with the DX Azure provider:

  • Join the #team_devex_help channel for direct support.
  • Provide specific error messages or logs when seeking help.
  • Share your Terraform configuration and provider setup details.

The DX Azure provider is designed to simplify and standardize Azure resource management. Don't hesitate to reach out for help as you integrate it into your workflows.