1. Packages
  2. Packages
  3. Nsxt Provider
  4. API Docs
  5. PolicyConstraint
Viewing docs for nsxt 3.12.0
published on Monday, May 18, 2026 by vmware
Viewing docs for nsxt 3.12.0
published on Monday, May 18, 2026 by vmware

    Create PolicyConstraint Resource

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

    Constructor syntax

    new PolicyConstraint(name: string, args: PolicyConstraintArgs, opts?: CustomResourceOptions);
    @overload
    def PolicyConstraint(resource_name: str,
                         args: PolicyConstraintArgs,
                         opts: Optional[ResourceOptions] = None)
    
    @overload
    def PolicyConstraint(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         display_name: Optional[str] = None,
                         context: Optional[PolicyConstraintContextArgs] = None,
                         description: Optional[str] = None,
                         instance_counts: Optional[Sequence[PolicyConstraintInstanceCountArgs]] = None,
                         message: Optional[str] = None,
                         nsx_id: Optional[str] = None,
                         policy_constraint_id: Optional[str] = None,
                         tags: Optional[Sequence[PolicyConstraintTagArgs]] = None,
                         target_owner_type: Optional[str] = None,
                         targets: Optional[Sequence[PolicyConstraintTargetArgs]] = None)
    func NewPolicyConstraint(ctx *Context, name string, args PolicyConstraintArgs, opts ...ResourceOption) (*PolicyConstraint, error)
    public PolicyConstraint(string name, PolicyConstraintArgs args, CustomResourceOptions? opts = null)
    public PolicyConstraint(String name, PolicyConstraintArgs args)
    public PolicyConstraint(String name, PolicyConstraintArgs args, CustomResourceOptions options)
    
    type: nsxt:PolicyConstraint
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "nsxt_policyconstraint" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args PolicyConstraintArgs
    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 PolicyConstraintArgs
    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 PolicyConstraintArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args PolicyConstraintArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args PolicyConstraintArgs
    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 policyConstraintResource = new Nsxt.PolicyConstraint("policyConstraintResource", new()
    {
        DisplayName = "string",
        Context = new Nsxt.Inputs.PolicyConstraintContextArgs
        {
            ProjectId = "string",
        },
        Description = "string",
        InstanceCounts = new[]
        {
            new Nsxt.Inputs.PolicyConstraintInstanceCountArgs
            {
                Count = 0,
                TargetResourceType = "string",
                Operator = "string",
            },
        },
        Message = "string",
        NsxId = "string",
        PolicyConstraintId = "string",
        Tags = new[]
        {
            new Nsxt.Inputs.PolicyConstraintTagArgs
            {
                Scope = "string",
                Tag = "string",
            },
        },
        TargetOwnerType = "string",
        Targets = new[]
        {
            new Nsxt.Inputs.PolicyConstraintTargetArgs
            {
                PathPrefix = "string",
            },
        },
    });
    
    example, err := nsxt.NewPolicyConstraint(ctx, "policyConstraintResource", &nsxt.PolicyConstraintArgs{
    	DisplayName: pulumi.String("string"),
    	Context: &nsxt.PolicyConstraintContextArgs{
    		ProjectId: pulumi.String("string"),
    	},
    	Description: pulumi.String("string"),
    	InstanceCounts: nsxt.PolicyConstraintInstanceCountArray{
    		&nsxt.PolicyConstraintInstanceCountArgs{
    			Count:              pulumi.Float64(0),
    			TargetResourceType: pulumi.String("string"),
    			Operator:           pulumi.String("string"),
    		},
    	},
    	Message:            pulumi.String("string"),
    	NsxId:              pulumi.String("string"),
    	PolicyConstraintId: pulumi.String("string"),
    	Tags: nsxt.PolicyConstraintTagArray{
    		&nsxt.PolicyConstraintTagArgs{
    			Scope: pulumi.String("string"),
    			Tag:   pulumi.String("string"),
    		},
    	},
    	TargetOwnerType: pulumi.String("string"),
    	Targets: nsxt.PolicyConstraintTargetArray{
    		&nsxt.PolicyConstraintTargetArgs{
    			PathPrefix: pulumi.String("string"),
    		},
    	},
    })
    
    resource "nsxt_policyconstraint" "policyConstraintResource" {
      display_name = "string"
      context = {
        project_id = "string"
      }
      description = "string"
      instance_counts {
        count                = 0
        target_resource_type = "string"
        operator             = "string"
      }
      message              = "string"
      nsx_id               = "string"
      policy_constraint_id = "string"
      tags {
        scope = "string"
        tag   = "string"
      }
      target_owner_type = "string"
      targets {
        path_prefix = "string"
      }
    }
    
    var policyConstraintResource = new PolicyConstraint("policyConstraintResource", PolicyConstraintArgs.builder()
        .displayName("string")
        .context(PolicyConstraintContextArgs.builder()
            .projectId("string")
            .build())
        .description("string")
        .instanceCounts(PolicyConstraintInstanceCountArgs.builder()
            .count(0.0)
            .targetResourceType("string")
            .operator("string")
            .build())
        .message("string")
        .nsxId("string")
        .policyConstraintId("string")
        .tags(PolicyConstraintTagArgs.builder()
            .scope("string")
            .tag("string")
            .build())
        .targetOwnerType("string")
        .targets(PolicyConstraintTargetArgs.builder()
            .pathPrefix("string")
            .build())
        .build());
    
    policy_constraint_resource = nsxt.PolicyConstraint("policyConstraintResource",
        display_name="string",
        context={
            "project_id": "string",
        },
        description="string",
        instance_counts=[{
            "count": float(0),
            "target_resource_type": "string",
            "operator": "string",
        }],
        message="string",
        nsx_id="string",
        policy_constraint_id="string",
        tags=[{
            "scope": "string",
            "tag": "string",
        }],
        target_owner_type="string",
        targets=[{
            "path_prefix": "string",
        }])
    
    const policyConstraintResource = new nsxt.PolicyConstraint("policyConstraintResource", {
        displayName: "string",
        context: {
            projectId: "string",
        },
        description: "string",
        instanceCounts: [{
            count: 0,
            targetResourceType: "string",
            operator: "string",
        }],
        message: "string",
        nsxId: "string",
        policyConstraintId: "string",
        tags: [{
            scope: "string",
            tag: "string",
        }],
        targetOwnerType: "string",
        targets: [{
            pathPrefix: "string",
        }],
    });
    
    type: nsxt:PolicyConstraint
    properties:
        context:
            projectId: string
        description: string
        displayName: string
        instanceCounts:
            - count: 0
              operator: string
              targetResourceType: string
        message: string
        nsxId: string
        policyConstraintId: string
        tags:
            - scope: string
              tag: string
        targetOwnerType: string
        targets:
            - pathPrefix: string
    

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

    DisplayName string
    Display name of the resource.
    Context PolicyConstraintContext
    The context which the object belongs to
    Description string
    Description of the resource.
    InstanceCounts List<PolicyConstraintInstanceCount>
    Constraint details
    Message string
    User friendly message to be shown to users upon violation.
    NsxId string
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    PolicyConstraintId string
    ID of the resource.
    Tags List<PolicyConstraintTag>
    A list of scope + tag pairs to associate with this resource.
    TargetOwnerType string
    Targets List<PolicyConstraintTarget>
    Targets for the constraints to be enforced
    DisplayName string
    Display name of the resource.
    Context PolicyConstraintContextArgs
    The context which the object belongs to
    Description string
    Description of the resource.
    InstanceCounts []PolicyConstraintInstanceCountArgs
    Constraint details
    Message string
    User friendly message to be shown to users upon violation.
    NsxId string
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    PolicyConstraintId string
    ID of the resource.
    Tags []PolicyConstraintTagArgs
    A list of scope + tag pairs to associate with this resource.
    TargetOwnerType string
    Targets []PolicyConstraintTargetArgs
    Targets for the constraints to be enforced
    display_name string
    Display name of the resource.
    context object
    The context which the object belongs to
    description string
    Description of the resource.
    instance_counts list(object)
    Constraint details
    message string
    User friendly message to be shown to users upon violation.
    nsx_id string
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    policy_constraint_id string
    ID of the resource.
    tags list(object)
    A list of scope + tag pairs to associate with this resource.
    target_owner_type string
    targets list(object)
    Targets for the constraints to be enforced
    displayName String
    Display name of the resource.
    context PolicyConstraintContext
    The context which the object belongs to
    description String
    Description of the resource.
    instanceCounts List<PolicyConstraintInstanceCount>
    Constraint details
    message String
    User friendly message to be shown to users upon violation.
    nsxId String
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    policyConstraintId String
    ID of the resource.
    tags List<PolicyConstraintTag>
    A list of scope + tag pairs to associate with this resource.
    targetOwnerType String
    targets List<PolicyConstraintTarget>
    Targets for the constraints to be enforced
    displayName string
    Display name of the resource.
    context PolicyConstraintContext
    The context which the object belongs to
    description string
    Description of the resource.
    instanceCounts PolicyConstraintInstanceCount[]
    Constraint details
    message string
    User friendly message to be shown to users upon violation.
    nsxId string
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    policyConstraintId string
    ID of the resource.
    tags PolicyConstraintTag[]
    A list of scope + tag pairs to associate with this resource.
    targetOwnerType string
    targets PolicyConstraintTarget[]
    Targets for the constraints to be enforced
    display_name str
    Display name of the resource.
    context PolicyConstraintContextArgs
    The context which the object belongs to
    description str
    Description of the resource.
    instance_counts Sequence[PolicyConstraintInstanceCountArgs]
    Constraint details
    message str
    User friendly message to be shown to users upon violation.
    nsx_id str
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    policy_constraint_id str
    ID of the resource.
    tags Sequence[PolicyConstraintTagArgs]
    A list of scope + tag pairs to associate with this resource.
    target_owner_type str
    targets Sequence[PolicyConstraintTargetArgs]
    Targets for the constraints to be enforced
    displayName String
    Display name of the resource.
    context Property Map
    The context which the object belongs to
    description String
    Description of the resource.
    instanceCounts List<Property Map>
    Constraint details
    message String
    User friendly message to be shown to users upon violation.
    nsxId String
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    policyConstraintId String
    ID of the resource.
    tags List<Property Map>
    A list of scope + tag pairs to associate with this resource.
    targetOwnerType String
    targets List<Property Map>
    Targets for the constraints to be enforced

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Path string
    The NSX path of the policy resource.
    Revision double
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.
    Id string
    The provider-assigned unique ID for this managed resource.
    Path string
    The NSX path of the policy resource.
    Revision float64
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.
    id string
    The provider-assigned unique ID for this managed resource.
    path string
    The NSX path of the policy resource.
    revision number
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.
    id String
    The provider-assigned unique ID for this managed resource.
    path String
    The NSX path of the policy resource.
    revision Double
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.
    id string
    The provider-assigned unique ID for this managed resource.
    path string
    The NSX path of the policy resource.
    revision number
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.
    id str
    The provider-assigned unique ID for this managed resource.
    path str
    The NSX path of the policy resource.
    revision float
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.
    id String
    The provider-assigned unique ID for this managed resource.
    path String
    The NSX path of the policy resource.
    revision Number
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.

    Look up Existing PolicyConstraint Resource

    Get an existing PolicyConstraint 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?: PolicyConstraintState, opts?: CustomResourceOptions): PolicyConstraint
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            context: Optional[PolicyConstraintContextArgs] = None,
            description: Optional[str] = None,
            display_name: Optional[str] = None,
            instance_counts: Optional[Sequence[PolicyConstraintInstanceCountArgs]] = None,
            message: Optional[str] = None,
            nsx_id: Optional[str] = None,
            path: Optional[str] = None,
            policy_constraint_id: Optional[str] = None,
            revision: Optional[float] = None,
            tags: Optional[Sequence[PolicyConstraintTagArgs]] = None,
            target_owner_type: Optional[str] = None,
            targets: Optional[Sequence[PolicyConstraintTargetArgs]] = None) -> PolicyConstraint
    func GetPolicyConstraint(ctx *Context, name string, id IDInput, state *PolicyConstraintState, opts ...ResourceOption) (*PolicyConstraint, error)
    public static PolicyConstraint Get(string name, Input<string> id, PolicyConstraintState? state, CustomResourceOptions? opts = null)
    public static PolicyConstraint get(String name, Output<String> id, PolicyConstraintState state, CustomResourceOptions options)
    resources:  _:    type: nsxt:PolicyConstraint    get:      id: ${id}
    import {
      to = nsxt_policyconstraint.example
      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:
    Context PolicyConstraintContext
    The context which the object belongs to
    Description string
    Description of the resource.
    DisplayName string
    Display name of the resource.
    InstanceCounts List<PolicyConstraintInstanceCount>
    Constraint details
    Message string
    User friendly message to be shown to users upon violation.
    NsxId string
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    Path string
    The NSX path of the policy resource.
    PolicyConstraintId string
    ID of the resource.
    Revision double
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.
    Tags List<PolicyConstraintTag>
    A list of scope + tag pairs to associate with this resource.
    TargetOwnerType string
    Targets List<PolicyConstraintTarget>
    Targets for the constraints to be enforced
    Context PolicyConstraintContextArgs
    The context which the object belongs to
    Description string
    Description of the resource.
    DisplayName string
    Display name of the resource.
    InstanceCounts []PolicyConstraintInstanceCountArgs
    Constraint details
    Message string
    User friendly message to be shown to users upon violation.
    NsxId string
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    Path string
    The NSX path of the policy resource.
    PolicyConstraintId string
    ID of the resource.
    Revision float64
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.
    Tags []PolicyConstraintTagArgs
    A list of scope + tag pairs to associate with this resource.
    TargetOwnerType string
    Targets []PolicyConstraintTargetArgs
    Targets for the constraints to be enforced
    context object
    The context which the object belongs to
    description string
    Description of the resource.
    display_name string
    Display name of the resource.
    instance_counts list(object)
    Constraint details
    message string
    User friendly message to be shown to users upon violation.
    nsx_id string
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    path string
    The NSX path of the policy resource.
    policy_constraint_id string
    ID of the resource.
    revision number
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.
    tags list(object)
    A list of scope + tag pairs to associate with this resource.
    target_owner_type string
    targets list(object)
    Targets for the constraints to be enforced
    context PolicyConstraintContext
    The context which the object belongs to
    description String
    Description of the resource.
    displayName String
    Display name of the resource.
    instanceCounts List<PolicyConstraintInstanceCount>
    Constraint details
    message String
    User friendly message to be shown to users upon violation.
    nsxId String
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    path String
    The NSX path of the policy resource.
    policyConstraintId String
    ID of the resource.
    revision Double
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.
    tags List<PolicyConstraintTag>
    A list of scope + tag pairs to associate with this resource.
    targetOwnerType String
    targets List<PolicyConstraintTarget>
    Targets for the constraints to be enforced
    context PolicyConstraintContext
    The context which the object belongs to
    description string
    Description of the resource.
    displayName string
    Display name of the resource.
    instanceCounts PolicyConstraintInstanceCount[]
    Constraint details
    message string
    User friendly message to be shown to users upon violation.
    nsxId string
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    path string
    The NSX path of the policy resource.
    policyConstraintId string
    ID of the resource.
    revision number
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.
    tags PolicyConstraintTag[]
    A list of scope + tag pairs to associate with this resource.
    targetOwnerType string
    targets PolicyConstraintTarget[]
    Targets for the constraints to be enforced
    context PolicyConstraintContextArgs
    The context which the object belongs to
    description str
    Description of the resource.
    display_name str
    Display name of the resource.
    instance_counts Sequence[PolicyConstraintInstanceCountArgs]
    Constraint details
    message str
    User friendly message to be shown to users upon violation.
    nsx_id str
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    path str
    The NSX path of the policy resource.
    policy_constraint_id str
    ID of the resource.
    revision float
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.
    tags Sequence[PolicyConstraintTagArgs]
    A list of scope + tag pairs to associate with this resource.
    target_owner_type str
    targets Sequence[PolicyConstraintTargetArgs]
    Targets for the constraints to be enforced
    context Property Map
    The context which the object belongs to
    description String
    Description of the resource.
    displayName String
    Display name of the resource.
    instanceCounts List<Property Map>
    Constraint details
    message String
    User friendly message to be shown to users upon violation.
    nsxId String
    The NSX ID of this resource. If set, this ID will be used to create the resource.
    path String
    The NSX path of the policy resource.
    policyConstraintId String
    ID of the resource.
    revision Number
    Indicates current revision number of the object as seen by NSX-T API server. This attribute can be useful for debugging.
    tags List<Property Map>
    A list of scope + tag pairs to associate with this resource.
    targetOwnerType String
    targets List<Property Map>
    Targets for the constraints to be enforced

    Supporting Types

    PolicyConstraintContext, PolicyConstraintContextArgs

    ProjectId string
    Id of the project which the resource belongs to.
    ProjectId string
    Id of the project which the resource belongs to.
    project_id string
    Id of the project which the resource belongs to.
    projectId String
    Id of the project which the resource belongs to.
    projectId string
    Id of the project which the resource belongs to.
    project_id str
    Id of the project which the resource belongs to.
    projectId String
    Id of the project which the resource belongs to.

    PolicyConstraintInstanceCount, PolicyConstraintInstanceCountArgs

    Count double
    Limit of instances
    TargetResourceType string
    Type of the resource that should be limited in instance count (refer to the table below)
    Operator string
    Either <= or <. Default is <=
    Count float64
    Limit of instances
    TargetResourceType string
    Type of the resource that should be limited in instance count (refer to the table below)
    Operator string
    Either <= or <. Default is <=
    count number
    Limit of instances
    target_resource_type string
    Type of the resource that should be limited in instance count (refer to the table below)
    operator string
    Either <= or <. Default is <=
    count Double
    Limit of instances
    targetResourceType String
    Type of the resource that should be limited in instance count (refer to the table below)
    operator String
    Either <= or <. Default is <=
    count number
    Limit of instances
    targetResourceType string
    Type of the resource that should be limited in instance count (refer to the table below)
    operator string
    Either <= or <. Default is <=
    count float
    Limit of instances
    target_resource_type str
    Type of the resource that should be limited in instance count (refer to the table below)
    operator str
    Either <= or <. Default is <=
    count Number
    Limit of instances
    targetResourceType String
    Type of the resource that should be limited in instance count (refer to the table below)
    operator String
    Either <= or <. Default is <=

    PolicyConstraintTag, PolicyConstraintTagArgs

    Scope string
    Tag string
    A list of scope + tag pairs to associate with this resource.
    Scope string
    Tag string
    A list of scope + tag pairs to associate with this resource.
    scope string
    tag string
    A list of scope + tag pairs to associate with this resource.
    scope String
    tag String
    A list of scope + tag pairs to associate with this resource.
    scope string
    tag string
    A list of scope + tag pairs to associate with this resource.
    scope str
    tag str
    A list of scope + tag pairs to associate with this resource.
    scope String
    tag String
    A list of scope + tag pairs to associate with this resource.

    PolicyConstraintTarget, PolicyConstraintTargetArgs

    PathPrefix string
    Prefix match to the path
    PathPrefix string
    Prefix match to the path
    path_prefix string
    Prefix match to the path
    pathPrefix String
    Prefix match to the path
    pathPrefix string
    Prefix match to the path
    path_prefix str
    Prefix match to the path
    pathPrefix String
    Prefix match to the path

    Package Details

    Repository
    nsxt vmware/terraform-provider-nsxt
    License
    Notes
    This Pulumi package is based on the nsxt Terraform Provider.
    Viewing docs for nsxt 3.12.0
    published on Monday, May 18, 2026 by vmware

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial