1. Packages
  2. Nsxt Provider
  3. API Docs
  4. getPolicySecurityPolicy
nsxt 3.8.1 published on Wednesday, Apr 30, 2025 by vmware

nsxt.getPolicySecurityPolicy

Explore with Pulumi AI

nsxt logo
nsxt 3.8.1 published on Wednesday, Apr 30, 2025 by vmware

    This data source provides information about policy Security Policues configured on NSX. This data source can be useful for fetching policy path to use in nsxt.PolicyPredefinedSecurityPolicy resource.

    This data source is applicable to NSX Policy Manager, NSX Global Manager and VMC.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as nsxt from "@pulumi/nsxt";
    
    const predefined = nsxt.getPolicySecurityPolicy({
        category: "Application",
        isDefault: true,
    });
    
    import pulumi
    import pulumi_nsxt as nsxt
    
    predefined = nsxt.get_policy_security_policy(category="Application",
        is_default=True)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/nsxt/v3/nsxt"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := nsxt.LookupPolicySecurityPolicy(ctx, &nsxt.LookupPolicySecurityPolicyArgs{
    			Category:  pulumi.StringRef("Application"),
    			IsDefault: pulumi.BoolRef(true),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Nsxt = Pulumi.Nsxt;
    
    return await Deployment.RunAsync(() => 
    {
        var predefined = Nsxt.GetPolicySecurityPolicy.Invoke(new()
        {
            Category = "Application",
            IsDefault = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nsxt.NsxtFunctions;
    import com.pulumi.nsxt.inputs.GetPolicySecurityPolicyArgs;
    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 predefined = NsxtFunctions.getPolicySecurityPolicy(GetPolicySecurityPolicyArgs.builder()
                .category("Application")
                .isDefault(true)
                .build());
    
        }
    }
    
    variables:
      predefined:
        fn::invoke:
          function: nsxt:getPolicySecurityPolicy
          arguments:
            category: Application
            isDefault: true
    

    Multi-Tenancy

    import * as pulumi from "@pulumi/pulumi";
    import * as nsxt from "@pulumi/nsxt";
    
    const demoproj = nsxt.getPolicyProject({
        displayName: "demoproj",
    });
    const predefined = demoproj.then(demoproj => nsxt.getPolicySecurityPolicy({
        context: {
            projectId: demoproj.id,
        },
        isDefault: true,
        category: "Application",
    }));
    
    import pulumi
    import pulumi_nsxt as nsxt
    
    demoproj = nsxt.get_policy_project(display_name="demoproj")
    predefined = nsxt.get_policy_security_policy(context={
            "project_id": demoproj.id,
        },
        is_default=True,
        category="Application")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/nsxt/v3/nsxt"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		demoproj, err := nsxt.LookupPolicyProject(ctx, &nsxt.LookupPolicyProjectArgs{
    			DisplayName: pulumi.StringRef("demoproj"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = nsxt.LookupPolicySecurityPolicy(ctx, &nsxt.LookupPolicySecurityPolicyArgs{
    			Context: nsxt.GetPolicySecurityPolicyContext{
    				ProjectId: demoproj.Id,
    			},
    			IsDefault: pulumi.BoolRef(true),
    			Category:  pulumi.StringRef("Application"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Nsxt = Pulumi.Nsxt;
    
    return await Deployment.RunAsync(() => 
    {
        var demoproj = Nsxt.GetPolicyProject.Invoke(new()
        {
            DisplayName = "demoproj",
        });
    
        var predefined = Nsxt.GetPolicySecurityPolicy.Invoke(new()
        {
            Context = new Nsxt.Inputs.GetPolicySecurityPolicyContextInputArgs
            {
                ProjectId = demoproj.Apply(getPolicyProjectResult => getPolicyProjectResult.Id),
            },
            IsDefault = true,
            Category = "Application",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nsxt.NsxtFunctions;
    import com.pulumi.nsxt.inputs.GetPolicyProjectArgs;
    import com.pulumi.nsxt.inputs.GetPolicySecurityPolicyArgs;
    import com.pulumi.nsxt.inputs.GetPolicySecurityPolicyContextArgs;
    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 demoproj = NsxtFunctions.getPolicyProject(GetPolicyProjectArgs.builder()
                .displayName("demoproj")
                .build());
    
            final var predefined = NsxtFunctions.getPolicySecurityPolicy(GetPolicySecurityPolicyArgs.builder()
                .context(GetPolicySecurityPolicyContextArgs.builder()
                    .projectId(demoproj.applyValue(getPolicyProjectResult -> getPolicyProjectResult.id()))
                    .build())
                .isDefault(true)
                .category("Application")
                .build());
    
        }
    }
    
    variables:
      demoproj:
        fn::invoke:
          function: nsxt:getPolicyProject
          arguments:
            displayName: demoproj
      predefined:
        fn::invoke:
          function: nsxt:getPolicySecurityPolicy
          arguments:
            context:
              projectId: ${demoproj.id}
            isDefault: true
            category: Application
    

    Using getPolicySecurityPolicy

    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 getPolicySecurityPolicy(args: GetPolicySecurityPolicyArgs, opts?: InvokeOptions): Promise<GetPolicySecurityPolicyResult>
    function getPolicySecurityPolicyOutput(args: GetPolicySecurityPolicyOutputArgs, opts?: InvokeOptions): Output<GetPolicySecurityPolicyResult>
    def get_policy_security_policy(category: Optional[str] = None,
                                   context: Optional[GetPolicySecurityPolicyContext] = None,
                                   description: Optional[str] = None,
                                   display_name: Optional[str] = None,
                                   domain: Optional[str] = None,
                                   id: Optional[str] = None,
                                   is_default: Optional[bool] = None,
                                   opts: Optional[InvokeOptions] = None) -> GetPolicySecurityPolicyResult
    def get_policy_security_policy_output(category: Optional[pulumi.Input[str]] = None,
                                   context: Optional[pulumi.Input[GetPolicySecurityPolicyContextArgs]] = None,
                                   description: Optional[pulumi.Input[str]] = None,
                                   display_name: Optional[pulumi.Input[str]] = None,
                                   domain: Optional[pulumi.Input[str]] = None,
                                   id: Optional[pulumi.Input[str]] = None,
                                   is_default: Optional[pulumi.Input[bool]] = None,
                                   opts: Optional[InvokeOptions] = None) -> Output[GetPolicySecurityPolicyResult]
    func LookupPolicySecurityPolicy(ctx *Context, args *LookupPolicySecurityPolicyArgs, opts ...InvokeOption) (*LookupPolicySecurityPolicyResult, error)
    func LookupPolicySecurityPolicyOutput(ctx *Context, args *LookupPolicySecurityPolicyOutputArgs, opts ...InvokeOption) LookupPolicySecurityPolicyResultOutput

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

    public static class GetPolicySecurityPolicy 
    {
        public static Task<GetPolicySecurityPolicyResult> InvokeAsync(GetPolicySecurityPolicyArgs args, InvokeOptions? opts = null)
        public static Output<GetPolicySecurityPolicyResult> Invoke(GetPolicySecurityPolicyInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetPolicySecurityPolicyResult> getPolicySecurityPolicy(GetPolicySecurityPolicyArgs args, InvokeOptions options)
    public static Output<GetPolicySecurityPolicyResult> getPolicySecurityPolicy(GetPolicySecurityPolicyArgs args, InvokeOptions options)
    
    fn::invoke:
      function: nsxt:index/getPolicySecurityPolicy:getPolicySecurityPolicy
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Category string
    Category of the policy to retrieve.
    Context GetPolicySecurityPolicyContext
    The context which the object belongs to
    Description string
    The description of the resource.
    DisplayName string
    The Display Name of the policy to retrieve.
    Domain string
    The domain of the policy, defaults to default. Needs to be specified in VMC environment.
    Id string
    The ID of Security Policy to retrieve.
    IsDefault bool
    Whether this is a default policy. Default is false.
    Category string
    Category of the policy to retrieve.
    Context GetPolicySecurityPolicyContext
    The context which the object belongs to
    Description string
    The description of the resource.
    DisplayName string
    The Display Name of the policy to retrieve.
    Domain string
    The domain of the policy, defaults to default. Needs to be specified in VMC environment.
    Id string
    The ID of Security Policy to retrieve.
    IsDefault bool
    Whether this is a default policy. Default is false.
    category String
    Category of the policy to retrieve.
    context GetPolicySecurityPolicyContext
    The context which the object belongs to
    description String
    The description of the resource.
    displayName String
    The Display Name of the policy to retrieve.
    domain String
    The domain of the policy, defaults to default. Needs to be specified in VMC environment.
    id String
    The ID of Security Policy to retrieve.
    isDefault Boolean
    Whether this is a default policy. Default is false.
    category string
    Category of the policy to retrieve.
    context GetPolicySecurityPolicyContext
    The context which the object belongs to
    description string
    The description of the resource.
    displayName string
    The Display Name of the policy to retrieve.
    domain string
    The domain of the policy, defaults to default. Needs to be specified in VMC environment.
    id string
    The ID of Security Policy to retrieve.
    isDefault boolean
    Whether this is a default policy. Default is false.
    category str
    Category of the policy to retrieve.
    context GetPolicySecurityPolicyContext
    The context which the object belongs to
    description str
    The description of the resource.
    display_name str
    The Display Name of the policy to retrieve.
    domain str
    The domain of the policy, defaults to default. Needs to be specified in VMC environment.
    id str
    The ID of Security Policy to retrieve.
    is_default bool
    Whether this is a default policy. Default is false.
    category String
    Category of the policy to retrieve.
    context Property Map
    The context which the object belongs to
    description String
    The description of the resource.
    displayName String
    The Display Name of the policy to retrieve.
    domain String
    The domain of the policy, defaults to default. Needs to be specified in VMC environment.
    id String
    The ID of Security Policy to retrieve.
    isDefault Boolean
    Whether this is a default policy. Default is false.

    getPolicySecurityPolicy Result

    The following output properties are available:

    Category string
    Description string
    The description of the resource.
    DisplayName string
    Id string
    Path string
    The NSX path of the policy resource.
    Context GetPolicySecurityPolicyContext
    Domain string
    IsDefault bool
    Category string
    Description string
    The description of the resource.
    DisplayName string
    Id string
    Path string
    The NSX path of the policy resource.
    Context GetPolicySecurityPolicyContext
    Domain string
    IsDefault bool
    category String
    description String
    The description of the resource.
    displayName String
    id String
    path String
    The NSX path of the policy resource.
    context GetPolicySecurityPolicyContext
    domain String
    isDefault Boolean
    category string
    description string
    The description of the resource.
    displayName string
    id string
    path string
    The NSX path of the policy resource.
    context GetPolicySecurityPolicyContext
    domain string
    isDefault boolean
    category str
    description str
    The description of the resource.
    display_name str
    id str
    path str
    The NSX path of the policy resource.
    context GetPolicySecurityPolicyContext
    domain str
    is_default bool
    category String
    description String
    The description of the resource.
    displayName String
    id String
    path String
    The NSX path of the policy resource.
    context Property Map
    domain String
    isDefault Boolean

    Supporting Types

    GetPolicySecurityPolicyContext

    ProjectId string
    The ID of the project which the object belongs to
    ProjectId string
    The ID of the project which the object belongs to
    projectId String
    The ID of the project which the object belongs to
    projectId string
    The ID of the project which the object belongs to
    project_id str
    The ID of the project which the object belongs to
    projectId String
    The ID of the project which the object belongs to

    Package Details

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