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

metadata_url can be used to obtain an environment from a specific url #7664

Merged
merged 4 commits into from
Jul 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion azurerm/internal/clients/builder.go
Original file line number Diff line number Diff line change
@@ -38,7 +38,15 @@ func Build(ctx context.Context, builder ClientBuilder) (*Client, error) {
return nil, fmt.Errorf(azureStackEnvironmentError)
}

env, err := authentication.DetermineEnvironment(builder.AuthConfig.Environment)
isAzureStack, err := authentication.IsEnvironmentAzureStack(ctx, builder.AuthConfig.MetadataURL, builder.AuthConfig.Environment)
if err != nil {
return nil, err
}
if isAzureStack {
return nil, fmt.Errorf(azureStackEnvironmentError)
}

env, err := authentication.AzureEnvironmentByNameFromEndpoint(ctx, builder.AuthConfig.MetadataURL, builder.AuthConfig.Environment)
if err != nil {
return nil, err
}
8 changes: 8 additions & 0 deletions azurerm/internal/provider/provider.go
Original file line number Diff line number Diff line change
@@ -97,6 +97,13 @@ func azureProvider(supportLegacyTestSuite bool) terraform.ResourceProvider {
Description: "The Cloud Environment which should be used. Possible values are public, usgovernment, german, and china. Defaults to public.",
},

"metadata_url": {
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("ARM_METADATA_URL", ""),
Description: "The Metadata URL which will be used to obtain the Cloud Environment.",
},

// Client Certificate specific fields
"client_certificate_path": {
Type: schema.TypeString,
@@ -211,6 +218,7 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc {
TenantID: d.Get("tenant_id").(string),
AuxiliaryTenantIDs: auxTenants,
Environment: d.Get("environment").(string),
MetadataURL: d.Get("metadata_url").(string),
MsiEndpoint: d.Get("msi_endpoint").(string),
ClientCertPassword: d.Get("client_certificate_password").(string),
ClientCertPath: d.Get("client_certificate_path").(string),
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ require (
github.com/btubbs/datetime v0.1.0
github.com/davecgh/go-spew v1.1.1
github.com/google/uuid v1.1.1
github.com/hashicorp/go-azure-helpers v0.10.0
github.com/hashicorp/go-azure-helpers v0.11.1
github.com/hashicorp/go-getter v1.4.0
github.com/hashicorp/go-multierror v1.0.0
github.com/hashicorp/go-uuid v1.0.1
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -117,6 +117,8 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv
github.com/hashicorp/go-azure-helpers v0.4.1/go.mod h1:lu62V//auUow6k0IykxLK2DCNW8qTmpm8KqhYVWattA=
github.com/hashicorp/go-azure-helpers v0.10.0 h1:KhjDnQhCqEMKlt4yH00MCevJQPJ6LkHFdSveXINO6vE=
github.com/hashicorp/go-azure-helpers v0.10.0/go.mod h1:YuAtHxm2v74s+IjQwUG88dHBJPd5jL+cXr5BGVzSKhE=
github.com/hashicorp/go-azure-helpers v0.11.1 h1:MpUAPXPFqvihw80cJnGXiu0cL0F6kYFq5+uzEI3j0TE=
github.com/hashicorp/go-azure-helpers v0.11.1/go.mod h1:YuAtHxm2v74s+IjQwUG88dHBJPd5jL+cXr5BGVzSKhE=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -198,7 +198,7 @@ github.com/google/uuid
github.com/googleapis/gax-go/v2
# github.com/hashicorp/errwrap v1.0.0
github.com/hashicorp/errwrap
# github.com/hashicorp/go-azure-helpers v0.10.0
# github.com/hashicorp/go-azure-helpers v0.11.1
github.com/hashicorp/go-azure-helpers/authentication
github.com/hashicorp/go-azure-helpers/resourceproviders
github.com/hashicorp/go-azure-helpers/response
4 changes: 4 additions & 0 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
@@ -95,6 +95,10 @@ The following arguments are supported:

* `tenant_id` - (Optional) The Tenant ID which should be used. This can also be sourced from the `ARM_TENANT_ID` Environment Variable.

* `metadata_url` - (Optional) The Metadata URL which will be used to obtain the Cloud Environment.

~> **Note:** `environment` must be set to the requested environment name in the list of available environments held in the `metadata_url`.

---

When authenticating as a Service Principal using a Client Certificate, the following fields can be set: