Repository navigation
feat(provisioner): Azure (azurerm) backend auto-provisioning - #2911
Conversation
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
Dependency ReviewThe following issues were found:
License Issuesgo.mod
Scanned Files
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughAdds AzureRM backend provisioning with secure defaults, idempotent resource reuse, blob protection, lease-based locking, force-gated deletion, registry integration, tests, documentation, and Azure SDK dependencies. It also separates Azure tenant environment variables by authentication mode. ChangesAzureRM backend lifecycle
Azure authentication environment handling
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant BackendRegistry
participant CreateAzurermBackend
participant AzureBackendClient
participant AzureResourceManager
participant AzureBlobStorage
BackendRegistry->>CreateAzurermBackend: invoke AzureRM backend creation
CreateAzurermBackend->>AzureBackendClient: load Azure clients
CreateAzurermBackend->>AzureResourceManager: ensure resource group and storage account
CreateAzurermBackend->>AzureBlobStorage: apply protection and create private container
AzureBlobStorage-->>CreateAzurermBackend: return provisioning result
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (3)
pkg/provisioner/backend/azurerm_test.go (2)
286-330: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the storage account tags in the full-create test.
The mock captures
createdAccountParams, and the PRD statesName=<account>andManagedBy=Atmosare hardcoded defaults. The test does not check them, so a regression inazureBackendTagswould pass. The captured params make this a two-line assertion.💚 Proposed test addition
require.NotNil(t, mock.createdAccountParams) assert.Equal(t, "centralus", mock.createdAccountParams.location, "account created in identity location") assert.True(t, mock.createdAccountParams.disableSharedKey, "shared key disabled when use_azuread_auth is true") + require.NotNil(t, mock.createdAccountParams.tags["Name"]) + require.NotNil(t, mock.createdAccountParams.tags["ManagedBy"]) + assert.Equal(t, "stcwtfstate", *mock.createdAccountParams.tags["Name"]) + assert.Equal(t, "Atmos", *mock.createdAccountParams.tags["ManagedBy"])🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/provisioner/backend/azurerm_test.go` around lines 286 - 330, Extend TestCreateAzurermBackend_FullCreate to assert the captured mock.createdAccountParams tags include the hardcoded defaults Name=stcwtfstate and ManagedBy=Atmos, alongside the existing account parameter assertions.
486-507: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the sentinel in the "account check error" case after the wrapping fix.
This case only calls
require.Error. It passes with any error, including the raw ARM error. OnceAzurermBackendExistswraps the failure (see the comment onpkg/provisioner/backend/azurerm.golines 240-248), addassert.ErrorIs(t, err, errUtils.ErrCheckStorageAccountExist)so the test pins the contract. Every other error test in this file asserts a sentinel.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/provisioner/backend/azurerm_test.go` around lines 486 - 507, Update the “account check error” case in the AzurermBackendExists table test to assert that the returned error matches errUtils.ErrCheckStorageAccountExist using assert.ErrorIs, while retaining the existing require.Error check and behavior for other cases.pkg/provisioner/backend/azurerm.go (1)
255-273: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReturn the sentinels directly instead of
fmt.Errorf("%w", err).
fmt.Errorf("%w", errUtils.ErrX)adds no context. It only allocates a wrapper with an identical message. Either return the sentinel, or useerrUtils.Buildto attach a hint that names the missing key, which is more useful to the user.♻️ Proposed refactor
storageAccount, ok := backendConfig["storage_account_name"].(string) if !ok || storageAccount == "" { - return nil, fmt.Errorf("%w", errUtils.ErrStorageAccountRequired) + return nil, errUtils.Build(errUtils.ErrStorageAccountRequired). + WithHint("Set `backend.storage_account_name` in the component configuration"). + Err() }Apply the same pattern to the
container_name,resource_group_name, and subscription checks.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/provisioner/backend/azurerm.go` around lines 255 - 273, Update the validation checks in the backend configuration flow to return the relevant errUtils sentinel directly instead of wrapping it with fmt.Errorf("%w", ...). Apply this to storage_account_name, container_name, resource_group_name, and the subscriptionID check, preserving the existing validation and return behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@go.mod`:
- Around line 482-483: Update the Azure SDK dependencies in go.mod to use the
current armstorage/v4 module at v4.1.0 instead of the stale armstorage v1.8.1
entry, and remove armresources and armstorage entries from go.mod and go.sum
when no code imports them. Ensure the resulting dependency files contain only
required, correctly versioned direct dependencies.
In `@pkg/provisioner/backend/azurerm_delete.go`:
- Around line 40-68: Remove the direct ui.Info and ui.Successf calls from the
deletion callback in DeleteBackendWithParams, including the visible Azure
deletion messages. Defer or collect these messages so they are emitted only
after spinner execution completes, preserving the existing message content and
deletion flow; apply the same pattern to DeleteS3Backend.
In `@pkg/provisioner/backend/azurerm.go`:
- Around line 240-248: Update AzurermBackendExists in
pkg/provisioner/backend/azurerm.go (lines 240-248) to wrap storageAccountExists
failures with errUtils.ErrCheckStorageAccountExist and containerExists failures
with errUtils.ErrCheckContainerExist, including the storage account, resource
group, and container context. In pkg/provisioner/backend/azurerm_test.go (lines
486-507), extend the “account check error” case with an ErrorIs assertion for
errUtils.ErrCheckStorageAccountExist.
In `@website/docs/stacks/components/provision/backend.mdx`:
- Line 210: Update the documentation for the use_azuread_auth setting to state
that it disables shared-key access only for newly created storage accounts,
because the auto-provision hook skips existing complete backends; direct users
to separately harden existing storage accounts.
In `@website/src/data/roadmap.js`:
- Line 212: Update the benefits text in the roadmap entry for “Azure (`azurerm`)
backend auto-provisioning” to say “workflow AWS users already had,” removing
“Azure” from that comparison while leaving the rest of the description
unchanged.
---
Nitpick comments:
In `@pkg/provisioner/backend/azurerm_test.go`:
- Around line 286-330: Extend TestCreateAzurermBackend_FullCreate to assert the
captured mock.createdAccountParams tags include the hardcoded defaults
Name=stcwtfstate and ManagedBy=Atmos, alongside the existing account parameter
assertions.
- Around line 486-507: Update the “account check error” case in the
AzurermBackendExists table test to assert that the returned error matches
errUtils.ErrCheckStorageAccountExist using assert.ErrorIs, while retaining the
existing require.Error check and behavior for other cases.
In `@pkg/provisioner/backend/azurerm.go`:
- Around line 255-273: Update the validation checks in the backend configuration
flow to return the relevant errUtils sentinel directly instead of wrapping it
with fmt.Errorf("%w", ...). Apply this to storage_account_name, container_name,
resource_group_name, and the subscriptionID check, preserving the existing
validation and return behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 94ed3010-3da4-4b62-b132-0c7901d2d8ba
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (9)
docs/prd/azurerm-backend-provisioner.mderrors/errors.gogo.modpkg/provisioner/backend/azurerm.gopkg/provisioner/backend/azurerm_delete.gopkg/provisioner/backend/azurerm_test.gowebsite/blog/2026-08-09-azure-backend-provisioning.mdxwebsite/docs/stacks/components/provision/backend.mdxwebsite/src/data/roadmap.js
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2911 +/- ##
==========================================
+ Coverage 82.83% 82.85% +0.01%
==========================================
Files 1866 1868 +2
Lines 181277 181624 +347
==========================================
+ Hits 150160 150481 +321
- Misses 23313 23328 +15
- Partials 7804 7815 +11
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…oning' into aknysh/azure-backend-autoprovisioning
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
pkg/provisioner/backend/azurerm_wrappers_test.go (1)
66-104: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse table-driven tests for repeated scenarios.
These tests define multiple behavior cases with separate subtests. Use one table and one subtest loop per API method.
pkg/provisioner/backend/azurerm_wrappers_test.go#L66-L104: convert resource-group existence cases to a table.pkg/provisioner/backend/azurerm_wrappers_test.go#L106-L131: convert resource-group creation cases to a table.pkg/provisioner/backend/azurerm_wrappers_test.go#L167-L224: convert storage-account creation cases to a table.pkg/provisioner/backend/azurerm_wrappers_test.go#L226-L254: convert blob data-protection cases to a table.pkg/provisioner/backend/azurerm_wrappers_test.go#L290-L315: convert container creation cases to a table.pkg/provisioner/backend/azurerm_wrappers_test.go#L317-L339: convert storage-account deletion cases to a table.As per coding guidelines, “Use table-driven tests for testing multiple scenarios in Go.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/provisioner/backend/azurerm_wrappers_test.go` around lines 66 - 104, Convert the repeated scenarios in TestAzureBackendClient_ResourceGroupExists and the tests at pkg/provisioner/backend/azurerm_wrappers_test.go lines 106-131, 167-224, 226-254, 290-315, and 317-339 into table-driven tests with one subtest loop per API method; preserve each scenario’s existing setup, assertions, and error behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/provisioner/backend/azurerm_wrappers_test.go`:
- Around line 173-180: The Azure fake provisioning handlers do not fully verify
required request fields. In
pkg/provisioner/backend/azurerm_wrappers_test.go:173-180, extend the
storage-account assertions to cover HTTPS-only access, public-blob access, and
Atmos tagging; in pkg/provisioner/backend/azurerm_wrappers_test.go:110-113,
assert the resource-group Tags. Preserve the existing location, SKU, TLS, and
shared-key assertions while validating the expected security defaults and tags.
- Around line 231-241: Extend the applyBlobDataProtection test’s
SetServiceProperties responder to capture
params.BlobServiceProperties.DeleteRetentionPolicy.Enabled, then assert the
captured nullable flag is present and true alongside the existing retention-days
assertions. Keep the current versioning and retention validation unchanged.
---
Nitpick comments:
In `@pkg/provisioner/backend/azurerm_wrappers_test.go`:
- Around line 66-104: Convert the repeated scenarios in
TestAzureBackendClient_ResourceGroupExists and the tests at
pkg/provisioner/backend/azurerm_wrappers_test.go lines 106-131, 167-224,
226-254, 290-315, and 317-339 into table-driven tests with one subtest loop per
API method; preserve each scenario’s existing setup, assertions, and error
behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c668d70d-79d5-4916-a4ee-a96f50026f2c
📒 Files selected for processing (2)
pkg/provisioner/backend/azurerm_test.gopkg/provisioner/backend/azurerm_wrappers_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- pkg/provisioner/backend/azurerm_test.go
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/provisioner/backend/azurerm_wrappers_test.go`:
- Line 70: Update the inline comments on the code field at
pkg/provisioner/backend/azurerm_wrappers_test.go:70-70 and the wantSharedKeyNil
field at pkg/provisioner/backend/azurerm_wrappers_test.go:188-188 so each
comment ends with a period.
- Line 381: Replace the ad hoc errors.New("cred boom") in the injected Azure
credential failure path with a distinct repository-level static error from
errors/errors.go. Reuse an existing suitable error or add a dedicated Azure
client initialization error, keeping it separate from
errUtils.ErrLoadAzureConfig so the wrapper test continues to validate the
intended failure.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 354838c1-1c4c-487d-8f78-4dbf2f62084e
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (6)
NOTICEerrors/errors.gogo.modpkg/provisioner/backend/azurerm_test.gopkg/provisioner/backend/azurerm_wrappers_test.gowebsite/src/data/roadmap.js
🚧 Files skipped from review as they are similar to previous changes (5)
- NOTICE
- website/src/data/roadmap.js
- errors/errors.go
- pkg/provisioner/backend/azurerm_test.go
- go.mod
…rm backend can init"
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/auth/cloud/azure/env_test.go (1)
70-77: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winTest removal of inherited tenant variables.
This case asserts that tenant variables are absent, but
inputEnvdoes not contain either tenant variable. The test passes if the clearing logic stops removing inherited tenant values. AddAZURE_TENANT_IDandARM_TENANT_IDto this case'sinputEnv.Proposed fix.
inputEnv: map[string]string{ "AZURE_CLIENT_ID": "conflicting-client-id", "AZURE_CLIENT_SECRET": "conflicting-secret", "AZURE_CLIENT_CERTIFICATE_PATH": "/path/to/cert", + "AZURE_TENANT_ID": "conflicting-tenant-id", "ARM_CLIENT_ID": "conflicting-arm-client", "ARM_CLIENT_SECRET": "conflicting-arm-secret", + "ARM_TENANT_ID": "conflicting-arm-tenant-id", "HOME": "/home/user", },As per coding guidelines, "Every new feature must include comprehensive unit tests targeting >80% code coverage for all packages."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/auth/cloud/azure/env_test.go` around lines 70 - 77, Update the test case containing expectedMissing in the environment-clearing tests so its inputEnv explicitly includes both AZURE_TENANT_ID and ARM_TENANT_ID with inherited values. Keep those variables in expectedMissing to verify the clearing logic removes them.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/fixes/2026-08-11-azurerm-backend-cli-subscription-tenant-conflict.md`:
- Around line 10-13: Add the text language identifier to the fenced error-output
block containing the AzureCLICredential message, changing the opening fence to
use text while preserving the output content.
---
Outside diff comments:
In `@pkg/auth/cloud/azure/env_test.go`:
- Around line 70-77: Update the test case containing expectedMissing in the
environment-clearing tests so its inputEnv explicitly includes both
AZURE_TENANT_ID and ARM_TENANT_ID with inherited values. Keep those variables in
expectedMissing to verify the clearing logic removes them.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 693f1424-8438-40f1-87be-3a0d708c2af1
📒 Files selected for processing (8)
docs/fixes/2026-08-11-azurerm-backend-cli-subscription-tenant-conflict.mdpkg/auth/cloud/azure/env.gopkg/auth/cloud/azure/env_test.gopkg/auth/cloud/azure/setup_test.gopkg/auth/providers/azure/cli_test.gopkg/auth/providers/azure/device_code_test.gopkg/auth/providers/azure/oidc.gopkg/provisioner/backend/azurerm_wrappers_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- pkg/provisioner/backend/azurerm_wrappers_test.go
|
CodeRabbit (@coderabbitai) full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
pkg/auth/providers/azure/oidc.go (1)
543-551: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPass the OIDC mode to the shared environment helper.
oidcProvider.PrepareEnvironmentcallsazureCloud.PrepareEnvironmentwithoutUseOIDC: true. The helper therefore enters the CLI branch, setsARM_USE_CLI, and logs a CLI-auth message before this method deletes the value and restores the OIDC tenant variables. PassUseOIDC: trueinazureCloud.PrepareEnvironmentConfigand remove this repair block. This keeps authentication-mode behavior in one place.Suggested alignment.
Location: p.location, CloudEnvironment: p.cloudEnv.Name, + UseOIDC: true, }) - // Override ARM_USE_CLI to use OIDC instead. - delete(result, "ARM_USE_CLI") - result["ARM_USE_OIDC"] = "true" - - // Export the tenant for OIDC. The shared CLI-path env preparation deliberately omits it (it - // would make the azurerm backend's Azure CLI credential pass both --subscription and --tenant, - // which the CLI rejects). OIDC (service-principal / federated) auth needs the tenant explicitly - // and does not shell out to the Azure CLI, so there is no such conflict here. - if p.tenantID != "" { - result["ARM_TENANT_ID"] = p.tenantID - result["AZURE_TENANT_ID"] = p.tenantID - }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/auth/providers/azure/oidc.go` around lines 543 - 551, Update oidcProvider.PrepareEnvironment to pass UseOIDC: true in the azureCloud.PrepareEnvironmentConfig call, ensuring the shared helper follows the OIDC path directly. Remove the subsequent ARM_USE_CLI cleanup and manual ARM_TENANT_ID/AZURE_TENANT_ID repair block, leaving authentication-mode environment setup centralized in azureCloud.PrepareEnvironment.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/prd/azurerm-backend-provisioner.md`:
- Around line 251-254: Update docs/prd/azurerm-backend-provisioner.md lines
251-254 to reference azurerm_wrappers_test.go instead of claiming ARM SDK
wrappers are only integration-tested against real Azure, and add that test file
to the package structure block at lines 199-204. Update the
TestNewAzureBackendClient comment in pkg/provisioner/backend/azurerm_test.go
lines 608-614 to reference azurerm_wrappers_test.go rather than stating wrappers
are exercised only against real Azure.
In `@pkg/provisioner/backend/azurerm.go`:
- Around line 541-556: Update applyBlobDataProtection to read the existing blob
service properties before calling SetServiceProperties, and use the greater of
blobSoftDeleteRetentionDays and each existing blob/container delete-retention
period. Preserve longer configured periods while continuing to enable versioning
and both policies.
In `@website/docs/stacks/components/provision/backend.mdx`:
- Around line 192-196: Update the “Entra ID hardening” documentation to clarify
that Atmos preserves the existing shared-key setting for pre-existing storage
accounts, while CreateAzurermBackend still processes incomplete backends by
applying blob versioning and soft delete before creating the missing container.
---
Nitpick comments:
In `@pkg/auth/providers/azure/oidc.go`:
- Around line 543-551: Update oidcProvider.PrepareEnvironment to pass UseOIDC:
true in the azureCloud.PrepareEnvironmentConfig call, ensuring the shared helper
follows the OIDC path directly. Remove the subsequent ARM_USE_CLI cleanup and
manual ARM_TENANT_ID/AZURE_TENANT_ID repair block, leaving authentication-mode
environment setup centralized in azureCloud.PrepareEnvironment.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: a049c26b-e7e4-4cc9-8577-ab806318dd61
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (18)
NOTICEdocs/fixes/2026-08-11-azurerm-backend-cli-subscription-tenant-conflict.mddocs/prd/azurerm-backend-provisioner.mderrors/errors.gogo.modpkg/auth/cloud/azure/env.gopkg/auth/cloud/azure/env_test.gopkg/auth/cloud/azure/setup_test.gopkg/auth/providers/azure/cli_test.gopkg/auth/providers/azure/device_code_test.gopkg/auth/providers/azure/oidc.gopkg/provisioner/backend/azurerm.gopkg/provisioner/backend/azurerm_delete.gopkg/provisioner/backend/azurerm_test.gopkg/provisioner/backend/azurerm_wrappers_test.gowebsite/blog/2026-08-09-azure-backend-provisioning.mdxwebsite/docs/stacks/components/provision/backend.mdxwebsite/src/data/roadmap.js
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
…into 1199-pro-exec-metadata * '1199-pro-exec-metadata' of github.com:cloudposse/atmos: Add task-runner dependencies, freshness checks, and preconditions to custom commands and workflows (#2882) feat(provisioner): Azure (azurerm) backend auto-provisioning (#2911) fix: preserve trailing newlines in text-based 3-way merges (#2891) fix(scaffold): preserve source in scaffold config (#2869) fix(deps): update github.com/epiclabs-io/diff3 digest to 3b16698 (#2917) fix(deps): update kubernetes monorepo to v0.36.3 (#2918)
|
These changes were released in v1.226.0-rc.5. |
what
Adds automatic provisioning for the
azurermTerraform state backend — the Azure counterpart to the existing S3 backend provisioner. Whenprovision.backend.enabled: trueon a component using anazurermbackend, Atmos creates the resource group (if missing), storage account, and blob container beforeterraform init, with opinionated secure defaults.Previously,
atmos terraform backend createreturnedcreate not implemented for backend type: azurermandprovision.backend.enabledsilently skipped for Azure.What gets created (hardcoded secure defaults)
StorageV2/Standard_LRS, TLS 1.2 minimum, HTTPS-only, public blob access blockeduse_azuread_auth: trueName+ManagedBy=AtmostagsNo lock resource is created — the
azurermbackend serializes concurrent writes with native Azure Blob Storage blob leases (the DynamoDB / native-S3-locking analog, built into Blob Storage).Design
create/delete/exists/nameinto the shared backend registry viainit(), so thebefore.terraform.inithook andatmos terraform backend create/deletepick upazurermwith no wiring changes to the hook or CLI.azureBackendAPIinterface hides the ARM SDK pollers behind synchronous methods for testability, mirroring the S3 client factory and the existingazurermstate-reader wrapper. A test-injectable client factory (SetAzureBackendClientFactory/ResetAzureBackendClientFactory) mirrorsSetS3ClientFactory.backendblock — it is not a validazurermbackend argument and Terraform would reject it inbackend.tf.json.armresources+armstorageSDK deps (azcore/azidentity/azblobwere already present).Also fixes:
azurermbackend init under Atmos-managed CLI authField-testing the provisioner end-to-end surfaced a pre-existing bug that blocked
azurermbackends whenever an Atmos profile was active. For CLI / device-code / interactive auth, Atmos exported bothARM_SUBSCRIPTION_IDandARM_TENANT_IDto the Terraform subprocess. OpenTofu'sazurermbackend authenticates via the Azure CLI and runsaz account get-access-token --subscription <id> --tenant <id>, which the CLI rejects withPlease specify only one of subscription and tenant, not both. It fails at argument validation — before the CLI even checks the session — soterraform initcannot list existing workspaces or read state at all:The tenant is now exported only for OIDC (service-principal / federated) auth, which needs it and does not shell out to the Azure CLI. On the CLI path only
ARM_SUBSCRIPTION_IDis exported; the tenant is already fixed by the MSAL session Atmos seeds (and the active subscription), and theazurerm/azapi/azureadproviders auto-detect it.oidc.gore-adds the tenant in its OIDC override, so service-principal auth is unchanged.pkg/auth/cloud/azure/env.go:PrepareEnvironmentgates the tenant export onUseOIDC.pkg/auth/providers/azure/oidc.go: OIDC override re-addsARM_TENANT_ID/AZURE_TENANT_ID.why
Brings Azure to feature parity with AWS for backend bootstrapping and eliminates the chicken-and-egg problem of needing remote state before Terraform can run — replacing the bespoke cold-start storage-account component teams currently hand-roll on Azure.
The CLI-auth fix is what makes the provisioned backend actually usable under Atmos-managed Azure auth: without it,
terraform initagainst anyazurermbackend fails while a profile is active.references
docs/prd/azurerm-backend-provisioner.mddocs/fixes/2026-08-11-azurerm-backend-cli-subscription-tenant-conflict.mddocs/prd/s3-backend-provisioner.mdtest
pkg/provisioner/backend/azurerm_test.go,azurerm_wrappers_test.go): table-driven, mockedazureBackendAPIand Azure SDK fake servers — config extraction/precedence,use_azuread_authparsing, full-create, resource-group reuse, existing-account warning, location-required error, every error path, existence checks, delete safety, registry wiring, and the ARM passthrough wrappers (404→exists mapping, poller completion, error propagation). 95.1% package coverage.pkg/auth/cloud/azure/{env,setup}_test.go,pkg/auth/providers/azure/{cli,device_code,oidc}_test.go): both branches of the tenant gate verified — omitted for CLI/device-code/interactive, present for OIDC.env.goandoidc.goPrepareEnvironmentare both 100% covered.go build ./...,go vet,gofmt, and all pre-commit hooks (go-fumpt, golangci-lint, go.mod tidy) pass.Note
The auto-provisioned account uses secure-but-simple defaults (
Standard_LRS, Microsoft-managed keys, public network access with Entra ID/RBAC gating) intended for dev/test/bootstrap — not production. For production, import the resources into a managed module (e.g.Azure/avm-res-storage-storageaccount); the provisioner is idempotent, soprovision.backend.enabled: truecan be left in place.