Skip to content

Commit

Permalink
Azure Creds: Honors the documented default behavior (again) (hashicor…
Browse files Browse the repository at this point in the history
…p#2190)

Fixes hashicorp#2189: `environment` defaults to Azure Public Cloud

Ideally this would be drawn from Vault Server, but the documented
default there is to point at Azure Public Cloud. This seems like a
decent compromise.

Signed-off-by: David Alexander <opensource@thelonelyghost.com>
  • Loading branch information
TheLonelyGhost authored Mar 14, 2024
1 parent e16b837 commit 37e87b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Unreleased

BUGS:
* fix `vault_azure_access_credentials` to default to Azure Public Cloud ([#2190](https://github.com/hashicorp/terraform-provider-vault/pull/2190))

## 4.0.0 (Mar 13, 2024)

**Important**: This release requires read policies to be set at the path level for mount metadata.
Expand Down
5 changes: 4 additions & 1 deletion vault/data_source_azure_access_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func azureAccessCredentialsDataSource() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Description: `The Azure environment to use during credential validation.
Defaults to the environment configured in the Vault backend.
Defaults to the Azure Public Cloud.
Some possible values: AzurePublicCloud, AzureUSGovernmentCloud`,
},
},
Expand Down Expand Up @@ -313,6 +313,9 @@ func azureAccessCredentialsDataSourceRead(ctx context.Context, d *schema.Resourc
}

func getAzureCloudConfigFromName(name string) (cloud.Configuration, error) {
if name == "" {
return cloud.AzurePublic, nil
}
if c, ok := azureCloudConfigMap[strings.ToUpper(name)]; !ok {
return c, fmt.Errorf("unsupported Azure cloud name %q", name)
} else {
Expand Down
6 changes: 6 additions & 0 deletions vault/data_source_azure_access_credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ func Test_getAzureCloudConfigFromName(t *testing.T) {
cloudName: "unknown",
wantErr: true,
},
{
name: "empty",
cloudName: "",
want: cloud.AzurePublic,
wantErr: false,
},
}
for k, v := range azureCloudConfigMap {
tests = append(tests, test{
Expand Down

0 comments on commit 37e87b4

Please sign in to comment.