hashicorp / terraform-provider-vault

Terraform Vault provider
https://www.terraform.io/docs/providers/vault/
Mozilla Public License 2.0
459 stars 540 forks source link

Add role_id attribute in vault_azure_auth_backend_role resource #2149

Open rv-harsha opened 7 months ago

rv-harsha commented 7 months ago

Is your feature request related to a problem? Please describe. The vault_azure_auth_backend_role resource is not returning the role_id attribute.

 Error: Unsupported attribute
│ 
│   on ../modules/azure-entity-alias/main.tf line 42, in resource "vault_identity_entity_alias" "azure_auth_alias":
│   42:     name             = vault_azure_auth_backend_role.this.role_id
│ 
│ This object has no argument, nested block, or exported attribute named "role_id".
╵

Describe the solution you'd like

Explain any additional use cases We need to associate the entity aliases with the Azure mounts created. To achieve this, we need to read (data block) the role id.

Additional context Add any other context or screenshots about the feature request here.

fairclothjm commented 7 months ago

@rv-harsha Hello! I am sorry you are having trouble. Can you try using role?

-name = vault_azure_auth_backend_role.this.role_id
+name = vault_azure_auth_backend_role.this.role

https://registry.terraform.io/providers/hashicorp/vault/latest/docs/resources/azure_auth_backend_role#role

rv-harsha commented 7 months ago

Hi @fairclothjm. This works but this just returns the role name for the Azure backend role that I just created, right? However, we specifically want the retrieve the role_id and map it to an entity alias.

fairclothjm commented 7 months ago

The role name is the role's unique identifier. I am not aware of a role_id field returned by the azure auth plugin.

rv-harsha commented 7 months ago

Yes. Currently, we have provision to retrieve role ids for AWS and GCP Auth Roles only. We are looking for something similar. Like this one for GCP.

So we don't have this data source for Azure

data "vault_gcp_auth_backend_role" "role" {
  backend   = "my-gcp-backend"
  role_name = "my-role"
}

output "role-id" {
  value = "${data.vault_gcp_auth_backend_role.role.role_id}"
}