1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. cms
  5. MonitorGroupInstances
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.cms.MonitorGroupInstances

Explore with Pulumi AI

Provides a Cloud Monitor Service Monitor Group Instances resource.

For information about Cloud Monitor Service Monitor Group Instances and how to use it, see What is Monitor Group Instances.

NOTE: Available since v1.115.0.

Example Usage

Basic Usage

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

const config = new pulumi.Config();
const name = config.get("name") || "tf_example";
const defaultNetwork = new alicloud.vpc.Network("default", {
    vpcName: name,
    cidrBlock: "192.168.0.0/16",
});
const defaultMonitorGroup = new alicloud.cms.MonitorGroup("default", {monitorGroupName: name});
const _default = alicloud.getRegions({
    current: true,
});
const example = new alicloud.cms.MonitorGroupInstances("example", {
    groupId: defaultMonitorGroup.id,
    instances: [{
        instanceId: defaultNetwork.id,
        instanceName: name,
        regionId: _default.then(_default => _default.regions?.[0]?.id),
        category: "vpc",
    }],
});
Copy
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "tf_example"
default_network = alicloud.vpc.Network("default",
    vpc_name=name,
    cidr_block="192.168.0.0/16")
default_monitor_group = alicloud.cms.MonitorGroup("default", monitor_group_name=name)
default = alicloud.get_regions(current=True)
example = alicloud.cms.MonitorGroupInstances("example",
    group_id=default_monitor_group.id,
    instances=[{
        "instance_id": default_network.id,
        "instance_name": name,
        "region_id": default.regions[0].id,
        "category": "vpc",
    }])
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/cms"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		cfg := config.New(ctx, "")
		name := "tf_example"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
			VpcName:   pulumi.String(name),
			CidrBlock: pulumi.String("192.168.0.0/16"),
		})
		if err != nil {
			return err
		}
		defaultMonitorGroup, err := cms.NewMonitorGroup(ctx, "default", &cms.MonitorGroupArgs{
			MonitorGroupName: pulumi.String(name),
		})
		if err != nil {
			return err
		}
		_default, err := alicloud.GetRegions(ctx, &alicloud.GetRegionsArgs{
			Current: pulumi.BoolRef(true),
		}, nil)
		if err != nil {
			return err
		}
		_, err = cms.NewMonitorGroupInstances(ctx, "example", &cms.MonitorGroupInstancesArgs{
			GroupId: defaultMonitorGroup.ID(),
			Instances: cms.MonitorGroupInstancesInstanceArray{
				&cms.MonitorGroupInstancesInstanceArgs{
					InstanceId:   defaultNetwork.ID(),
					InstanceName: pulumi.String(name),
					RegionId:     pulumi.String(_default.Regions[0].Id),
					Category:     pulumi.String("vpc"),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var config = new Config();
    var name = config.Get("name") ?? "tf_example";
    var defaultNetwork = new AliCloud.Vpc.Network("default", new()
    {
        VpcName = name,
        CidrBlock = "192.168.0.0/16",
    });

    var defaultMonitorGroup = new AliCloud.Cms.MonitorGroup("default", new()
    {
        MonitorGroupName = name,
    });

    var @default = AliCloud.GetRegions.Invoke(new()
    {
        Current = true,
    });

    var example = new AliCloud.Cms.MonitorGroupInstances("example", new()
    {
        GroupId = defaultMonitorGroup.Id,
        Instances = new[]
        {
            new AliCloud.Cms.Inputs.MonitorGroupInstancesInstanceArgs
            {
                InstanceId = defaultNetwork.Id,
                InstanceName = name,
                RegionId = @default.Apply(@default => @default.Apply(getRegionsResult => getRegionsResult.Regions[0]?.Id)),
                Category = "vpc",
            },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.cms.MonitorGroup;
import com.pulumi.alicloud.cms.MonitorGroupArgs;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetRegionsArgs;
import com.pulumi.alicloud.cms.MonitorGroupInstances;
import com.pulumi.alicloud.cms.MonitorGroupInstancesArgs;
import com.pulumi.alicloud.cms.inputs.MonitorGroupInstancesInstanceArgs;
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 config = ctx.config();
        final var name = config.get("name").orElse("tf_example");
        var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
            .vpcName(name)
            .cidrBlock("192.168.0.0/16")
            .build());

        var defaultMonitorGroup = new MonitorGroup("defaultMonitorGroup", MonitorGroupArgs.builder()
            .monitorGroupName(name)
            .build());

        final var default = AlicloudFunctions.getRegions(GetRegionsArgs.builder()
            .current(true)
            .build());

        var example = new MonitorGroupInstances("example", MonitorGroupInstancesArgs.builder()
            .groupId(defaultMonitorGroup.id())
            .instances(MonitorGroupInstancesInstanceArgs.builder()
                .instanceId(defaultNetwork.id())
                .instanceName(name)
                .regionId(default_.regions()[0].id())
                .category("vpc")
                .build())
            .build());

    }
}
Copy
configuration:
  name:
    type: string
    default: tf_example
resources:
  defaultNetwork:
    type: alicloud:vpc:Network
    name: default
    properties:
      vpcName: ${name}
      cidrBlock: 192.168.0.0/16
  defaultMonitorGroup:
    type: alicloud:cms:MonitorGroup
    name: default
    properties:
      monitorGroupName: ${name}
  example:
    type: alicloud:cms:MonitorGroupInstances
    properties:
      groupId: ${defaultMonitorGroup.id}
      instances:
        - instanceId: ${defaultNetwork.id}
          instanceName: ${name}
          regionId: ${default.regions[0].id}
          category: vpc
variables:
  default:
    fn::invoke:
      function: alicloud:getRegions
      arguments:
        current: true
Copy

Create MonitorGroupInstances Resource

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

Constructor syntax

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

@overload
def MonitorGroupInstances(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          group_id: Optional[str] = None,
                          instances: Optional[Sequence[MonitorGroupInstancesInstanceArgs]] = None)
func NewMonitorGroupInstances(ctx *Context, name string, args MonitorGroupInstancesArgs, opts ...ResourceOption) (*MonitorGroupInstances, error)
public MonitorGroupInstances(string name, MonitorGroupInstancesArgs args, CustomResourceOptions? opts = null)
public MonitorGroupInstances(String name, MonitorGroupInstancesArgs args)
public MonitorGroupInstances(String name, MonitorGroupInstancesArgs args, CustomResourceOptions options)
type: alicloud:cms:MonitorGroupInstances
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. MonitorGroupInstancesArgs
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. MonitorGroupInstancesArgs
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. MonitorGroupInstancesArgs
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. MonitorGroupInstancesArgs
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. MonitorGroupInstancesArgs
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 monitorGroupInstancesResource = new AliCloud.Cms.MonitorGroupInstances("monitorGroupInstancesResource", new()
{
    GroupId = "string",
    Instances = new[]
    {
        new AliCloud.Cms.Inputs.MonitorGroupInstancesInstanceArgs
        {
            Category = "string",
            InstanceId = "string",
            InstanceName = "string",
            RegionId = "string",
        },
    },
});
Copy
example, err := cms.NewMonitorGroupInstances(ctx, "monitorGroupInstancesResource", &cms.MonitorGroupInstancesArgs{
	GroupId: pulumi.String("string"),
	Instances: cms.MonitorGroupInstancesInstanceArray{
		&cms.MonitorGroupInstancesInstanceArgs{
			Category:     pulumi.String("string"),
			InstanceId:   pulumi.String("string"),
			InstanceName: pulumi.String("string"),
			RegionId:     pulumi.String("string"),
		},
	},
})
Copy
var monitorGroupInstancesResource = new MonitorGroupInstances("monitorGroupInstancesResource", MonitorGroupInstancesArgs.builder()
    .groupId("string")
    .instances(MonitorGroupInstancesInstanceArgs.builder()
        .category("string")
        .instanceId("string")
        .instanceName("string")
        .regionId("string")
        .build())
    .build());
Copy
monitor_group_instances_resource = alicloud.cms.MonitorGroupInstances("monitorGroupInstancesResource",
    group_id="string",
    instances=[{
        "category": "string",
        "instance_id": "string",
        "instance_name": "string",
        "region_id": "string",
    }])
Copy
const monitorGroupInstancesResource = new alicloud.cms.MonitorGroupInstances("monitorGroupInstancesResource", {
    groupId: "string",
    instances: [{
        category: "string",
        instanceId: "string",
        instanceName: "string",
        regionId: "string",
    }],
});
Copy
type: alicloud:cms:MonitorGroupInstances
properties:
    groupId: string
    instances:
        - category: string
          instanceId: string
          instanceName: string
          regionId: string
Copy

MonitorGroupInstances 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 MonitorGroupInstances resource accepts the following input properties:

GroupId
This property is required.
Changes to this property will trigger replacement.
string
The id of Cms Group.
Instances This property is required. List<Pulumi.AliCloud.Cms.Inputs.MonitorGroupInstancesInstance>
Instance information added to the Cms Group. See instances below.
GroupId
This property is required.
Changes to this property will trigger replacement.
string
The id of Cms Group.
Instances This property is required. []MonitorGroupInstancesInstanceArgs
Instance information added to the Cms Group. See instances below.
groupId
This property is required.
Changes to this property will trigger replacement.
String
The id of Cms Group.
instances This property is required. List<MonitorGroupInstancesInstance>
Instance information added to the Cms Group. See instances below.
groupId
This property is required.
Changes to this property will trigger replacement.
string
The id of Cms Group.
instances This property is required. MonitorGroupInstancesInstance[]
Instance information added to the Cms Group. See instances below.
group_id
This property is required.
Changes to this property will trigger replacement.
str
The id of Cms Group.
instances This property is required. Sequence[MonitorGroupInstancesInstanceArgs]
Instance information added to the Cms Group. See instances below.
groupId
This property is required.
Changes to this property will trigger replacement.
String
The id of Cms Group.
instances This property is required. List<Property Map>
Instance information added to the Cms Group. See instances below.

Outputs

All input properties are implicitly available as output properties. Additionally, the MonitorGroupInstances 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 MonitorGroupInstances Resource

Get an existing MonitorGroupInstances 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?: MonitorGroupInstancesState, opts?: CustomResourceOptions): MonitorGroupInstances
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        group_id: Optional[str] = None,
        instances: Optional[Sequence[MonitorGroupInstancesInstanceArgs]] = None) -> MonitorGroupInstances
func GetMonitorGroupInstances(ctx *Context, name string, id IDInput, state *MonitorGroupInstancesState, opts ...ResourceOption) (*MonitorGroupInstances, error)
public static MonitorGroupInstances Get(string name, Input<string> id, MonitorGroupInstancesState? state, CustomResourceOptions? opts = null)
public static MonitorGroupInstances get(String name, Output<String> id, MonitorGroupInstancesState state, CustomResourceOptions options)
resources:  _:    type: alicloud:cms:MonitorGroupInstances    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:
GroupId Changes to this property will trigger replacement. string
The id of Cms Group.
Instances List<Pulumi.AliCloud.Cms.Inputs.MonitorGroupInstancesInstance>
Instance information added to the Cms Group. See instances below.
GroupId Changes to this property will trigger replacement. string
The id of Cms Group.
Instances []MonitorGroupInstancesInstanceArgs
Instance information added to the Cms Group. See instances below.
groupId Changes to this property will trigger replacement. String
The id of Cms Group.
instances List<MonitorGroupInstancesInstance>
Instance information added to the Cms Group. See instances below.
groupId Changes to this property will trigger replacement. string
The id of Cms Group.
instances MonitorGroupInstancesInstance[]
Instance information added to the Cms Group. See instances below.
group_id Changes to this property will trigger replacement. str
The id of Cms Group.
instances Sequence[MonitorGroupInstancesInstanceArgs]
Instance information added to the Cms Group. See instances below.
groupId Changes to this property will trigger replacement. String
The id of Cms Group.
instances List<Property Map>
Instance information added to the Cms Group. See instances below.

Supporting Types

MonitorGroupInstancesInstance
, MonitorGroupInstancesInstanceArgs

Category This property is required. string
The category of instance.
InstanceId This property is required. string
The id of instance.
InstanceName This property is required. string
The name of instance.
RegionId This property is required. string
The region id of instance.
Category This property is required. string
The category of instance.
InstanceId This property is required. string
The id of instance.
InstanceName This property is required. string
The name of instance.
RegionId This property is required. string
The region id of instance.
category This property is required. String
The category of instance.
instanceId This property is required. String
The id of instance.
instanceName This property is required. String
The name of instance.
regionId This property is required. String
The region id of instance.
category This property is required. string
The category of instance.
instanceId This property is required. string
The id of instance.
instanceName This property is required. string
The name of instance.
regionId This property is required. string
The region id of instance.
category This property is required. str
The category of instance.
instance_id This property is required. str
The id of instance.
instance_name This property is required. str
The name of instance.
region_id This property is required. str
The region id of instance.
category This property is required. String
The category of instance.
instanceId This property is required. String
The id of instance.
instanceName This property is required. String
The name of instance.
regionId This property is required. String
The region id of instance.

Import

Cloud Monitor Service Monitor Group Instances can be imported using the id, e.g.

$ pulumi import alicloud:cms/monitorGroupInstances:MonitorGroupInstances example <group_id>
Copy

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

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.