You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Terragrunt also includes end-to-end tests for the Azure Storage (`azurerm`) remote-state backend. These are prefixed with `TestAzure*` and use the `azure` build tag, because they create and destroy real Azure resources. The `internal/azurehelper` tests use the same build tag; their live round-trip skips when credentials are absent.
274
+
275
+
```bash
276
+
GOFLAGS='-tags=azure' go test ./internal/azurehelper/...
277
+
GOFLAGS='-tags=azure' go test -run 'TestAzure*' ./test
278
+
```
279
+
280
+
Unlike some other suites, these fail rather than skip when credentials are missing, so a misconfigured environment is visible instead of silently reporting success.
281
+
282
+
To successfully run the Azure tests, you must set the following environment variables:
283
+
284
+
-`TG_AZURE_TEST_SUBSCRIPTION_ID`: The subscription hosting the test storage account. `ARM_SUBSCRIPTION_ID` or `AZURE_SUBSCRIPTION_ID` also work.
285
+
-`TG_AZURE_TEST_STORAGE_ACCOUNT`: The name of a pre-existing storage account the tests create containers in. `ARM_STORAGE_ACCOUNT_NAME` also works.
286
+
-`AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_TENANT_ID`: Service principal credentials. The `ARM_*` spelling of each is also accepted, and these can be omitted entirely when authenticating with `az login`.
287
+
288
+
With ARM-capable authentication, the resource group is looked up from the storage account. Set `TG_AZURE_TEST_RESOURCE_GROUP` when using an access key or SAS token, because data-plane credentials cannot perform that lookup.
The identity used for Azure tests must hold the following roles:
297
+
298
+
-`Storage Blob Data Contributor`, because the tests authorize blob access with Microsoft Entra rather than an account key.
299
+
-`Storage Account Contributor`, because blob versioning and soft delete are management-plane properties of the account. Without it, `TestAzureBackendVersioningConverges` cannot converge them.
300
+
301
+
You can assign these roles using the following Azure CLI commands:
Scoping both roles to the resource group also lets the tests resolve it from the storage account name, so no subscription-wide assignment is needed.
318
+
319
+
An account key (`ARM_ACCESS_KEY`) authenticates the blob data plane and is enough for
320
+
most of the suite, but it cannot reach the management plane at all, so
321
+
`TestAzureBackendVersioningConverges` skips under it. Only an Entra identity runs the
322
+
whole suite.
323
+
324
+
The tests create and delete blob containers with unique names on each run; they never create or delete the storage account itself.
325
+
271
326
#### Race tests
272
327
273
328
Given that Terragrunt is a tool that frequently involves concurrently running multiple things at once, there's always a risk for race conditions to occur. As such, there are dedicated tests that are run with the `-race` flag in CI to use golang's built-in tooling for identifying race conditions.
Copy file name to clipboardExpand all lines: docs/src/data/experiments/azure-backend.mdx
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,8 +88,9 @@ To transition the `azure-backend` feature to a stable release, the following mus
88
88
-[x]`internal/azurehelper` package wrapping the Azure SDK with a builder pattern matching `awshelper`/`gcphelper`.
89
89
-[x] Bootstrap of storage accounts and blob containers, including versioning and soft delete convergence.
90
90
-[ ] Optional RBAC role assignment for `use_azuread_auth` during bootstrap (the data-plane role must currently be granted manually).
91
-
-[x] Delete and migrate operations for state blobs and containers with confirmation prompts.
91
+
-[x] Delete operations for state blobs and containers, with confirmation prompts, and state migration within a storage account.
92
92
-[ ] Direct state file reads from Azure blobs for `--dependency-fetch-output-from-state`.
93
93
-[x] Documentation covering authentication methods, configuration keys, and troubleshooting.
94
-
-[ ] End-to-end live coverage against a real subscription for resource group and storage account bootstrap, policy convergence, backend delete, and state migration. The existing live blob round-trip covers only the data-plane helper; hermetic unit tests ship behind the `azure` build tag.
94
+
-[x] End-to-end live coverage against a real subscription for container bootstrap, blob versioning convergence, and backend delete, behind the `azure` build tag.
95
+
-[ ] End-to-end live coverage for resource group and storage account creation, soft-delete retention convergence, and state migration. The current live tests assume a pre-existing storage account.
0 commit comments