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

only use the default subscription if not set explicitly #445

Merged
merged 1 commit into from
Nov 7, 2017

Conversation

lamdor
Copy link
Contributor

@lamdor lamdor commented Oct 20, 2017

I found this after I was setting the the subscription and tenant Id in the provider config via:

provider "azurerm" {
  subscription_id = "...."
  tenant_id       = "...."
}

and then logging in with az login. However, it the terraform provider was still trying to use what ever my configured default subscription is. I expected it to use what I had it configured explicitly to use. This fixes that.

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rubbish

Thanks for this PR - apologies for the delayed review! I've taken a look and done some testing and this LGTM :)

Thanks!

@tombuildsstuff tombuildsstuff merged commit f751808 into hashicorp:master Nov 7, 2017
tombuildsstuff added a commit that referenced this pull request Nov 7, 2017
@pmarques
Copy link

Thanks @rubbish and @tombuildsstuff, this fix is really nice, just got into the same problem.

Just a quick thing, this fix broke my "configurations" which keeps throwing just a weird message:

Error: Error refreshing state: 1 error(s) occurred:                                                                      
                                                                                                                 
* provider.azurerm: No valid (unexpired) Azure CLI Auth Tokens found. Please run `az login`.     

You can do what the message tells you to do but after running again you get the same error.
My provider is only configured with the subscription_id (since per documentation everything is optional):

provider "azurerm" {
  subscription_id = "${var.subscription_id}"
}

This happens because tenant_id is now required, this condition condition fails and then validateBearerAuth here will also fail.

I can think at least 2 ways of addressing this issue:

  • we can change the log message here to print the actual cause
  • We can review the provider config validation to make tenant_id optional, dropping the TenantID validation here, as far I was able to check it works if we remove that validation but it can be a good practice anyway.

@tombuildsstuff
Copy link
Contributor

@pmarques thanks for raising this - I'm going to look into a fix for this now - and given issue #562 is specific to this I'll post an update there

Thanks!

@ghost
Copy link

ghost commented Apr 1, 2020

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 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants