1. Packages
  2. Oracle Cloud Infrastructure
  3. API Docs
  4. Identity
  5. getPolicies
Oracle Cloud Infrastructure v2.3.0 published on Wednesday, Jul 17, 2024 by Pulumi

oci.Identity.getPolicies

Explore with Pulumi AI

oci logo
Oracle Cloud Infrastructure v2.3.0 published on Wednesday, Jul 17, 2024 by Pulumi

    This data source provides the list of Policies in Oracle Cloud Infrastructure Identity service.

    Lists the policies in the specified compartment (either the tenancy or another of your compartments). See Where to Get the Tenancy’s OCID and User’s OCID.

    To determine which policies apply to a particular group or compartment, you must view the individual statements inside all your policies. There isn’t a way to automatically obtain that information via the API.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as oci from "@pulumi/oci";
    
    const testPolicies = oci.Identity.getPolicies({
        compartmentId: tenancyOcid,
        name: policyName,
        state: policyState,
    });
    
    import pulumi
    import pulumi_oci as oci
    
    test_policies = oci.Identity.get_policies(compartment_id=tenancy_ocid,
        name=policy_name,
        state=policy_state)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-oci/sdk/v2/go/oci/Identity"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := Identity.GetPolicies(ctx, &identity.GetPoliciesArgs{
    			CompartmentId: tenancyOcid,
    			Name:          pulumi.StringRef(policyName),
    			State:         pulumi.StringRef(policyState),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Oci = Pulumi.Oci;
    
    return await Deployment.RunAsync(() => 
    {
        var testPolicies = Oci.Identity.GetPolicies.Invoke(new()
        {
            CompartmentId = tenancyOcid,
            Name = policyName,
            State = policyState,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.oci.Identity.IdentityFunctions;
    import com.pulumi.oci.Identity.inputs.GetPoliciesArgs;
    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 testPolicies = IdentityFunctions.getPolicies(GetPoliciesArgs.builder()
                .compartmentId(tenancyOcid)
                .name(policyName)
                .state(policyState)
                .build());
    
        }
    }
    
    variables:
      testPolicies:
        fn::invoke:
          Function: oci:Identity:getPolicies
          Arguments:
            compartmentId: ${tenancyOcid}
            name: ${policyName}
            state: ${policyState}
    

    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?: InvokeOptions): Output<GetPoliciesResult>
    def get_policies(compartment_id: Optional[str] = None,
                     filters: Optional[Sequence[_identity.GetPoliciesFilter]] = None,
                     name: Optional[str] = None,
                     state: Optional[str] = None,
                     opts: Optional[InvokeOptions] = None) -> GetPoliciesResult
    def get_policies_output(compartment_id: Optional[pulumi.Input[str]] = None,
                     filters: Optional[pulumi.Input[Sequence[pulumi.Input[_identity.GetPoliciesFilterArgs]]]] = None,
                     name: Optional[pulumi.Input[str]] = None,
                     state: Optional[pulumi.Input[str]] = None,
                     opts: Optional[InvokeOptions] = 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 CompletableFuture<GetPoliciesResult> getPolicies(GetPoliciesArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: oci:Identity/getPolicies:getPolicies
      arguments:
        # arguments dictionary

    The following arguments are supported:

    CompartmentId string
    The OCID of the compartment (remember that the tenancy is simply the root compartment).
    Filters List<GetPoliciesFilter>
    Name string
    A filter to only return resources that match the given name exactly.
    State string
    A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.
    CompartmentId string
    The OCID of the compartment (remember that the tenancy is simply the root compartment).
    Filters []GetPoliciesFilter
    Name string
    A filter to only return resources that match the given name exactly.
    State string
    A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.
    compartmentId String
    The OCID of the compartment (remember that the tenancy is simply the root compartment).
    filters List<GetPoliciesFilter>
    name String
    A filter to only return resources that match the given name exactly.
    state String
    A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.
    compartmentId string
    The OCID of the compartment (remember that the tenancy is simply the root compartment).
    filters GetPoliciesFilter[]
    name string
    A filter to only return resources that match the given name exactly.
    state string
    A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.
    compartment_id str
    The OCID of the compartment (remember that the tenancy is simply the root compartment).
    filters Sequence[identity.GetPoliciesFilter]
    name str
    A filter to only return resources that match the given name exactly.
    state str
    A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.
    compartmentId String
    The OCID of the compartment (remember that the tenancy is simply the root compartment).
    filters List<Property Map>
    name String
    A filter to only return resources that match the given name exactly.
    state String
    A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.

    getPolicies Result

    The following output properties are available:

    CompartmentId string
    The OCID of the compartment containing the policy (either the tenancy or another compartment).
    Id string
    The provider-assigned unique ID for this managed resource.
    Policies List<GetPoliciesPolicy>
    The list of policies.
    Filters List<GetPoliciesFilter>
    Name string
    The name you assign to the policy during creation. The name must be unique across all policies in the tenancy and cannot be changed.
    State string
    The policy's current state.
    CompartmentId string
    The OCID of the compartment containing the policy (either the tenancy or another compartment).
    Id string
    The provider-assigned unique ID for this managed resource.
    Policies []GetPoliciesPolicy
    The list of policies.
    Filters []GetPoliciesFilter
    Name string
    The name you assign to the policy during creation. The name must be unique across all policies in the tenancy and cannot be changed.
    State string
    The policy's current state.
    compartmentId String
    The OCID of the compartment containing the policy (either the tenancy or another compartment).
    id String
    The provider-assigned unique ID for this managed resource.
    policies List<GetPoliciesPolicy>
    The list of policies.
    filters List<GetPoliciesFilter>
    name String
    The name you assign to the policy during creation. The name must be unique across all policies in the tenancy and cannot be changed.
    state String
    The policy's current state.
    compartmentId string
    The OCID of the compartment containing the policy (either the tenancy or another compartment).
    id string
    The provider-assigned unique ID for this managed resource.
    policies GetPoliciesPolicy[]
    The list of policies.
    filters GetPoliciesFilter[]
    name string
    The name you assign to the policy during creation. The name must be unique across all policies in the tenancy and cannot be changed.
    state string
    The policy's current state.
    compartment_id str
    The OCID of the compartment containing the policy (either the tenancy or another compartment).
    id str
    The provider-assigned unique ID for this managed resource.
    policies Sequence[identity.GetPoliciesPolicy]
    The list of policies.
    filters Sequence[identity.GetPoliciesFilter]
    name str
    The name you assign to the policy during creation. The name must be unique across all policies in the tenancy and cannot be changed.
    state str
    The policy's current state.
    compartmentId String
    The OCID of the compartment containing the policy (either the tenancy or another compartment).
    id String
    The provider-assigned unique ID for this managed resource.
    policies List<Property Map>
    The list of policies.
    filters List<Property Map>
    name String
    The name you assign to the policy during creation. The name must be unique across all policies in the tenancy and cannot be changed.
    state String
    The policy's current state.

    Supporting Types

    GetPoliciesFilter

    Name string
    A filter to only return resources that match the given name exactly.
    Values List<string>
    Regex bool
    Name string
    A filter to only return resources that match the given name exactly.
    Values []string
    Regex bool
    name String
    A filter to only return resources that match the given name exactly.
    values List<String>
    regex Boolean
    name string
    A filter to only return resources that match the given name exactly.
    values string[]
    regex boolean
    name str
    A filter to only return resources that match the given name exactly.
    values Sequence[str]
    regex bool
    name String
    A filter to only return resources that match the given name exactly.
    values List<String>
    regex Boolean

    GetPoliciesPolicy

    CompartmentId string
    The OCID of the compartment (remember that the tenancy is simply the root compartment).
    DefinedTags Dictionary<string, object>
    Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: {"Operations.CostCenter": "42"}
    Description string
    The description you assign to the policy. Does not have to be unique, and it's changeable.
    ETag string

    Deprecated: The 'ETag' field has been deprecated and may be removed in a future version. Do not use this field.

    FreeformTags Dictionary<string, object>
    Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. Example: {"Department": "Finance"}
    Id string
    The OCID of the policy.
    InactiveState string
    The detailed status of INACTIVE lifecycleState.
    LastUpdateETag string

    Deprecated: The 'lastUpdateETag' field has been deprecated and may be removed in a future version. Do not use this field.

    Name string
    A filter to only return resources that match the given name exactly.
    PolicyHash string

    Deprecated: The 'policyHash' field has been deprecated and may be removed in a future version. Do not use this field.

    State string
    A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.
    Statements List<string>
    An array of one or more policy statements written in the policy language.
    TimeCreated string
    Date and time the policy was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
    VersionDate string
    The version of the policy. If null or set to an empty string, when a request comes in for authorization, the policy will be evaluated according to the current behavior of the services at that moment. If set to a particular date (YYYY-MM-DD), the policy will be evaluated according to the behavior of the services on that date.
    CompartmentId string
    The OCID of the compartment (remember that the tenancy is simply the root compartment).
    DefinedTags map[string]interface{}
    Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: {"Operations.CostCenter": "42"}
    Description string
    The description you assign to the policy. Does not have to be unique, and it's changeable.
    ETag string

    Deprecated: The 'ETag' field has been deprecated and may be removed in a future version. Do not use this field.

    FreeformTags map[string]interface{}
    Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. Example: {"Department": "Finance"}
    Id string
    The OCID of the policy.
    InactiveState string
    The detailed status of INACTIVE lifecycleState.
    LastUpdateETag string

    Deprecated: The 'lastUpdateETag' field has been deprecated and may be removed in a future version. Do not use this field.

    Name string
    A filter to only return resources that match the given name exactly.
    PolicyHash string

    Deprecated: The 'policyHash' field has been deprecated and may be removed in a future version. Do not use this field.

    State string
    A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.
    Statements []string
    An array of one or more policy statements written in the policy language.
    TimeCreated string
    Date and time the policy was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
    VersionDate string
    The version of the policy. If null or set to an empty string, when a request comes in for authorization, the policy will be evaluated according to the current behavior of the services at that moment. If set to a particular date (YYYY-MM-DD), the policy will be evaluated according to the behavior of the services on that date.
    ETag String

    Deprecated: The 'ETag' field has been deprecated and may be removed in a future version. Do not use this field.

    compartmentId String
    The OCID of the compartment (remember that the tenancy is simply the root compartment).
    definedTags Map<String,Object>
    Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: {"Operations.CostCenter": "42"}
    description String
    The description you assign to the policy. Does not have to be unique, and it's changeable.
    freeformTags Map<String,Object>
    Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. Example: {"Department": "Finance"}
    id String
    The OCID of the policy.
    inactiveState String
    The detailed status of INACTIVE lifecycleState.
    lastUpdateETag String

    Deprecated: The 'lastUpdateETag' field has been deprecated and may be removed in a future version. Do not use this field.

    name String
    A filter to only return resources that match the given name exactly.
    policyHash String

    Deprecated: The 'policyHash' field has been deprecated and may be removed in a future version. Do not use this field.

    state String
    A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.
    statements List<String>
    An array of one or more policy statements written in the policy language.
    timeCreated String
    Date and time the policy was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
    versionDate String
    The version of the policy. If null or set to an empty string, when a request comes in for authorization, the policy will be evaluated according to the current behavior of the services at that moment. If set to a particular date (YYYY-MM-DD), the policy will be evaluated according to the behavior of the services on that date.
    ETag string

    Deprecated: The 'ETag' field has been deprecated and may be removed in a future version. Do not use this field.

    compartmentId string
    The OCID of the compartment (remember that the tenancy is simply the root compartment).
    definedTags {[key: string]: any}
    Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: {"Operations.CostCenter": "42"}
    description string
    The description you assign to the policy. Does not have to be unique, and it's changeable.
    freeformTags {[key: string]: any}
    Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. Example: {"Department": "Finance"}
    id string
    The OCID of the policy.
    inactiveState string
    The detailed status of INACTIVE lifecycleState.
    lastUpdateETag string

    Deprecated: The 'lastUpdateETag' field has been deprecated and may be removed in a future version. Do not use this field.

    name string
    A filter to only return resources that match the given name exactly.
    policyHash string

    Deprecated: The 'policyHash' field has been deprecated and may be removed in a future version. Do not use this field.

    state string
    A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.
    statements string[]
    An array of one or more policy statements written in the policy language.
    timeCreated string
    Date and time the policy was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
    versionDate string
    The version of the policy. If null or set to an empty string, when a request comes in for authorization, the policy will be evaluated according to the current behavior of the services at that moment. If set to a particular date (YYYY-MM-DD), the policy will be evaluated according to the behavior of the services on that date.
    compartment_id str
    The OCID of the compartment (remember that the tenancy is simply the root compartment).
    defined_tags Mapping[str, Any]
    Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: {"Operations.CostCenter": "42"}
    description str
    The description you assign to the policy. Does not have to be unique, and it's changeable.
    e_tag str

    Deprecated: The 'ETag' field has been deprecated and may be removed in a future version. Do not use this field.

    freeform_tags Mapping[str, Any]
    Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. Example: {"Department": "Finance"}
    id str
    The OCID of the policy.
    inactive_state str
    The detailed status of INACTIVE lifecycleState.
    last_update_e_tag str

    Deprecated: The 'lastUpdateETag' field has been deprecated and may be removed in a future version. Do not use this field.

    name str
    A filter to only return resources that match the given name exactly.
    policy_hash str

    Deprecated: The 'policyHash' field has been deprecated and may be removed in a future version. Do not use this field.

    state str
    A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.
    statements Sequence[str]
    An array of one or more policy statements written in the policy language.
    time_created str
    Date and time the policy was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
    version_date str
    The version of the policy. If null or set to an empty string, when a request comes in for authorization, the policy will be evaluated according to the current behavior of the services at that moment. If set to a particular date (YYYY-MM-DD), the policy will be evaluated according to the behavior of the services on that date.
    ETag String

    Deprecated: The 'ETag' field has been deprecated and may be removed in a future version. Do not use this field.

    compartmentId String
    The OCID of the compartment (remember that the tenancy is simply the root compartment).
    definedTags Map<Any>
    Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: {"Operations.CostCenter": "42"}
    description String
    The description you assign to the policy. Does not have to be unique, and it's changeable.
    freeformTags Map<Any>
    Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see Resource Tags. Example: {"Department": "Finance"}
    id String
    The OCID of the policy.
    inactiveState String
    The detailed status of INACTIVE lifecycleState.
    lastUpdateETag String

    Deprecated: The 'lastUpdateETag' field has been deprecated and may be removed in a future version. Do not use this field.

    name String
    A filter to only return resources that match the given name exactly.
    policyHash String

    Deprecated: The 'policyHash' field has been deprecated and may be removed in a future version. Do not use this field.

    state String
    A filter to only return resources that match the given lifecycle state. The state value is case-insensitive.
    statements List<String>
    An array of one or more policy statements written in the policy language.
    timeCreated String
    Date and time the policy was created, in the format defined by RFC3339. Example: 2016-08-25T21:10:29.600Z
    versionDate String
    The version of the policy. If null or set to an empty string, when a request comes in for authorization, the policy will be evaluated according to the current behavior of the services at that moment. If set to a particular date (YYYY-MM-DD), the policy will be evaluated according to the behavior of the services on that date.

    Package Details

    Repository
    oci pulumi/pulumi-oci
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the oci Terraform Provider.
    oci logo
    Oracle Cloud Infrastructure v2.3.0 published on Wednesday, Jul 17, 2024 by Pulumi