-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Error when deploying azurerm_container_group with CMK using key_vault_key_id setting #23305
Comments
I have reached out to Microsoft on this and opened a support cause. The support team escalated to the backend product team who provided the following information and asked that I open a GH Issue. They believe this is a bug on TF. They enabled TF Debug (example tutorial: https://docs.aiven.io/docs/tools/terraform/howto/terraform-logging) to get the JSON in the ARM PUT request: 2023-09-14T11:42:20.384-0600 [DEBUG] provider.terraform-provider-azurerm_v3.72.0_x5.exe: AzureRM Request: {"identity":{"type":"UserAssigned","userAssignedIdentities":{"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/acirepro/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myACIId":{}}},"location":"eastus","name":"acirepro","properties":{"containers":[{"name":"hello-world","properties":{"command":[],"environmentVariables":[],"image":"mcr.microsoft.com/azuredocs/aci-helloworld:latest","ports":[{"port":80,"protocol":"TCP"}],"resources":{"requests":{"cpu":0.5,"memoryInGB":1.5}}}}],"encryptionProperties":{"keyName":"acikey","keyVersion":"698ab1c778ef4d9981480e922d33ed47","vaultBaseUrl":"https://acikvcmk.vault.azure.net/"},"ipAddress":{"autoGeneratedDomainNameLabelScope":"Unsecure","ports":[{"port":80,"protocol":"TCP"}],"type":"Private"},"initContainers":[],"osType":"Linux","restartPolicy":"Always","sku":"Standard","subnetIds":[{"id":"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/acirepro/providers/Microsoft.Network/virtualNetworks/acivnet/subnets/acisubnet"}],"volumes":[]},"tags":{},"zones":[]}: timestamp=2023-09-14T11:42:20.384-0600 As you can see TF uses latest ACI API 2023-05-01, which supports CMK via managed identity plus RBAC, but according to docs the encryptionProperties block needs the identity id: https://learn.microsoft.com/en-us/rest/api/container-instances/2023-05-01/container-groups/create-or-update?tabs=HTTP#encryptionproperties. This is true for all APIs equal or newer than 2022-09-01, which is the one they have used in their ARM repro that worked: So, TF is still handling this encryptionProperties block per API definition equal or older than 2021-10-01 when only Access Policies were supported to access KV: https://learn.microsoft.com/en-us/rest/api/container-instances/2021-10-01/container-groups/create-or-update?tabs=HTTP#encryptionproperties. Please log a bug to TF to address this. Also, this comment is no longer true, only for Azure Government clouds: |
@dawsonar802 Would you please provide a minimal self-contained configuration so that I can reproduce this locally? The reason I'm asking this is because the existing acctest for the CMK works fine, where it didn't set the |
@magodo, the code mentioned in the initial post is what I am using. MS deployed using some different code, but I was unable to access that from the file download site. Identity is needed from my understanding and the identities needs access on the KV via RBAC. That should get you the same error. Let me know if that helps. |
@stephybun / @magodo, just so I understand, the resource now should work with RBAC instead of only Access Policy permissions on the KV correct? We just need to pass in the identity that has access? It seems confusing that we could not just use the existing identity block and the system or user assigned identity that we are already creating/passing in. Could you please clarify. It is also somewhat confusing and misleading having this issue closed when the 3.74.0 release is not available and I am not able to confirm the issue is actually resolved. |
If I understand the API correctly, previously it only supports to assign needed key vault access policy to RP owned SP named "Azure Container Instance Service". Then you just need to specify the With #23332, users are able to specify the identity used to access the key vault key. This identity can be the same user assigned identity, or one of the identities set to the Regarding why this issue is closed, it is the process we are practicing: closing the issue and mark the milestone that the fix will be shipped, instead of close a bunch of issues after the release. You are welcome to reopen this issue if the issue remains for you. Whilst, it would be helpful that you can provide a minimal self-contained config (with all the values interpolated) that can reproduce this issue. |
@magodo, understood. Yes, RBAC is the main issue, as it is recommended to move away from Access Policies and to use RBAC. I did test with giving the 'Azure Container Instance Service' various RBAC roles, but it still would not work. So maybe once the |
@dawsonar802 RBAC will work as long as the new With current TF version no RBAC role over identity or 'Azure Container Instance Service' SP will work, because the encryptionProperties block lacks the |
Thanks @kennethgp . I will give it a try once the new version is released. |
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.4.0
AzureRM Provider Version
3.72.0
Affected Resource(s)/Data Source(s)
azurerm_container_group
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
Deploy the resource with CMK and linked to the specified KV.
Actual Behaviour
A generic error is given:
Steps to Reproduce
No response
Important Factoids
No response
References
No response
The text was updated successfully, but these errors were encountered: