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

Fail early on mismatched environments/clouds #3281

Merged
merged 1 commit into from
May 14, 2024
Merged

Conversation

thomas11
Copy link
Contributor

Quoting the code comment: CLI authentication can only use the environment that the CLI is configured for. Fail early if that's not the one from config, to avoid obscure errors about missing subscriptions or endpoints later.

Resolves #3274

Sample shell session:

❯ pulumi config -s gov | rg environ
azure-native:environment  usgovernment

❯ az account show | rg environ
  "environmentName": "AzureCloud",

❯ PATH=$HOME/pulumi/pan/bin:$PATH pulumi up -s gov
Previewing update (gov)

     Type                                     Name              Plan       Info
 +   pulumi:pulumi:Stack                      azn-3268-env-gov  create     3 warnings
     └─ azure-native:resources:ResourceGroup  resourceGroup                1 error

Diagnostics:
  azure-native:resources:ResourceGroup (resourceGroup):
    error: The configured Azure environment 'usgovernment' does not match the determined environment 'public'.
    When authenticating using the Azure CLI, the configured environment needs to match the one shown by 'az account show'.
    You can change environments using 'az cloud set --name <environment>'.

Copy link

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

Copy link

codecov bot commented May 13, 2024

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 55.33%. Comparing base (9901424) to head (7ad04f6).
Report is 1 commits behind head on master.

Files Patch % Lines
provider/pkg/provider/auth.go 0.00% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3281      +/-   ##
==========================================
- Coverage   55.37%   55.33%   -0.04%     
==========================================
  Files          66       66              
  Lines        9924     9930       +6     
==========================================
  Hits         5495     5495              
- Misses       3996     4001       +5     
- Partials      433      434       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thomas11 thomas11 merged commit b47bf2e into master May 14, 2024
24 checks passed
@thomas11 thomas11 deleted the tkappler/env-warning branch May 14, 2024 04:40
Copy link
Member

@mikhailshilkov mikhailshilkov left a comment

Choose a reason for hiding this comment

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

I'm missing a test to go with this change.

provider/pkg/provider/auth.go Show resolved Hide resolved
@thomas11
Copy link
Contributor Author

I'm missing a test to go with this change.

Fair enough. The whole area isn't covered much.

#3285 adds a bunch.

thomas11 added a commit that referenced this pull request May 18, 2024
This is a core part of the provider that lacked coverage. Also includes
the new #3281.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When using CLI auth, the provider should warn about mismatched Azure environments
3 participants