Skip to content

build(terraform): move the azurerm provider to 5.x #5074

Closed as not planned
Closed as not planned

Description

@dan-petty

Problem or Motivation

tf/azure/versions.tf pins the provider hashicorp/azurerm at ~> 3.100. The newest is 5.13 (registry.opentofu.org). Renovate (#4893) will offer two majors. The pin alone fails:

  • 4.0 upgrade guide: the provider block needs subscription_id (or ARM_SUBSCRIPTION_ID). tf/azure/main.tf has provider "azurerm" { features {} }.
  • 4.0: default_node_pool.enable_auto_scaling is renamed auto_scaling_enabled. tf/azure/main.tf sets enable_auto_scaling = true.
  • The 5.0 guide removes more fields of azurerm_kubernetes_cluster, azurerm_subnet and azurerm_virtual_network.

No CI job runs tofu validate on tf/, and tofu is not installed in the devcontainer. The research read only the upgrade guides.

Research of 2026-11-12 (research-ci, record tofu:hashicorp/azurerm).

Proposed Solution & Architectural Design

  • Set ~> 5.13 and make the 4.0 and 5.0 guide edits in tf/azure/main.tf.
  • Run tofu init -backend=false && tofu validate in tf/azure (and tofu plan against a test subscription if one exists). Record the output in the pull request.

Done when tofu validate passes on tf/azure with azurerm 5.13.

Target Subsystem

OpenTofu / Infrastructure as Code

Existing Tool Considered

OpenTofu (tofu validate) and the azurerm upgrade guides. No new code.

Source: #4893

Alternatives check of 2026-11-15: in-use.
The repository already uses this tool.
Tool: renovatebot/renovate (https://github.com/renovatebot/renovate), AGPL-3.0, last activity 2026-11-15, maintained.

Proposed design

Problem statement

tf/azure/versions.tf pins the provider hashicorp/azurerm at ~> 3.100, and the newest release is 5.13. The pin alone fails: azurerm 4.0 takes the subscription id on the provider block (or from ARM_SUBSCRIPTION_ID) and renames default_node_pool.enable_auto_scaling to auto_scaling_enabled, and 5.0 is a further breaking release. The change sets ~> 5.13, applies the guide edits to tf/azure/main.tf and tf/azure/variables.tf, runs tofu init -backend=false && tofu validate in tf/azure with the OpenTofu 1.13.9 that the devcontainer image and the static CI job already install, and locks the edits with offline assertions in tests/security/test_tf_azure_aks_security.py. A permanent tofu validate row in the CI gate goes to a new issue, because the gate row, the provider lock file and its time budget are a change of their own.

Acceptance criteria

Requirement: Azurerm version pin

tf/azure/versions.tf SHALL pin the provider hashicorp/azurerm at ~> 5.13.

Scenario: Offline test reads the azurerm constraint

  • WHEN the test reads the version of the azurerm provider in tf/azure/versions.tf
  • THEN the value is exactly ~> 5.13

Requirement: Subscription id variable

tf/azure/variables.tf SHALL declare variable "subscription_id" with type string and default = null.

Scenario: Variable declares a null default

  • WHEN the test reads tf/azure/variables.tf
  • THEN exactly one variable "subscription_id" block exists, and it sets type = string and default = null

Requirement: Provider subscription id

The provider "azurerm" block in tf/azure/main.tf MUST set subscription_id from the input variable subscription_id.

Scenario: Provider block passes the variable

  • WHEN the test reads the provider "azurerm" block in tf/azure/main.tf
  • THEN the block sets subscription_id = var.subscription_id

Requirement: No literal subscription id

The provider "azurerm" block in tf/azure/main.tf MUST NOT hold a literal subscription id.

Scenario: Provider block holds no GUID literal

  • WHEN the test scans the provider "azurerm" block of tf/azure/main.tf for a UUID literal
  • THEN no UUID literal occurs in the block

Requirement: Node pool autoscaling field

The default_node_pool block of tf/azure/main.tf SHALL use auto_scaling_enabled and MUST NOT set enable_auto_scaling.

Scenario: Node pool uses the new name

  • WHEN the test reads the default_node_pool block in tf/azure/main.tf
  • THEN the block sets auto_scaling_enabled = true and holds no enable_auto_scaling

Requirement: Offline test module passes

tests/security/test_tf_azure_aks_security.py MUST pass with no network access.

Scenario: Run the security test module offline

  • WHEN the test runner runs tests/security/test_tf_azure_aks_security.py with no network
  • THEN every test in the module passes, including the existing network_profile and no-IP-literal assertions

Existing Tool Considered

renovatebot/renovate (https://github.com/renovatebot/renovate, AGPL-3.0, last activity 2026-11-15) is maintained, and the repository already runs it (docs/adr/0027-dependency-updates-come-from-self-hosted-renovate.md). It opens the pull request that raises hashicorp/azurerm in tf/azure/versions.tf to 5.x and keeps the pin current. It lacks the code migration: subscription_id on the provider block, the auto_scaling_enabled rename, the 5.0 removals, and the tofu validate run. minamijoyo/tfupdate only rewrites version constraints. The validation needs no new tool: OpenTofu 1.13.9 is already in the devcontainer image (.devcontainer/Dockerfile:206) and the static CI job (.github/workflows/ci.yml:80), so tofu init -backend=false && tofu validate covers the schema check. The change builds no code: it edits HCL and adds offline test assertions.

Key questions

  • Which azurerm version does tf/azure pin now, and which version does the change target?: tf/azure/versions.tf:7 pins hashicorp/azurerm at ~> 3.100. The change sets ~> 5.13, the newest release that the issue names. [sources: tf/azure/versions.tf:7]
  • Where does tf/azure/main.tf hold the provider block and the autoscaling argument?: The provider "azurerm" block is at tf/azure/main.tf:1 and holds only features {}. The default_node_pool block sets enable_auto_scaling = true at tf/azure/main.tf:56. [sources: tf/azure/main.tf:1, tf/azure/main.tf:56]
  • Which edits do the azurerm 4.0 and 5.0 upgrade guides require for tf/azure?: The 4.0 guide renames the deprecated default_node_pool.enable_auto_scaling to auto_scaling_enabled and moves the subscription id to the provider block or ARM_SUBSCRIPTION_ID; it also renames enable_node_public_ip to node_public_ip_enabled, which tf/azure/main.tf does not use. The 5.0 guide is a further breaking-change guide for 4.x to 5.0. No hand-written list of the 5.0 removals is kept: the provider schema, checked by tofu init -backend=false && tofu validate with azurerm 5.13, is the authority, and the change fixes each error that the run reports. [sources: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/4.0-upgrade-guide, https://library.tf/providers/hashicorp/azurerm/latest/docs/guides/4.0-upgrade-guide, https://github.com/hashicorp/terraform-provider-azurerm/blob/main/website/docs/guides/5.0-upgrade-guide.html.markdown]
  • Is OpenTofu installed in the devcontainer and in CI?: Yes. The issue premise is out of date. The devcontainer image installs OpenTofu 1.13.9 from the pin with a sha256 check (.devcontainer/Dockerfile:206), the static CI job installs it with uv run devops install-tools --tool tofu --only-missing (.github/workflows/ci.yml:80), and openspec/specs/devcontainer-image-tools/spec.md:67 requires it in the runner image and the CI test job. So the change runs tofu init -backend=false && tofu validate and needs no image work. [sources: .github/workflows/ci.yml:80, openspec/specs/devcontainer-image-tools/spec.md:67]
  • Does any CI check validate tf/?: No. The devops ci gate holds 26 rows (src/devops_cli/commands/ci.py:120) and none of them runs tofu validate on tf/; the archived proposal of build(deps): take every safe version update before Renovate #5065 records the same gap. That is why a permanent gate row is a new issue. [sources: src/devops_cli/commands/ci.py:120, openspec/changes/archive/2026-11-12-5065-take-every-safe-version-update-before/proposal.md:45]
  • How does the provider block get the subscription id?: Add variable "subscription_id" with type = string and default = null, and set subscription_id = var.subscription_id in the provider block. The null default keeps the provider's ARM_SUBSCRIPTION_ID fallback, and variables.tf holds the declared input. (best practice) [sources: tf/azure/main.tf:1, tf/azure/variables.tf, https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/4.0-upgrade-guide]
    • Chosen: Variable with default = null. A null value keeps the provider's ARM_SUBSCRIPTION_ID fallback, and variables.tf holds the declared input, as it does for every other input of the module.
    • Rejected: Variable with no default. It breaks the runs that set only ARM_SUBSCRIPTION_ID.
    • Rejected: Literal subscription id. It writes a tenant value into a public repository.
    • Rejected: Leave the block and rely on ARM_SUBSCRIPTION_ID alone. The 4.0 guide accepts it, but the configuration then declares no input for the subscription.
  • Where do the offline checks of the Terraform files live?: Add the assertions to tests/security/test_tf_azure_aks_security.py. (best practice) [sources: tests/security/test_tf_azure_aks_security.py:14, tests/security/test_tf_azure_aks_security.py:21]
    • Chosen: Extend tests/security/test_tf_azure_aks_security.py. The module already reads tf/azure/main.tf and tf/azure/variables.tf and asserts their AKS arguments, so the new assertions need no new file reads.
    • Rejected: New test module under tests/security/. It duplicates the file reads and the fixtures of the existing module.
    • Rejected: tofu validate CI job. No gate row validates tf/, and a new row is a change of its own; the offline assertions lock the edits in this change.
  • How is the tofu validate gate delivered?: The change runs tofu init -backend=false && tofu validate in tf/azure with the installed OpenTofu 1.13.9 and records the output in the pull request; a new issue adds the permanent CI gate. A hand-written list of the 5.0 removed fields is not kept, because the provider schema is the authority. (best practice) [sources: .github/workflows/ci.yml:80, .github/workflows/ci.yml:51, src/devops_cli/commands/ci.py:120]
    • Chosen: Run tofu init -backend=false && tofu validate in this change and defer the CI row. OpenTofu 1.13.9 is already in the image and the static job, so the issue's done-when is reachable now; the gate row needs a provider lock file and a time budget of its own.
    • Rejected: Keep a hand-written list of the 5.0 removed fields in the offline test. The list is a hand-maintained copy of the upgrade guide and proves nothing about the 5.13 schema; tofu validate reports the removed arguments itself.
    • Rejected: Add the tofu validate step to the static CI job now. The static job has a 6-minute timeout (.github/workflows/ci.yml:51), tf/azure holds no .terraform.lock.hcl, and the init downloads three providers; that work belongs in its own issue.
    • Rejected: Defer the whole validation. OpenTofu is installed in the devcontainer and in CI, so the run is possible now.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/infra
    scope/terraform
    status/new
    value/medium
    effort/medium
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches found no tool that performs the azurerm 3.x→5.x code migration: the upgrade guides are documentation, and tfupdate only rewrites version constraints. Renovate, which the issue already relies on (#4893), covers only the version-pin half by opening a pull request that raises hashicorp/azurerm to 5.x, leaving the breaking-change edits in tf/azure/main.tf and the tofu validate gate to a person.

    The repository already uses this tool.

    Tool: renovatebot/renovate (https://github.com/renovatebot/renovate)

    • License: AGPL-3.0
    • Last activity: 2026-11-15
    • Maintained: yes

    Covers:

    • Opens a pull request that raises the hashicorp/azurerm constraint in tf/azure/versions.tf from ~> 3.100 to ~> 5.13
    • Keeps the provider pin current on later 5.x releases

    Lacks:

    • Does not rewrite tf/azure/main.tf for the 4.0 breaking changes: provider "azurerm" needs subscription_id (or ARM_SUBSCRIPTION_ID)
    • Does not rename default_node_pool.enable_auto_scaling to auto_scaling_enabled
    • Does not remove the azurerm_kubernetes_cluster, azurerm_subnet and azurerm_virtual_network fields that the 5.0 guide drops
    • Does not run tofu init -backend=false && tofu validate or add a CI job that validates tf/

    Tools considered:

    Searches run:

    • tool to migrate azurerm provider 3.x to 5.x breaking changes, results: 5
    • OpenTofu tofu validate GitHub Actions azurerm provider, results: 5
    • tfupdate update terraform provider version constraint tool, results: 5
    • tfupdate github terraform provider version updater, results: 5
    • azurerm 5.0 upgrade guide breaking changes kubernetes cluster, results: 5
    • hashicorp azurerm provider, results: 5
    • opentofu, results: 5
    • renovate terraform provider updates, results: 5
    • tfupdate, results: 5
    • azurerm 5.0 upgrade guide removed arguments, results: 5

    Sources:

    Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.

  6. added
    status/ready
    and removed
    status/new
    on Nov 16, 2026
  7. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 3355a77 (see proposed design in issue body).

    Moved to new items: #6074.

  8. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor

    Closed as not planned. The hand-written tf/azure stub, which this item upgrades to azurerm 5.x, was never applied. dan-petty/infra#9 rebuilds the AKS cluster on the Azure Verified Module at an exact registry version, and #6679 deletes tf/azure. The provider pin then lives in infra, and Renovate updates it there (ADR 0032, #6674).

  9. removed
    status/ready
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/terraformsource/agenttype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions