1. Packages
  2. Packages
  3. Nutanix
  4. API Docs
  5. getVmAntiAffinityPolicyV2
Viewing docs for Nutanix v0.16.0
published on Tuesday, May 26, 2026 by Piers Karsenbarg
nutanix logo
Viewing docs for Nutanix v0.16.0
published on Tuesday, May 26, 2026 by Piers Karsenbarg

    Retrieve the VM-VM Anti-Affinity policy details for the provided external identifier (ext_id).

    Example

    import * as pulumi from "@pulumi/pulumi";
    import * as nutanix from "@pierskarsenbarg/nutanix";
    
    const policy = nutanix.getVmAntiAffinityPolicyV2({
        extId: "12345678-1234-1234-1234-123456789012",
    });
    export const policyName = policy.then(policy => policy.name);
    
    import pulumi
    import pulumi_nutanix as nutanix
    
    policy = nutanix.get_vm_anti_affinity_policy_v2(ext_id="12345678-1234-1234-1234-123456789012")
    pulumi.export("policyName", policy.name)
    
    package main
    
    import (
    	"github.com/pierskarsenbarg/pulumi-nutanix/sdk/go/nutanix"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		policy, err := nutanix.GetVmAntiAffinityPolicyV2(ctx, &nutanix.LookupVmAntiAffinityPolicyV2Args{
    			ExtId: "12345678-1234-1234-1234-123456789012",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("policyName", policy.Name)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Nutanix = PiersKarsenbarg.Nutanix;
    
    return await Deployment.RunAsync(() => 
    {
        var policy = Nutanix.GetVmAntiAffinityPolicyV2.Invoke(new()
        {
            ExtId = "12345678-1234-1234-1234-123456789012",
        });
    
        return new Dictionary<string, object?>
        {
            ["policyName"] = policy.Apply(getVmAntiAffinityPolicyV2Result => getVmAntiAffinityPolicyV2Result.Name),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nutanix.NutanixFunctions;
    import com.pulumi.nutanix.inputs.GetVmAntiAffinityPolicyV2Args;
    import java.util.ArrayList;
    import java.util.Arrays;
    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 policy = NutanixFunctions.getVmAntiAffinityPolicyV2(GetVmAntiAffinityPolicyV2Args.builder()
                .extId("12345678-1234-1234-1234-123456789012")
                .build());
    
            ctx.export("policyName", policy.name());
        }
    }
    
    variables:
      policy:
        fn::invoke:
          function: nutanix:getVmAntiAffinityPolicyV2
          arguments:
            extId: 12345678-1234-1234-1234-123456789012
    outputs:
      policyName: ${policy.name}
    
    pulumi {
      required_providers {
        nutanix = {
          source = "pulumi/nutanix"
        }
      }
    }
    
    data "nutanix_getvmantiaffinitypolicyv2" "policy" {
      ext_id = "12345678-1234-1234-1234-123456789012"
    }
    
    output "policyName" {
      value = data.nutanix_getvmantiaffinitypolicyv2.policy.name
    }
    

    Using getVmAntiAffinityPolicyV2

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getVmAntiAffinityPolicyV2(args: GetVmAntiAffinityPolicyV2Args, opts?: InvokeOptions): Promise<GetVmAntiAffinityPolicyV2Result>
    function getVmAntiAffinityPolicyV2Output(args: GetVmAntiAffinityPolicyV2OutputArgs, opts?: InvokeOptions): Output<GetVmAntiAffinityPolicyV2Result>
    def get_vm_anti_affinity_policy_v2(ext_id: Optional[str] = None,
                                       opts: Optional[InvokeOptions] = None) -> GetVmAntiAffinityPolicyV2Result
    def get_vm_anti_affinity_policy_v2_output(ext_id: pulumi.Input[Optional[str]] = None,
                                       opts: Optional[InvokeOptions] = None) -> Output[GetVmAntiAffinityPolicyV2Result]
    func LookupVmAntiAffinityPolicyV2(ctx *Context, args *LookupVmAntiAffinityPolicyV2Args, opts ...InvokeOption) (*LookupVmAntiAffinityPolicyV2Result, error)
    func LookupVmAntiAffinityPolicyV2Output(ctx *Context, args *LookupVmAntiAffinityPolicyV2OutputArgs, opts ...InvokeOption) LookupVmAntiAffinityPolicyV2ResultOutput

    > Note: This function is named LookupVmAntiAffinityPolicyV2 in the Go SDK.

    public static class GetVmAntiAffinityPolicyV2 
    {
        public static Task<GetVmAntiAffinityPolicyV2Result> InvokeAsync(GetVmAntiAffinityPolicyV2Args args, InvokeOptions? opts = null)
        public static Output<GetVmAntiAffinityPolicyV2Result> Invoke(GetVmAntiAffinityPolicyV2InvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetVmAntiAffinityPolicyV2Result> getVmAntiAffinityPolicyV2(GetVmAntiAffinityPolicyV2Args args, InvokeOptions options)
    public static Output<GetVmAntiAffinityPolicyV2Result> getVmAntiAffinityPolicyV2(GetVmAntiAffinityPolicyV2Args args, InvokeOptions options)
    
    fn::invoke:
      function: nutanix:index/getVmAntiAffinityPolicyV2:getVmAntiAffinityPolicyV2
      arguments:
        # arguments dictionary
    data "nutanix_getvmantiaffinitypolicyv2" "name" {
        # arguments
    }

    The following arguments are supported:

    ExtId string
    The external identifier of a VM-VM Anti-Affinity policy.
    ExtId string
    The external identifier of a VM-VM Anti-Affinity policy.
    ext_id string
    The external identifier of a VM-VM Anti-Affinity policy.
    extId String
    The external identifier of a VM-VM Anti-Affinity policy.
    extId string
    The external identifier of a VM-VM Anti-Affinity policy.
    ext_id str
    The external identifier of a VM-VM Anti-Affinity policy.
    extId String
    The external identifier of a VM-VM Anti-Affinity policy.

    getVmAntiAffinityPolicyV2 Result

    The following output properties are available:

    Categories List<string>
    List of VM category external IDs that this policy applies to.
    CreateTime string
    The timestamp when the policy was created.
    CreatedBy Dictionary<string, string>
    Information about the entity that created the policy.
    Description string
    A description of the VM-VM Anti-Affinity policy.
    ExtId string
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    The name of the VM-VM Anti-Affinity policy.
    NumCompliantVms int
    Number of compliant VMs which are part of the VM-VM anti-affinity policy.
    NumNonCompliantVms int
    Number of non-compliant VMs which are part of the VM-VM anti-affinity policy.
    NumPendingVms int
    Number of VMs with compliance state as pending, which are part of the VM-VM anti-affinity policy.
    UpdateTime string
    The timestamp when the policy was last updated.
    UpdatedBy Dictionary<string, string>
    Information about the entity that last updated the policy.
    Categories []string
    List of VM category external IDs that this policy applies to.
    CreateTime string
    The timestamp when the policy was created.
    CreatedBy map[string]string
    Information about the entity that created the policy.
    Description string
    A description of the VM-VM Anti-Affinity policy.
    ExtId string
    Id string
    The provider-assigned unique ID for this managed resource.
    Name string
    The name of the VM-VM Anti-Affinity policy.
    NumCompliantVms int
    Number of compliant VMs which are part of the VM-VM anti-affinity policy.
    NumNonCompliantVms int
    Number of non-compliant VMs which are part of the VM-VM anti-affinity policy.
    NumPendingVms int
    Number of VMs with compliance state as pending, which are part of the VM-VM anti-affinity policy.
    UpdateTime string
    The timestamp when the policy was last updated.
    UpdatedBy map[string]string
    Information about the entity that last updated the policy.
    categories list(string)
    List of VM category external IDs that this policy applies to.
    create_time string
    The timestamp when the policy was created.
    created_by map(string)
    Information about the entity that created the policy.
    description string
    A description of the VM-VM Anti-Affinity policy.
    ext_id string
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    The name of the VM-VM Anti-Affinity policy.
    num_compliant_vms number
    Number of compliant VMs which are part of the VM-VM anti-affinity policy.
    num_non_compliant_vms number
    Number of non-compliant VMs which are part of the VM-VM anti-affinity policy.
    num_pending_vms number
    Number of VMs with compliance state as pending, which are part of the VM-VM anti-affinity policy.
    update_time string
    The timestamp when the policy was last updated.
    updated_by map(string)
    Information about the entity that last updated the policy.
    categories List<String>
    List of VM category external IDs that this policy applies to.
    createTime String
    The timestamp when the policy was created.
    createdBy Map<String,String>
    Information about the entity that created the policy.
    description String
    A description of the VM-VM Anti-Affinity policy.
    extId String
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    The name of the VM-VM Anti-Affinity policy.
    numCompliantVms Integer
    Number of compliant VMs which are part of the VM-VM anti-affinity policy.
    numNonCompliantVms Integer
    Number of non-compliant VMs which are part of the VM-VM anti-affinity policy.
    numPendingVms Integer
    Number of VMs with compliance state as pending, which are part of the VM-VM anti-affinity policy.
    updateTime String
    The timestamp when the policy was last updated.
    updatedBy Map<String,String>
    Information about the entity that last updated the policy.
    categories string[]
    List of VM category external IDs that this policy applies to.
    createTime string
    The timestamp when the policy was created.
    createdBy {[key: string]: string}
    Information about the entity that created the policy.
    description string
    A description of the VM-VM Anti-Affinity policy.
    extId string
    id string
    The provider-assigned unique ID for this managed resource.
    name string
    The name of the VM-VM Anti-Affinity policy.
    numCompliantVms number
    Number of compliant VMs which are part of the VM-VM anti-affinity policy.
    numNonCompliantVms number
    Number of non-compliant VMs which are part of the VM-VM anti-affinity policy.
    numPendingVms number
    Number of VMs with compliance state as pending, which are part of the VM-VM anti-affinity policy.
    updateTime string
    The timestamp when the policy was last updated.
    updatedBy {[key: string]: string}
    Information about the entity that last updated the policy.
    categories Sequence[str]
    List of VM category external IDs that this policy applies to.
    create_time str
    The timestamp when the policy was created.
    created_by Mapping[str, str]
    Information about the entity that created the policy.
    description str
    A description of the VM-VM Anti-Affinity policy.
    ext_id str
    id str
    The provider-assigned unique ID for this managed resource.
    name str
    The name of the VM-VM Anti-Affinity policy.
    num_compliant_vms int
    Number of compliant VMs which are part of the VM-VM anti-affinity policy.
    num_non_compliant_vms int
    Number of non-compliant VMs which are part of the VM-VM anti-affinity policy.
    num_pending_vms int
    Number of VMs with compliance state as pending, which are part of the VM-VM anti-affinity policy.
    update_time str
    The timestamp when the policy was last updated.
    updated_by Mapping[str, str]
    Information about the entity that last updated the policy.
    categories List<String>
    List of VM category external IDs that this policy applies to.
    createTime String
    The timestamp when the policy was created.
    createdBy Map<String>
    Information about the entity that created the policy.
    description String
    A description of the VM-VM Anti-Affinity policy.
    extId String
    id String
    The provider-assigned unique ID for this managed resource.
    name String
    The name of the VM-VM Anti-Affinity policy.
    numCompliantVms Number
    Number of compliant VMs which are part of the VM-VM anti-affinity policy.
    numNonCompliantVms Number
    Number of non-compliant VMs which are part of the VM-VM anti-affinity policy.
    numPendingVms Number
    Number of VMs with compliance state as pending, which are part of the VM-VM anti-affinity policy.
    updateTime String
    The timestamp when the policy was last updated.
    updatedBy Map<String>
    Information about the entity that last updated the policy.

    Package Details

    Repository
    nutanix pierskarsenbarg/pulumi-nutanix
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the nutanix Terraform Provider.
    nutanix logo
    Viewing docs for Nutanix v0.16.0
    published on Tuesday, May 26, 2026 by Piers Karsenbarg

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial