# Unable to get SystemAssigned identity attributes

**URL:** <https://discuss.hashicorp.com/t/unable-to-get-systemassigned-identity-attributes/4842>\
**Category:** Azure\
**Created:** [January 2, 2020, 8:07am UTC](https://discuss.hashicorp.com/t/unable-to-get-systemassigned-identity-attributes/4842 "2020-01-02T08:07:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tauqirghani](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/tauqirghani/32/3803_2.png) [@tauqirghani](https://discuss.hashicorp.com/u/tauqirghani)\
**Post date:** [January 2, 2020, 8:07am UTC](https://discuss.hashicorp.com/t/unable-to-get-systemassigned-identity-attributes/4842/1 "2020-01-02T08:07:22Z")

</div>

Following block in app\_service is supposed to create a System Generated tenant\_id and principal\_id that can be used in the later blocks

identity {  
type = “SystemAssigned”  
}

But when I try to use these these as follows

resource “azurerm\_key\_vault\_access\_policy” “app” {  
key\_vault\_id = var.key\_vault\_id  
tenant\_id = azurerm\_app\_service.app.identity[0].tenant\_id  
object\_id = azurerm\_app\_service.app.identity[0].principal\_id  
secret\_permissions = [“get”, “list”]

depends\_on = [azurerm\_app\_service.app]  
}

terraform throws an error

Error: “object\_id”: required field is not set

on …\modules\app-service\main.tf line 68, in resource “azurerm\_key\_vault\_access\_policy” “app”:  
68: resource “azurerm\_key\_vault\_access\_policy” “app” {

Error: “tenant\_id”: required field is not set

on …\modules\app-service\main.tf line 68, in resource “azurerm\_key\_vault\_access\_policy” “app”:  
68: resource “azurerm\_key\_vault\_access\_policy” “app” {

Any ideas?

---

<div class="post-metadata">

**Author:** ![michalchecinski](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/michalchecinski/32/11088_2.png) [@michalchecinski](https://discuss.hashicorp.com/u/michalchecinski)\
**Post date:** [August 28, 2020, 4:50pm UTC](https://discuss.hashicorp.com/t/unable-to-get-systemassigned-identity-attributes/4842/2 "2020-08-28T16:50:24Z")

</div>

I found out that you need to have system assigned identity enabled on that resource, and then you can query for that identity. I’ve done it in two deployments, but there must be some other way to achieve this. Will comment when I find another way 🙂
