Skip to content

Commit

Permalink
Remove management group
Browse files Browse the repository at this point in the history
  • Loading branch information
Aris van Ommeren committed Jan 9, 2023
1 parent 36a8a82 commit 03af4b0
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions internal/services/subscription/subscription_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@ func resourceSubscription() *pluginsdk.Resource {
},
},

"management_group_id": {
Type: pluginsdk.TypeString,
Description: "The Management Group ID to which the subscription belongs",
Optional: true,
},

"subscription_id": {
Type: pluginsdk.TypeString,
Description: "The GUID of the Subscription.",
Expand Down Expand Up @@ -167,10 +161,6 @@ func resourceSubscriptionCreate(d *pluginsdk.ResourceData, meta interface{}) err
},
}

if managementGroupIdRaw, ok := d.GetOk("management_group_id"); ok {
req.Properties.AdditionalProperties.ManagementGroupId = utils.ToPtr(managementGroupIdRaw.(string))
}

subscriptionId := ""

// Check if we're adding alias management for an existing subscription
Expand Down Expand Up @@ -258,7 +248,6 @@ func resourceSubscriptionCreate(d *pluginsdk.ResourceData, meta interface{}) err
func resourceSubscriptionUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
aliasClient := meta.(*clients.Client).Subscription.AliasClient
subscriptionClient := meta.(*clients.Client).Subscription.SubscriptionClient
managementGroupsClient := meta.(*clients.Client).ManagementGroups.SubscriptionClient
ctx, cancel := timeouts.ForUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -291,22 +280,6 @@ func resourceSubscriptionUpdate(d *pluginsdk.ResourceData, meta interface{}) err
}
}

if d.HasChange("management_group_id") {
groupName := d.Get("management_group_id").(string)
if groupName != "" {
if _, err := managementGroupsClient.Create(ctx, groupName, *subscriptionId, "no-cache"); err != nil {
return fmt.Errorf("[DEBUG] Error assigning Subscription ID %q to Management Group %q: %+v", *subscriptionId, groupName, err)
}
} else if old, _ := d.GetChange("management_group_id"); old.(string) != "" {
deleteResp, err := managementGroupsClient.Delete(ctx, old.(string), *subscriptionId, "no-cache")
if err != nil {
if !response.WasNotFound(deleteResp.Response) {
return fmt.Errorf("unable to de-associate Subscription %q from Management Group %q: %+v", *subscriptionId, old.(string), err)
}
}
}
}

if d.HasChange("tags") {
tagsClient := meta.(*clients.Client).Resource.TagsClientForSubscription(*subscriptionId)
t := tags.Expand(d.Get("tags").(map[string]interface{}))
Expand Down

0 comments on commit 03af4b0

Please sign in to comment.