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

builder: raising an error for unsupported environments #6817

Merged
merged 1 commit into from May 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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