1. Packages
  2. Tencentcloud Provider
  3. API Docs
  4. MonitorBindingObject
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack

tencentcloud.MonitorBindingObject

Explore with Pulumi AI

tencentcloud logo
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack

    Provides a resource for bind objects to a policy group resource.

    NOTE: It has been deprecated and replaced by tencentcloud_monitor_policy_binding_object.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as tencentcloud from "@pulumi/tencentcloud";
    
    const instances = tencentcloud.getInstances({});
    const group = new tencentcloud.MonitorPolicyGroup("group", {
        groupName: "terraform_test",
        policyViewName: "cvm_device",
        remark: "this is a test policy group",
        isUnionRule: 1,
        conditions: [{
            metricId: 33,
            alarmNotifyType: 1,
            alarmNotifyPeriod: 600,
            calcType: 1,
            calcValue: 3,
            calcPeriod: 300,
            continuePeriod: 2,
        }],
    });
    //for cvm
    const binding = new tencentcloud.MonitorBindingObject("binding", {
        groupId: group.monitorPolicyGroupId,
        dimensions: [{
            dimensionsJson: instances.then(instances => `{"unInstanceId":"${instances.instanceLists?.[0]?.instanceId}"}`),
        }],
    });
    
    import pulumi
    import pulumi_tencentcloud as tencentcloud
    
    instances = tencentcloud.get_instances()
    group = tencentcloud.MonitorPolicyGroup("group",
        group_name="terraform_test",
        policy_view_name="cvm_device",
        remark="this is a test policy group",
        is_union_rule=1,
        conditions=[{
            "metric_id": 33,
            "alarm_notify_type": 1,
            "alarm_notify_period": 600,
            "calc_type": 1,
            "calc_value": 3,
            "calc_period": 300,
            "continue_period": 2,
        }])
    #for cvm
    binding = tencentcloud.MonitorBindingObject("binding",
        group_id=group.monitor_policy_group_id,
        dimensions=[{
            "dimensions_json": f"{{\"unInstanceId\":\"{instances.instance_lists[0].instance_id}\"}}",
        }])
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/tencentcloud/tencentcloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		instances, err := tencentcloud.GetInstances(ctx, &tencentcloud.GetInstancesArgs{}, nil)
    		if err != nil {
    			return err
    		}
    		group, err := tencentcloud.NewMonitorPolicyGroup(ctx, "group", &tencentcloud.MonitorPolicyGroupArgs{
    			GroupName:      pulumi.String("terraform_test"),
    			PolicyViewName: pulumi.String("cvm_device"),
    			Remark:         pulumi.String("this is a test policy group"),
    			IsUnionRule:    pulumi.Float64(1),
    			Conditions: tencentcloud.MonitorPolicyGroupConditionArray{
    				&tencentcloud.MonitorPolicyGroupConditionArgs{
    					MetricId:          pulumi.Float64(33),
    					AlarmNotifyType:   pulumi.Float64(1),
    					AlarmNotifyPeriod: pulumi.Float64(600),
    					CalcType:          pulumi.Float64(1),
    					CalcValue:         pulumi.Float64(3),
    					CalcPeriod:        pulumi.Float64(300),
    					ContinuePeriod:    pulumi.Float64(2),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// for cvm
    		_, err = tencentcloud.NewMonitorBindingObject(ctx, "binding", &tencentcloud.MonitorBindingObjectArgs{
    			GroupId: group.MonitorPolicyGroupId,
    			Dimensions: tencentcloud.MonitorBindingObjectDimensionArray{
    				&tencentcloud.MonitorBindingObjectDimensionArgs{
    					DimensionsJson: pulumi.Sprintf("{\"unInstanceId\":\"%v\"}", instances.InstanceLists[0].InstanceId),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Tencentcloud = Pulumi.Tencentcloud;
    
    return await Deployment.RunAsync(() => 
    {
        var instances = Tencentcloud.GetInstances.Invoke();
    
        var @group = new Tencentcloud.MonitorPolicyGroup("group", new()
        {
            GroupName = "terraform_test",
            PolicyViewName = "cvm_device",
            Remark = "this is a test policy group",
            IsUnionRule = 1,
            Conditions = new[]
            {
                new Tencentcloud.Inputs.MonitorPolicyGroupConditionArgs
                {
                    MetricId = 33,
                    AlarmNotifyType = 1,
                    AlarmNotifyPeriod = 600,
                    CalcType = 1,
                    CalcValue = 3,
                    CalcPeriod = 300,
                    ContinuePeriod = 2,
                },
            },
        });
    
        //for cvm
        var binding = new Tencentcloud.MonitorBindingObject("binding", new()
        {
            GroupId = @group.MonitorPolicyGroupId,
            Dimensions = new[]
            {
                new Tencentcloud.Inputs.MonitorBindingObjectDimensionArgs
                {
                    DimensionsJson = $"{{\"unInstanceId\":\"{instances.Apply(getInstancesResult => getInstancesResult.InstanceLists[0]?.InstanceId)}\"}}",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.tencentcloud.TencentcloudFunctions;
    import com.pulumi.tencentcloud.inputs.GetInstancesArgs;
    import com.pulumi.tencentcloud.MonitorPolicyGroup;
    import com.pulumi.tencentcloud.MonitorPolicyGroupArgs;
    import com.pulumi.tencentcloud.inputs.MonitorPolicyGroupConditionArgs;
    import com.pulumi.tencentcloud.MonitorBindingObject;
    import com.pulumi.tencentcloud.MonitorBindingObjectArgs;
    import com.pulumi.tencentcloud.inputs.MonitorBindingObjectDimensionArgs;
    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 instances = TencentcloudFunctions.getInstances();
    
            var group = new MonitorPolicyGroup("group", MonitorPolicyGroupArgs.builder()
                .groupName("terraform_test")
                .policyViewName("cvm_device")
                .remark("this is a test policy group")
                .isUnionRule(1)
                .conditions(MonitorPolicyGroupConditionArgs.builder()
                    .metricId(33)
                    .alarmNotifyType(1)
                    .alarmNotifyPeriod(600)
                    .calcType(1)
                    .calcValue(3)
                    .calcPeriod(300)
                    .continuePeriod(2)
                    .build())
                .build());
    
            //for cvm
            var binding = new MonitorBindingObject("binding", MonitorBindingObjectArgs.builder()
                .groupId(group.monitorPolicyGroupId())
                .dimensions(MonitorBindingObjectDimensionArgs.builder()
                    .dimensionsJson(String.format("{{\"unInstanceId\":\"%s\"}}", instances.applyValue(getInstancesResult -> getInstancesResult.instanceLists()[0].instanceId())))
                    .build())
                .build());
    
        }
    }
    
    resources:
      group:
        type: tencentcloud:MonitorPolicyGroup
        properties:
          groupName: terraform_test
          policyViewName: cvm_device
          remark: this is a test policy group
          isUnionRule: 1
          conditions:
            - metricId: 33
              alarmNotifyType: 1
              alarmNotifyPeriod: 600
              calcType: 1
              calcValue: 3
              calcPeriod: 300
              continuePeriod: 2
      #for cvm
      binding:
        type: tencentcloud:MonitorBindingObject
        properties:
          groupId: ${group.monitorPolicyGroupId}
          dimensions:
            - dimensionsJson: '{"unInstanceId":"${instances.instanceLists[0].instanceId}"}'
    variables:
      instances:
        fn::invoke:
          function: tencentcloud:getInstances
          arguments: {}
    

    Create MonitorBindingObject Resource

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

    Constructor syntax

    new MonitorBindingObject(name: string, args: MonitorBindingObjectArgs, opts?: CustomResourceOptions);
    @overload
    def MonitorBindingObject(resource_name: str,
                             args: MonitorBindingObjectArgs,
                             opts: Optional[ResourceOptions] = None)
    
    @overload
    def MonitorBindingObject(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             dimensions: Optional[Sequence[MonitorBindingObjectDimensionArgs]] = None,
                             group_id: Optional[float] = None,
                             monitor_binding_object_id: Optional[str] = None)
    func NewMonitorBindingObject(ctx *Context, name string, args MonitorBindingObjectArgs, opts ...ResourceOption) (*MonitorBindingObject, error)
    public MonitorBindingObject(string name, MonitorBindingObjectArgs args, CustomResourceOptions? opts = null)
    public MonitorBindingObject(String name, MonitorBindingObjectArgs args)
    public MonitorBindingObject(String name, MonitorBindingObjectArgs args, CustomResourceOptions options)
    
    type: tencentcloud:MonitorBindingObject
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

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

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

    Dimensions List<MonitorBindingObjectDimension>
    A list objects. Each element contains the following attributes:
    GroupId double
    Policy group ID for binding objects.
    MonitorBindingObjectId string
    ID of the resource.
    Dimensions []MonitorBindingObjectDimensionArgs
    A list objects. Each element contains the following attributes:
    GroupId float64
    Policy group ID for binding objects.
    MonitorBindingObjectId string
    ID of the resource.
    dimensions List<MonitorBindingObjectDimension>
    A list objects. Each element contains the following attributes:
    groupId Double
    Policy group ID for binding objects.
    monitorBindingObjectId String
    ID of the resource.
    dimensions MonitorBindingObjectDimension[]
    A list objects. Each element contains the following attributes:
    groupId number
    Policy group ID for binding objects.
    monitorBindingObjectId string
    ID of the resource.
    dimensions Sequence[MonitorBindingObjectDimensionArgs]
    A list objects. Each element contains the following attributes:
    group_id float
    Policy group ID for binding objects.
    monitor_binding_object_id str
    ID of the resource.
    dimensions List<Property Map>
    A list objects. Each element contains the following attributes:
    groupId Number
    Policy group ID for binding objects.
    monitorBindingObjectId String
    ID of the resource.

    Outputs

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

    Get an existing MonitorBindingObject 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?: MonitorBindingObjectState, opts?: CustomResourceOptions): MonitorBindingObject
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            dimensions: Optional[Sequence[MonitorBindingObjectDimensionArgs]] = None,
            group_id: Optional[float] = None,
            monitor_binding_object_id: Optional[str] = None) -> MonitorBindingObject
    func GetMonitorBindingObject(ctx *Context, name string, id IDInput, state *MonitorBindingObjectState, opts ...ResourceOption) (*MonitorBindingObject, error)
    public static MonitorBindingObject Get(string name, Input<string> id, MonitorBindingObjectState? state, CustomResourceOptions? opts = null)
    public static MonitorBindingObject get(String name, Output<String> id, MonitorBindingObjectState state, CustomResourceOptions options)
    resources:  _:    type: tencentcloud:MonitorBindingObject    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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:
    Dimensions List<MonitorBindingObjectDimension>
    A list objects. Each element contains the following attributes:
    GroupId double
    Policy group ID for binding objects.
    MonitorBindingObjectId string
    ID of the resource.
    Dimensions []MonitorBindingObjectDimensionArgs
    A list objects. Each element contains the following attributes:
    GroupId float64
    Policy group ID for binding objects.
    MonitorBindingObjectId string
    ID of the resource.
    dimensions List<MonitorBindingObjectDimension>
    A list objects. Each element contains the following attributes:
    groupId Double
    Policy group ID for binding objects.
    monitorBindingObjectId String
    ID of the resource.
    dimensions MonitorBindingObjectDimension[]
    A list objects. Each element contains the following attributes:
    groupId number
    Policy group ID for binding objects.
    monitorBindingObjectId string
    ID of the resource.
    dimensions Sequence[MonitorBindingObjectDimensionArgs]
    A list objects. Each element contains the following attributes:
    group_id float
    Policy group ID for binding objects.
    monitor_binding_object_id str
    ID of the resource.
    dimensions List<Property Map>
    A list objects. Each element contains the following attributes:
    groupId Number
    Policy group ID for binding objects.
    monitorBindingObjectId String
    ID of the resource.

    Supporting Types

    MonitorBindingObjectDimension, MonitorBindingObjectDimensionArgs

    DimensionsJson string
    Represents a collection of dimensions of an object instance, json format.eg:'{"unInstanceId":"ins-ot3cq4bi"}'.
    UniqueId string
    Object unique ID.
    DimensionsJson string
    Represents a collection of dimensions of an object instance, json format.eg:'{"unInstanceId":"ins-ot3cq4bi"}'.
    UniqueId string
    Object unique ID.
    dimensionsJson String
    Represents a collection of dimensions of an object instance, json format.eg:'{"unInstanceId":"ins-ot3cq4bi"}'.
    uniqueId String
    Object unique ID.
    dimensionsJson string
    Represents a collection of dimensions of an object instance, json format.eg:'{"unInstanceId":"ins-ot3cq4bi"}'.
    uniqueId string
    Object unique ID.
    dimensions_json str
    Represents a collection of dimensions of an object instance, json format.eg:'{"unInstanceId":"ins-ot3cq4bi"}'.
    unique_id str
    Object unique ID.
    dimensionsJson String
    Represents a collection of dimensions of an object instance, json format.eg:'{"unInstanceId":"ins-ot3cq4bi"}'.
    uniqueId String
    Object unique ID.

    Package Details

    Repository
    tencentcloud tencentcloudstack/terraform-provider-tencentcloud
    License
    Notes
    This Pulumi package is based on the tencentcloud Terraform Provider.
    tencentcloud logo
    tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack