Skip to content
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

Support for configuration of keyVaultReferenceIdentity in azurerm_app_service #13388

Closed
orjan opened this issue Sep 16, 2021 · 6 comments
Closed

Comments

@orjan
Copy link

orjan commented Sep 16, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Some apps need to reference secrets at creation time, when a system-assigned identity would not yet be available. In these cases, a user-assigned identity can be created and given access to the vault in advance.

Today there's no way to configure this through terraform making it hard to resolve key vault values needed a startup e.g. @Microsoft.KeyVault(VaultName=myvault;SecretName=mysecret) so we'll need to resort to a manual configuration similar to the one below.

userAssignedIdentityResourceId=$(az identity show -g MyResourceGroupName -n MyUserAssignedIdentityName --query id -o tsv)
appResourceId=$(az webapp show -g MyResourceGroupName -n MyAppName --query id -o tsv)
az rest --method PATCH --uri "${appResourceId}?api-version=2021-01-01" --body "{'properties':{'keyVaultReferenceIdentity':'${userAssignedIdentityResourceId}'}}"

New or Affected Resource(s)

  • azurerm_app_service

Potential Terraform Configuration

resource "azurerm_app_service" "example" {
  key_vault_reference_identity_id = azurerm_user_assigned_identity.default.id
}

References

@orjan
Copy link
Author

orjan commented Oct 11, 2021

Maybe it's better to use key_vault_reference_identity since there are 3 potential values:

  • azurerm_user_assigned_identity.default.id
  • "SystemAssigned"
  • null

I don't know how we could set null due to models.go looks like this:

	if s.KeyVaultReferenceIdentity != nil {
		objectMap["keyVaultReferenceIdentity"] = s.KeyVaultReferenceIdentity
	}

There is a NullValue present i another part in the Azure SDK but I'm not sure if we can use it?
https://github.com/Azure/azure-sdk-for-go/blob/main/sdk/azcore/core.go#L20

@katbyte katbyte added this to the v2.81.0 milestone Oct 14, 2021
katbyte pushed a commit that referenced this issue Oct 14, 2021
…ble (#13720)

Solves #13388 by making the user assigned identity id
for looking up key vault secrets configurable.

The attribute is computed to read the default value (at the moment: SystemAssigned ) if no value is specified .
The default value is returned by the API even if no SystemAssigned identity is set for an AppService. Therefore this behaviour should be fine.

Test case succeeded:
@katbyte katbyte modified the milestones: v2.81.0, v2.82.0 Oct 14, 2021
@katbyte katbyte modified the milestones: v2.82.0, v2.83.0 Oct 21, 2021
@github-actions
Copy link

This functionality has been released in v2.83.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@orjan
Copy link
Author

orjan commented Oct 25, 2021

It’s working as expected, great work @patst!

@orjan orjan closed this as completed Oct 25, 2021
@github-actions
Copy link

This functionality has been released in v2.83.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@sebader
Copy link
Contributor

sebader commented Oct 29, 2021

Would be awesome if this could also be added to Function Apps! #13960

@github-actions
Copy link

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.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants