Skip to content

Commit

Permalink
Merge pull request #6817 from terraform-providers/b/azure-stack
Browse files Browse the repository at this point in the history
builder: raising an error for unsupported environments
  • Loading branch information
tombuildsstuff committed May 7, 2020
2 parents 26b9791 + 3ac50cc commit 9e920ab
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions azurerm/internal/clients/builder.go
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 9e920ab

Please sign in to comment.