1. Registry
  2. Packages
  3. Alibaba Cloud Provider
  4. API Docs
  5. apig
  6. getPolicies
Viewing docs for Alibaba Cloud v3.108.0
published on Thursday, Sep 17, 2026 by Pulumi
alicloud logo alicloud logo
Viewing docs for Alibaba Cloud v3.108.0
published on Thursday, Sep 17, 2026 by Pulumi

    This data source provides Apig Policy available to the user.What is Policy

    NOTE: Available since v1.292.0.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    // The ID of an existing APIG gateway
    const gatewayId = config.require("gatewayId");
    const _default = alicloud.apig.getPolicies({
        gatewayId: gatewayId,
    });
    export const firstPolicyId = _default.then(_default => _default.policies?.[0]?.policyId);
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    # The ID of an existing APIG gateway
    gateway_id = config.require("gatewayId")
    default = alicloud.apig.get_policies(gateway_id=gateway_id)
    pulumi.export("firstPolicyId", default.policies[0].policy_id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/apig"
    	"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, "")
    		// The ID of an existing APIG gateway
    		gatewayId := cfg.Require("gatewayId")
    		_default, err := apig.GetPolicies(ctx, &apig.GetPoliciesArgs{
    			GatewayId: pulumi.StringRef(gatewayId),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("firstPolicyId", _default.Policies[0].PolicyId)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        // The ID of an existing APIG gateway
        var gatewayId = config.Require("gatewayId");
        var @default = AliCloud.Apig.GetPolicies.Invoke(new()
        {
            GatewayId = gatewayId,
        });
    
        return new Dictionary<string, object?>
        {
            ["firstPolicyId"] = @default.Apply(@default => @default.Apply(getPoliciesResult => getPoliciesResult.Policies[0]?.PolicyId)),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.apig.ApigFunctions;
    import com.pulumi.alicloud.apig.inputs.GetPoliciesArgs;
    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 config = ctx.config();
            final var gatewayId = config.require("gatewayId");
            final var default = ApigFunctions.getPolicies(GetPoliciesArgs.builder()
                .gatewayId(gatewayId)
                .build());
    
            ctx.export("firstPolicyId", default_.policies()[0].policyId());
        }
    }
    
    configuration:
      gatewayId:
        type: string
    variables:
      default:
        fn::invoke:
          function: alicloud:apig:getPolicies
          arguments:
            gatewayId: ${gatewayId}
    outputs:
      firstPolicyId: ${default.policies[0].policyId}
    
    pulumi {
      required_providers {
        alicloud = {
          source = "pulumi/alicloud"
        }
      }
    }
    
    data "alicloud_apig_getpolicies" "default" {
      gateway_id = var.gatewayId
    }
    
    variable "gatewayId" {
      type        = string
      description = "The ID of an existing APIG gateway"
    }
    output "firstPolicyId" {
      value = data.alicloud_apig_getpolicies.default.policies[0].policy_id
    }
    

    Using getPolicies

    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 getPolicies(args: GetPoliciesArgs, opts?: InvokeOptions): Promise<GetPoliciesResult>
    function getPoliciesOutput(args: GetPoliciesOutputArgs, opts?: InvokeOutputOptions): Output<GetPoliciesResult>
    def get_policies(attach_resource_ids: Optional[str] = None,
                     attach_resource_type: Optional[str] = None,
                     enable_details: Optional[bool] = None,
                     environment_id: Optional[str] = None,
                     gateway_id: Optional[str] = None,
                     ids: Optional[Sequence[str]] = None,
                     name_regex: Optional[str] = None,
                     output_file: Optional[str] = None,
                     opts: Optional[InvokeOptions] = None) -> GetPoliciesResult
    def get_policies_output(attach_resource_ids: pulumi.Input[Optional[str]] = None,
                     attach_resource_type: pulumi.Input[Optional[str]] = None,
                     enable_details: pulumi.Input[Optional[bool]] = None,
                     environment_id: pulumi.Input[Optional[str]] = None,
                     gateway_id: pulumi.Input[Optional[str]] = None,
                     ids: pulumi.Input[Optional[Sequence[pulumi.Input[str]]]] = None,
                     name_regex: pulumi.Input[Optional[str]] = None,
                     output_file: pulumi.Input[Optional[str]] = None,
                     opts: Optional[InvokeOutputOptions] = None) -> Output[GetPoliciesResult]
    func GetPolicies(ctx *Context, args *GetPoliciesArgs, opts ...InvokeOption) (*GetPoliciesResult, error)
    func GetPoliciesOutput(ctx *Context, args *GetPoliciesOutputArgs, opts ...InvokeOption) GetPoliciesResultOutput

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

    public static class GetPolicies 
    {
        public static Task<GetPoliciesResult> InvokeAsync(GetPoliciesArgs args, InvokeOptions? opts = null)
        public static Output<GetPoliciesResult> Invoke(GetPoliciesInvokeArgs args, InvokeOptions? opts = null)
        public static Output<GetPoliciesResult> Invoke(GetPoliciesInvokeArgs args, InvokeOutputOptions opts)
    }
    public static CompletableFuture<GetPoliciesResult> getPolicies(GetPoliciesArgs args, InvokeOptions options)
    public static Output<GetPoliciesResult> getPolicies(GetPoliciesArgs args, InvokeOptions options)
    public static Output<GetPoliciesResult> getPolicies(GetPoliciesArgs args, InvokeOutputOptions options)
    
    fn::invoke:
      function: alicloud:apig/getPolicies:getPolicies
      arguments:
        # arguments dictionary
    data "alicloud_apig_get_policies" "name" {
        # arguments
    }

    The following arguments are supported:

    AttachResourceIds string
    The ID of the attach point resource to filter policies by.
    AttachResourceType string
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    EnableDetails bool
    Default to false. Set it to true to output more details about resource attributes that belong to this policy.
    EnvironmentId string
    Environment id.
    GatewayId string
    Gateway id.
    Ids List<string>
    A list of Policy IDs.
    NameRegex string
    A regex string to filter results by policy name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    AttachResourceIds string
    The ID of the attach point resource to filter policies by.
    AttachResourceType string
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    EnableDetails bool
    Default to false. Set it to true to output more details about resource attributes that belong to this policy.
    EnvironmentId string
    Environment id.
    GatewayId string
    Gateway id.
    Ids []string
    A list of Policy IDs.
    NameRegex string
    A regex string to filter results by policy name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    attach_resource_ids string
    The ID of the attach point resource to filter policies by.
    attach_resource_type string
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    enable_details bool
    Default to false. Set it to true to output more details about resource attributes that belong to this policy.
    environment_id string
    Environment id.
    gateway_id string
    Gateway id.
    ids list(string)
    A list of Policy IDs.
    name_regex string
    A regex string to filter results by policy name.
    output_file string
    File name where to save data source results (after running pulumi preview).
    attachResourceIds String
    The ID of the attach point resource to filter policies by.
    attachResourceType String
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    enableDetails Boolean
    Default to false. Set it to true to output more details about resource attributes that belong to this policy.
    environmentId String
    Environment id.
    gatewayId String
    Gateway id.
    ids List<String>
    A list of Policy IDs.
    nameRegex String
    A regex string to filter results by policy name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    attachResourceIds string
    The ID of the attach point resource to filter policies by.
    attachResourceType string
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    enableDetails boolean
    Default to false. Set it to true to output more details about resource attributes that belong to this policy.
    environmentId string
    Environment id.
    gatewayId string
    Gateway id.
    ids string[]
    A list of Policy IDs.
    nameRegex string
    A regex string to filter results by policy name.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    attach_resource_ids str
    The ID of the attach point resource to filter policies by.
    attach_resource_type str
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    enable_details bool
    Default to false. Set it to true to output more details about resource attributes that belong to this policy.
    environment_id str
    Environment id.
    gateway_id str
    Gateway id.
    ids Sequence[str]
    A list of Policy IDs.
    name_regex str
    A regex string to filter results by policy name.
    output_file str
    File name where to save data source results (after running pulumi preview).
    attachResourceIds String
    The ID of the attach point resource to filter policies by.
    attachResourceType String
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    enableDetails Boolean
    Default to false. Set it to true to output more details about resource attributes that belong to this policy.
    environmentId String
    Environment id.
    gatewayId String
    Gateway id.
    ids List<String>
    A list of Policy IDs.
    nameRegex String
    A regex string to filter results by policy name.
    outputFile String
    File name where to save data source results (after running pulumi preview).

    getPolicies Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Ids List<string>
    Names List<string>
    A list of Policy names.
    Policies List<Pulumi.AliCloud.Apig.Outputs.GetPoliciesPolicy>
    A list of Policy Entries. Each element contains the following attributes:
    AttachResourceIds string
    The Mount point id list.
    AttachResourceType string
    The mount point type of the policy.
    EnableDetails bool
    EnvironmentId string
    Environment id.
    GatewayId string
    Gateway id.
    NameRegex string
    OutputFile string
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids []string
    Names []string
    A list of Policy names.
    Policies []GetPoliciesPolicy
    A list of Policy Entries. Each element contains the following attributes:
    AttachResourceIds string
    The Mount point id list.
    AttachResourceType string
    The mount point type of the policy.
    EnableDetails bool
    EnvironmentId string
    Environment id.
    GatewayId string
    Gateway id.
    NameRegex string
    OutputFile string
    id string
    The provider-assigned unique ID for this managed resource.
    ids list(string)
    names list(string)
    A list of Policy names.
    policies list(object)
    A list of Policy Entries. Each element contains the following attributes:
    attach_resource_ids string
    The Mount point id list.
    attach_resource_type string
    The mount point type of the policy.
    enable_details bool
    environment_id string
    Environment id.
    gateway_id string
    Gateway id.
    name_regex string
    output_file string
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    names List<String>
    A list of Policy names.
    policies List<GetPoliciesPolicy>
    A list of Policy Entries. Each element contains the following attributes:
    attachResourceIds String
    The Mount point id list.
    attachResourceType String
    The mount point type of the policy.
    enableDetails Boolean
    environmentId String
    Environment id.
    gatewayId String
    Gateway id.
    nameRegex String
    outputFile String
    id string
    The provider-assigned unique ID for this managed resource.
    ids string[]
    names string[]
    A list of Policy names.
    policies GetPoliciesPolicy[]
    A list of Policy Entries. Each element contains the following attributes:
    attachResourceIds string
    The Mount point id list.
    attachResourceType string
    The mount point type of the policy.
    enableDetails boolean
    environmentId string
    Environment id.
    gatewayId string
    Gateway id.
    nameRegex string
    outputFile string
    id str
    The provider-assigned unique ID for this managed resource.
    ids Sequence[str]
    names Sequence[str]
    A list of Policy names.
    policies Sequence[GetPoliciesPolicy]
    A list of Policy Entries. Each element contains the following attributes:
    attach_resource_ids str
    The Mount point id list.
    attach_resource_type str
    The mount point type of the policy.
    enable_details bool
    environment_id str
    Environment id.
    gateway_id str
    Gateway id.
    name_regex str
    output_file str
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    names List<String>
    A list of Policy names.
    policies List<Property Map>
    A list of Policy Entries. Each element contains the following attributes:
    attachResourceIds String
    The Mount point id list.
    attachResourceType String
    The mount point type of the policy.
    enableDetails Boolean
    environmentId String
    Environment id.
    gatewayId String
    Gateway id.
    nameRegex String
    outputFile String

    Supporting Types

    GetPoliciesPolicy

    AttachResourceIds List<string>
    The ID of the attach point resource to filter policies by.
    AttachResourceType string
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    EnvironmentId string
    Environment id.
    GatewayId string
    Gateway id.
    Id string
    The ID of the Policy.
    PolicyAttachmentId string
    Policy attachment id.
    PolicyClassId string
    Policy class id.
    PolicyClassName string
    Policy class name.
    PolicyConfig string
    Policy configuration.
    PolicyId string
    The first ID of the resource.
    PolicyName string
    Policy name.
    AttachResourceIds []string
    The ID of the attach point resource to filter policies by.
    AttachResourceType string
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    EnvironmentId string
    Environment id.
    GatewayId string
    Gateway id.
    Id string
    The ID of the Policy.
    PolicyAttachmentId string
    Policy attachment id.
    PolicyClassId string
    Policy class id.
    PolicyClassName string
    Policy class name.
    PolicyConfig string
    Policy configuration.
    PolicyId string
    The first ID of the resource.
    PolicyName string
    Policy name.
    attach_resource_ids list(string)
    The ID of the attach point resource to filter policies by.
    attach_resource_type string
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    environment_id string
    Environment id.
    gateway_id string
    Gateway id.
    id string
    The ID of the Policy.
    policy_attachment_id string
    Policy attachment id.
    policy_class_id string
    Policy class id.
    policy_class_name string
    Policy class name.
    policy_config string
    Policy configuration.
    policy_id string
    The first ID of the resource.
    policy_name string
    Policy name.
    attachResourceIds List<String>
    The ID of the attach point resource to filter policies by.
    attachResourceType String
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    environmentId String
    Environment id.
    gatewayId String
    Gateway id.
    id String
    The ID of the Policy.
    policyAttachmentId String
    Policy attachment id.
    policyClassId String
    Policy class id.
    policyClassName String
    Policy class name.
    policyConfig String
    Policy configuration.
    policyId String
    The first ID of the resource.
    policyName String
    Policy name.
    attachResourceIds string[]
    The ID of the attach point resource to filter policies by.
    attachResourceType string
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    environmentId string
    Environment id.
    gatewayId string
    Gateway id.
    id string
    The ID of the Policy.
    policyAttachmentId string
    Policy attachment id.
    policyClassId string
    Policy class id.
    policyClassName string
    Policy class name.
    policyConfig string
    Policy configuration.
    policyId string
    The first ID of the resource.
    policyName string
    Policy name.
    attach_resource_ids Sequence[str]
    The ID of the attach point resource to filter policies by.
    attach_resource_type str
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    environment_id str
    Environment id.
    gateway_id str
    Gateway id.
    id str
    The ID of the Policy.
    policy_attachment_id str
    Policy attachment id.
    policy_class_id str
    Policy class id.
    policy_class_name str
    Policy class name.
    policy_config str
    Policy configuration.
    policy_id str
    The first ID of the resource.
    policy_name str
    Policy name.
    attachResourceIds List<String>
    The ID of the attach point resource to filter policies by.
    attachResourceType String
    Policies support mount point types. Valid values: HttpApi, Operation, GatewayRoute, GatewayService, GatewayServicePort, Domain, Gateway.
    environmentId String
    Environment id.
    gatewayId String
    Gateway id.
    id String
    The ID of the Policy.
    policyAttachmentId String
    Policy attachment id.
    policyClassId String
    Policy class id.
    policyClassName String
    Policy class name.
    policyConfig String
    Policy configuration.
    policyId String
    The first ID of the resource.
    policyName String
    Policy name.

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the alicloud Terraform Provider.
    alicloud logo alicloud logo
    Viewing docs for Alibaba Cloud v3.108.0
    published on Thursday, Sep 17, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial