-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automation Account - Customer Managed Key - Error on deployment #24926
Comments
Hi @XristophD , The |
Hello @wuxu92 , I am not sure if I understand your comment correct. I am aware that encryption.identity.userAssignedIdentity is not (directly) related to the account's identity block. But the user-managed identity assigned to encryption.identity.userAssignedIdentity needs to be added to the identity block as well. Anyway, this is not the issue I am facing right now. I created a simplified deployment, let me know if you can replicate the issue with this. Steps to replicate:
{
name = "aa-infr-cmktest-weu-01"
key_type = "RSA"
key_size = 4096
key_opts = ["decrypt", "encrypt", "unwrapKey", "wrapKey"]
}
resource "azurerm_automation_account" "aa_github_issue" {
name = "aa-infr-cmktest-weu-01"
resource_group_name = "rg-yourresourcegroup-here"
location = "westeurope"
sku_name = "Basic"
local_authentication_enabled = false
public_network_access_enabled = true
identity {
type = "SystemAssigned"
}
encryption {
key_vault_key_id = module.kv_weu.keys["aa-infr-cmktest-weu-01"].versionless_id
}
}
resource "azurerm_role_assignment" "aa_github_issue_systemidentity_kv_weu_krypto_svc_encr_user" {
scope = module.kv_weu.keys["aa-infr-cmktest-weu-01"].resource_versionless_id
role_definition_name = "Key Vault Crypto Service Encryption User" # Minimal Permission, read/wrap/unwrap
principal_id = azurerm_automation_account.aa_github_issue.identity[0].principal_id # System Assigned Managed Identity
} Since we only use SystemAssigned identities in this setup, we do not have the requirement to set identity.identity_ids or encryption.user_assigned_identity_id information. The later cannot be set, since it would be a reference to itself, therefore, when the encryption block does only set key_vault_key_id the system assigned identitiy should always be used. This is the first step we need to solve, the later step would be to set identity.type = "SystemAssigned, UserAssigned", assign (multiple) identity.identity_ids and reference either the system assigned identity, or one of the user assigned identities. |
Thank you for providing the information @XristophD . I have reproduced the issue and created a PR (#24977 ) to resolve the issue. The steps I set a encryption with systemAssigned identity as below should wotk when the PR is merged:
|
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Is there an existing issue for this?
Community Note
Terraform Version
1.7.3
AzureRM Provider Version
3.92.0
Affected Resource(s)/Data Source(s)
azurerm_automation_account
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
The Automation Account ist created and the Encryption settings are configured as defined.
Since no User Assigned Identity is provided (in the identity block as well the encryption block), the System Assigned Identity should be used.
Actual Behaviour
The payload for the AZURERM-API call is using a malformed syntax on the managed identity:
Payload in JSON-Syntax shows, that encryption.identity.userAssignedIdentity is not set to null but an empty string. Therefore, the API expects an UserAssigned identity.
Steps to Reproduce
terraform apply
Important Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered: