Skip to content

Commit

Permalink
builder: raising an error if environment is unintentionally set to "A…
Browse files Browse the repository at this point in the history
…ZURESTACKCLOUD"

Users should instead use the separate "azurestack" provider which offers integration
with Azure Stack via the Azure Stack Profiles
  • Loading branch information
tombuildsstuff committed May 7, 2020
1 parent 24b3807 commit 3ac50cc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions azurerm/internal/clients/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package clients
import (
"context"
"fmt"
"strings"

"github.com/hashicorp/go-azure-helpers/authentication"
"github.com/hashicorp/go-azure-helpers/sender"
Expand All @@ -21,7 +22,21 @@ type ClientBuilder struct {
Features features.UserFeatures
}

const azureStackEnvironmentError = `
The AzureRM Provider supports the different Azure Public Clouds - including China, Germany,
Public and US Government - however it does not support Azure Stack due to differences in
API and feature availability.
Terraform instead offers a separate "azurestack" provider which supports the functionality
and API's available in Azure Stack via Azure Stack Profiles.
`

func Build(ctx context.Context, builder ClientBuilder) (*Client, error) {
// point folks towards the separate Azure Stack Provider when using Azure Stack
if strings.EqualFold(builder.AuthConfig.Environment, "AZURESTACKCLOUD") {
return nil, fmt.Errorf(azureStackEnvironmentError)
}

env, err := authentication.DetermineEnvironment(builder.AuthConfig.Environment)
if err != nil {
return nil, err
Expand Down

0 comments on commit 3ac50cc

Please sign in to comment.