-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Terraform test - Add support terraform functions in mock objects #34672
Copy link
Copy link
Open
Labels
Description
Terraform Version
1.7.3Use Cases
I want to generate test data based on specific data type or string format:
- for a GUID use uuid()
- for an Azure resource id use format("/subscriptions/%s", uuid())
Attempted Solutions
mock_data "azurerm_client_config" {
defaults = {
client_id = uuid()
}
}
override_resource {
target = azurerm_storage_account.example
values = {
id = format("/subscriptions/%s/resourceGroups/example/providers/Microsoft.Storage/storageAccounts/myaccount", uuid())
}
}Error when trying to use a function:
Error: Function calls not allowed
│
│ on tests/mock_data/data.tfmock.hcl line 9, in mock_data "azurerm_client_config":
│ 9: client_id = uuid()
│
│ Functions may not be called here.Proposal
No response
References
No response
Reactions are currently unavailable