Skip to content

Commit

Permalink
Stop requiring subscription ID to be configured for the provider
Browse files Browse the repository at this point in the history
Configuring a subscription ID is a vestige from the provider split. We
don't use subscription_id anywhere and have no plans to. Any resource
that operates on a subscription or its dependents should belong in the
azurerm provider.

Although it's never used because we only use SDK clients that are
configured with a tenant ID, go-azure-helper requires it for sensible
reasons and it doesn't make sense to push this concern upstream for now.

We'll keep the configuration property around for now so that users have
time to remove it from their configurations.
  • Loading branch information
manicminer committed Jun 12, 2020
1 parent a9c691e commit 44829f2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 0 additions & 2 deletions azuread/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

// ArmClient contains the handles to all the specific Azure ADger resource classes' respective clients.
type ArmClient struct {
subscriptionID string
clientID string
objectID string
tenantID string
Expand Down Expand Up @@ -57,7 +56,6 @@ func getArmClient(authCfg *authentication.Config, tfVersion string, ctx context.

// client declarations:
client := ArmClient{
subscriptionID: authCfg.SubscriptionID,
clientID: authCfg.ClientID,
objectID: objectID,
tenantID: authCfg.TenantID,
Expand Down
13 changes: 8 additions & 5 deletions azuread/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import (
func Provider() terraform.ResourceProvider {
p := &schema.Provider{
Schema: map[string]*schema.Schema{
// TODO: remove subscription_id field at next major version
"subscription_id": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("ARM_SUBSCRIPTION_ID", ""),
Type: schema.TypeString,
Optional: true,
Default: "",
},

"client_id": {
Expand Down Expand Up @@ -100,11 +101,13 @@ func Provider() terraform.ResourceProvider {

func providerConfigure(p *schema.Provider) schema.ConfigureFunc {
return func(d *schema.ResourceData) (interface{}, error) {
// When constructing the Builder, we use the tenant ID for the subscription ID.
// Although this has no effect since we never consume it, this practise mimics
// the Azure CLI and it seems the most sensible value to use after a nonsense string.
builder := &authentication.Builder{
// TODO: remove the requirement on the Subscription ID
SubscriptionID: d.Get("subscription_id").(string),
ClientID: d.Get("client_id").(string),
ClientSecret: d.Get("client_secret").(string),
SubscriptionID: d.Get("tenant_id").(string),
TenantID: d.Get("tenant_id").(string),
Environment: d.Get("environment").(string),
MsiEndpoint: d.Get("msi_endpoint").(string),
Expand Down
1 change: 0 additions & 1 deletion azuread/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func TestProvider_impl(t *testing.T) {

func testAccPreCheck(t *testing.T) {
variables := []string{
"ARM_SUBSCRIPTION_ID",
"ARM_CLIENT_ID",
"ARM_CLIENT_SECRET",
"ARM_TENANT_ID",
Expand Down

0 comments on commit 44829f2

Please sign in to comment.