1. Packages
  2. Azure Classic
  3. API Docs
  4. management
  5. GroupSubscriptionAssociation

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi

azure.management.GroupSubscriptionAssociation

Explore with Pulumi AI

Manages a Management Group Subscription Association.

!> Note: When using this resource, configuring subscription_ids on the azure.management.Group resource is not supported.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const example = azure.management.getGroup({
    name: "exampleManagementGroup",
});
const exampleGetSubscription = azure.core.getSubscription({
    subscriptionId: "12345678-1234-1234-1234-123456789012",
});
const exampleGroupSubscriptionAssociation = new azure.management.GroupSubscriptionAssociation("example", {
    managementGroupId: example.then(example => example.id),
    subscriptionId: exampleGetSubscription.then(exampleGetSubscription => exampleGetSubscription.id),
});
Copy
import pulumi
import pulumi_azure as azure

example = azure.management.get_group(name="exampleManagementGroup")
example_get_subscription = azure.core.get_subscription(subscription_id="12345678-1234-1234-1234-123456789012")
example_group_subscription_association = azure.management.GroupSubscriptionAssociation("example",
    management_group_id=example.id,
    subscription_id=example_get_subscription.id)
Copy
package main

import (
	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/management"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := management.LookupGroup(ctx, &management.LookupGroupArgs{
			Name: pulumi.StringRef("exampleManagementGroup"),
		}, nil)
		if err != nil {
			return err
		}
		exampleGetSubscription, err := core.LookupSubscription(ctx, &core.LookupSubscriptionArgs{
			SubscriptionId: pulumi.StringRef("12345678-1234-1234-1234-123456789012"),
		}, nil)
		if err != nil {
			return err
		}
		_, err = management.NewGroupSubscriptionAssociation(ctx, "example", &management.GroupSubscriptionAssociationArgs{
			ManagementGroupId: pulumi.String(example.Id),
			SubscriptionId:    pulumi.String(exampleGetSubscription.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;

return await Deployment.RunAsync(() => 
{
    var example = Azure.Management.GetGroup.Invoke(new()
    {
        Name = "exampleManagementGroup",
    });

    var exampleGetSubscription = Azure.Core.GetSubscription.Invoke(new()
    {
        SubscriptionId = "12345678-1234-1234-1234-123456789012",
    });

    var exampleGroupSubscriptionAssociation = new Azure.Management.GroupSubscriptionAssociation("example", new()
    {
        ManagementGroupId = example.Apply(getGroupResult => getGroupResult.Id),
        SubscriptionId = exampleGetSubscription.Apply(getSubscriptionResult => getSubscriptionResult.Id),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.management.ManagementFunctions;
import com.pulumi.azure.management.inputs.GetGroupArgs;
import com.pulumi.azure.core.CoreFunctions;
import com.pulumi.azure.core.inputs.GetSubscriptionArgs;
import com.pulumi.azure.management.GroupSubscriptionAssociation;
import com.pulumi.azure.management.GroupSubscriptionAssociationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var example = ManagementFunctions.getGroup(GetGroupArgs.builder()
            .name("exampleManagementGroup")
            .build());

        final var exampleGetSubscription = CoreFunctions.getSubscription(GetSubscriptionArgs.builder()
            .subscriptionId("12345678-1234-1234-1234-123456789012")
            .build());

        var exampleGroupSubscriptionAssociation = new GroupSubscriptionAssociation("exampleGroupSubscriptionAssociation", GroupSubscriptionAssociationArgs.builder()
            .managementGroupId(example.applyValue(getGroupResult -> getGroupResult.id()))
            .subscriptionId(exampleGetSubscription.applyValue(getSubscriptionResult -> getSubscriptionResult.id()))
            .build());

    }
}
Copy
resources:
  exampleGroupSubscriptionAssociation:
    type: azure:management:GroupSubscriptionAssociation
    name: example
    properties:
      managementGroupId: ${example.id}
      subscriptionId: ${exampleGetSubscription.id}
variables:
  example:
    fn::invoke:
      function: azure:management:getGroup
      arguments:
        name: exampleManagementGroup
  exampleGetSubscription:
    fn::invoke:
      function: azure:core:getSubscription
      arguments:
        subscriptionId: 12345678-1234-1234-1234-123456789012
Copy

Create GroupSubscriptionAssociation Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new GroupSubscriptionAssociation(name: string, args: GroupSubscriptionAssociationArgs, opts?: CustomResourceOptions);
@overload
def GroupSubscriptionAssociation(resource_name: str,
                                 args: GroupSubscriptionAssociationArgs,
                                 opts: Optional[ResourceOptions] = None)

@overload
def GroupSubscriptionAssociation(resource_name: str,
                                 opts: Optional[ResourceOptions] = None,
                                 management_group_id: Optional[str] = None,
                                 subscription_id: Optional[str] = None)
func NewGroupSubscriptionAssociation(ctx *Context, name string, args GroupSubscriptionAssociationArgs, opts ...ResourceOption) (*GroupSubscriptionAssociation, error)
public GroupSubscriptionAssociation(string name, GroupSubscriptionAssociationArgs args, CustomResourceOptions? opts = null)
public GroupSubscriptionAssociation(String name, GroupSubscriptionAssociationArgs args)
public GroupSubscriptionAssociation(String name, GroupSubscriptionAssociationArgs args, CustomResourceOptions options)
type: azure:management:GroupSubscriptionAssociation
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. GroupSubscriptionAssociationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. GroupSubscriptionAssociationArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. GroupSubscriptionAssociationArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. GroupSubscriptionAssociationArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. GroupSubscriptionAssociationArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var groupSubscriptionAssociationResource = new Azure.Management.GroupSubscriptionAssociation("groupSubscriptionAssociationResource", new()
{
    ManagementGroupId = "string",
    SubscriptionId = "string",
});
Copy
example, err := management.NewGroupSubscriptionAssociation(ctx, "groupSubscriptionAssociationResource", &management.GroupSubscriptionAssociationArgs{
	ManagementGroupId: pulumi.String("string"),
	SubscriptionId:    pulumi.String("string"),
})
Copy
var groupSubscriptionAssociationResource = new GroupSubscriptionAssociation("groupSubscriptionAssociationResource", GroupSubscriptionAssociationArgs.builder()
    .managementGroupId("string")
    .subscriptionId("string")
    .build());
Copy
group_subscription_association_resource = azure.management.GroupSubscriptionAssociation("groupSubscriptionAssociationResource",
    management_group_id="string",
    subscription_id="string")
Copy
const groupSubscriptionAssociationResource = new azure.management.GroupSubscriptionAssociation("groupSubscriptionAssociationResource", {
    managementGroupId: "string",
    subscriptionId: "string",
});
Copy
type: azure:management:GroupSubscriptionAssociation
properties:
    managementGroupId: string
    subscriptionId: string
Copy

GroupSubscriptionAssociation Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The GroupSubscriptionAssociation resource accepts the following input properties:

ManagementGroupId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the Management Group to associate the Subscription with. Changing this forces a new Management to be created.
SubscriptionId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the Subscription to be associated with the Management Group. Changing this forces a new Management to be created.
ManagementGroupId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the Management Group to associate the Subscription with. Changing this forces a new Management to be created.
SubscriptionId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the Subscription to be associated with the Management Group. Changing this forces a new Management to be created.
managementGroupId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the Management Group to associate the Subscription with. Changing this forces a new Management to be created.
subscriptionId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the Subscription to be associated with the Management Group. Changing this forces a new Management to be created.
managementGroupId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the Management Group to associate the Subscription with. Changing this forces a new Management to be created.
subscriptionId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the Subscription to be associated with the Management Group. Changing this forces a new Management to be created.
management_group_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the Management Group to associate the Subscription with. Changing this forces a new Management to be created.
subscription_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the Subscription to be associated with the Management Group. Changing this forces a new Management to be created.
managementGroupId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the Management Group to associate the Subscription with. Changing this forces a new Management to be created.
subscriptionId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the Subscription to be associated with the Management Group. Changing this forces a new Management to be created.

Outputs

All input properties are implicitly available as output properties. Additionally, the GroupSubscriptionAssociation resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing GroupSubscriptionAssociation Resource

Get an existing GroupSubscriptionAssociation resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: GroupSubscriptionAssociationState, opts?: CustomResourceOptions): GroupSubscriptionAssociation
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        management_group_id: Optional[str] = None,
        subscription_id: Optional[str] = None) -> GroupSubscriptionAssociation
func GetGroupSubscriptionAssociation(ctx *Context, name string, id IDInput, state *GroupSubscriptionAssociationState, opts ...ResourceOption) (*GroupSubscriptionAssociation, error)
public static GroupSubscriptionAssociation Get(string name, Input<string> id, GroupSubscriptionAssociationState? state, CustomResourceOptions? opts = null)
public static GroupSubscriptionAssociation get(String name, Output<String> id, GroupSubscriptionAssociationState state, CustomResourceOptions options)
resources:  _:    type: azure:management:GroupSubscriptionAssociation    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
ManagementGroupId Changes to this property will trigger replacement. string
The ID of the Management Group to associate the Subscription with. Changing this forces a new Management to be created.
SubscriptionId Changes to this property will trigger replacement. string
The ID of the Subscription to be associated with the Management Group. Changing this forces a new Management to be created.
ManagementGroupId Changes to this property will trigger replacement. string
The ID of the Management Group to associate the Subscription with. Changing this forces a new Management to be created.
SubscriptionId Changes to this property will trigger replacement. string
The ID of the Subscription to be associated with the Management Group. Changing this forces a new Management to be created.
managementGroupId Changes to this property will trigger replacement. String
The ID of the Management Group to associate the Subscription with. Changing this forces a new Management to be created.
subscriptionId Changes to this property will trigger replacement. String
The ID of the Subscription to be associated with the Management Group. Changing this forces a new Management to be created.
managementGroupId Changes to this property will trigger replacement. string
The ID of the Management Group to associate the Subscription with. Changing this forces a new Management to be created.
subscriptionId Changes to this property will trigger replacement. string
The ID of the Subscription to be associated with the Management Group. Changing this forces a new Management to be created.
management_group_id Changes to this property will trigger replacement. str
The ID of the Management Group to associate the Subscription with. Changing this forces a new Management to be created.
subscription_id Changes to this property will trigger replacement. str
The ID of the Subscription to be associated with the Management Group. Changing this forces a new Management to be created.
managementGroupId Changes to this property will trigger replacement. String
The ID of the Management Group to associate the Subscription with. Changing this forces a new Management to be created.
subscriptionId Changes to this property will trigger replacement. String
The ID of the Subscription to be associated with the Management Group. Changing this forces a new Management to be created.

Import

Managements can be imported using the resource id, e.g.

$ pulumi import azure:management/groupSubscriptionAssociation:GroupSubscriptionAssociation example /providers/Microsoft.Management/managementGroups/MyManagementGroup/subscriptions/12345678-1234-1234-1234-123456789012
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Azure Classic pulumi/pulumi-azure
License
Apache-2.0
Notes
This Pulumi package is based on the azurerm Terraform Provider.