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

tenant_id expects a GUID but azurerm_client_config.current returns name #3359

Closed
alexstanhope opened this issue May 2, 2019 · 6 comments
Closed

Comments

@alexstanhope
Copy link

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

Terraform (and AzureRM Provider) Version

Terraform v0.11.13

  • provider.azurerm v1.25.0

Affected Resource(s)

  • azurerm_client_config
  • azurerm_key_vault

Terraform Configuration Files

This code snippet is taken from the first and only example in the AzureRM provider documentation:
https://www.terraform.io/docs/providers/azurerm/r/key_vault_key.html

data "azurerm_client_config" "current" {}
resource "azurerm_key_vault" "test" {
  name                = "keyvaultkeyexample"
  location            = "${azurerm_resource_group.test.location}"
  resource_group_name = "${azurerm_resource_group.test.name}"
  tenant_id           = "${data.azurerm_client_config.current.tenant_id}"

Debug Output

Sorry, I only have this line so it's inlined here:

* azurerm_key_vault.test: "tenant_id" is an invalid UUUID: encoding/hex: invalid byte: U+006D 'm'

Expected Behavior

When running the example script, an azurerm_key_vault resource should be created.

Actual Behavior

The error message reports that it wasn't expecting an m character. That's because my Azure tenant name begins m....onmicrosoft.com. m is not a hex character, which is why I'm pretty sure it's expecting a hex GUID. When I manually supply the Directory GUID (see below) it works.

Steps to Reproduce

  1. terraform apply

Important Factoids

https://www.terraform.io/docs/providers/azurerm/d/client_config.html

This error is created because client_config returns a tenant ID of the form tenantname.onmicrosoft.com. but azurerm_key_vault.tenant_id is expecting a GUID, along the lines of the Directory GUID described in this SO question.

References

@katbyte katbyte added the bug label Aug 27, 2019
@katbyte
Copy link
Collaborator

katbyte commented Aug 27, 2019

Hi @alexstanhope,

I'm sorry you are having this issue. Could you possible share with us your provider block or environment variables used while encountering this error? I ask because that resource only echos ethe exact information provided to the provider. So ${data.azurerm_client_config.current.tenant_id} should only be returning whatever you has passed in.

@cleverlight
Copy link

That must be my error then. I'm passing in the wrong value:

export ARM_TENANT_ID="tenantname.onmicrosoft.com"

@ghost ghost removed the waiting-response label Aug 28, 2019
@tombuildsstuff
Copy link
Contributor

hi @cleverlight @alexstanhope

The tenant_id field expects that the Azure Tenant ID will be provided as a GUID/UUID rather than as the domain name - as such this should work if you can switch these values over, would you be able to take a look and see if that works for you?

Thanks!

@tombuildsstuff
Copy link
Contributor

hi @cleverlight @alexstanhope

Since we've not heard back from you here I'm going to close this issue for the moment, but if you're still having issues please let us know and we'll take another look.

Thanks!

@cleverlight
Copy link

Thanks @tombuildsstuff

Good timing. I just got around to testing it yesterday and you're right, I can confirm that with tenant_id set to a GUID it works correctly.

The documentation is very clear, I just mistakenly read it out of an Azure Portal blade:
https://www.terraform.io/docs/providers/azurerm/auth/azure_cli.html
https://www.terraform.io/docs/providers/azurerm/auth/service_principal_client_secret.html

@ghost ghost removed the waiting-response label Oct 28, 2019
@ghost
Copy link

ghost commented Nov 27, 2019

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 27, 2019
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

5 participants