1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. ram
  5. getRoles
Alibaba Cloud v3.51.0 published on Saturday, Mar 23, 2024 by Pulumi

alicloud.ram.getRoles

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.51.0 published on Saturday, Mar 23, 2024 by Pulumi

    This data source provides a list of RAM Roles in an Alibaba Cloud account according to the specified filters.

    NOTE: Available since v1.0.0+.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const rolesDs = alicloud.ram.getRoles({
        nameRegex: ".*test.*",
        outputFile: "roles.txt",
        policyName: "AliyunACSDefaultAccess",
        policyType: "Custom",
    });
    export const firstRoleId = rolesDs.then(rolesDs => rolesDs.roles?.[0]?.id);
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    roles_ds = alicloud.ram.get_roles(name_regex=".*test.*",
        output_file="roles.txt",
        policy_name="AliyunACSDefaultAccess",
        policy_type="Custom")
    pulumi.export("firstRoleId", roles_ds.roles[0].id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ram"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		rolesDs, err := ram.GetRoles(ctx, &ram.GetRolesArgs{
    			NameRegex:  pulumi.StringRef(".*test.*"),
    			OutputFile: pulumi.StringRef("roles.txt"),
    			PolicyName: pulumi.StringRef("AliyunACSDefaultAccess"),
    			PolicyType: pulumi.StringRef("Custom"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("firstRoleId", rolesDs.Roles[0].Id)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var rolesDs = AliCloud.Ram.GetRoles.Invoke(new()
        {
            NameRegex = ".*test.*",
            OutputFile = "roles.txt",
            PolicyName = "AliyunACSDefaultAccess",
            PolicyType = "Custom",
        });
    
        return new Dictionary<string, object?>
        {
            ["firstRoleId"] = rolesDs.Apply(getRolesResult => getRolesResult.Roles[0]?.Id),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.ram.RamFunctions;
    import com.pulumi.alicloud.ram.inputs.GetRolesArgs;
    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 rolesDs = RamFunctions.getRoles(GetRolesArgs.builder()
                .nameRegex(".*test.*")
                .outputFile("roles.txt")
                .policyName("AliyunACSDefaultAccess")
                .policyType("Custom")
                .build());
    
            ctx.export("firstRoleId", rolesDs.applyValue(getRolesResult -> getRolesResult.roles()[0].id()));
        }
    }
    
    variables:
      rolesDs:
        fn::invoke:
          Function: alicloud:ram:getRoles
          Arguments:
            nameRegex: .*test.*
            outputFile: roles.txt
            policyName: AliyunACSDefaultAccess
            policyType: Custom
    outputs:
      firstRoleId: ${rolesDs.roles[0].id}
    

    Using getRoles

    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 getRoles(args: GetRolesArgs, opts?: InvokeOptions): Promise<GetRolesResult>
    function getRolesOutput(args: GetRolesOutputArgs, opts?: InvokeOptions): Output<GetRolesResult>
    def get_roles(ids: Optional[Sequence[str]] = None,
                  name_regex: Optional[str] = None,
                  output_file: Optional[str] = None,
                  policy_name: Optional[str] = None,
                  policy_type: Optional[str] = None,
                  opts: Optional[InvokeOptions] = None) -> GetRolesResult
    def get_roles_output(ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                  name_regex: Optional[pulumi.Input[str]] = None,
                  output_file: Optional[pulumi.Input[str]] = None,
                  policy_name: Optional[pulumi.Input[str]] = None,
                  policy_type: Optional[pulumi.Input[str]] = None,
                  opts: Optional[InvokeOptions] = None) -> Output[GetRolesResult]
    func GetRoles(ctx *Context, args *GetRolesArgs, opts ...InvokeOption) (*GetRolesResult, error)
    func GetRolesOutput(ctx *Context, args *GetRolesOutputArgs, opts ...InvokeOption) GetRolesResultOutput

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

    public static class GetRoles 
    {
        public static Task<GetRolesResult> InvokeAsync(GetRolesArgs args, InvokeOptions? opts = null)
        public static Output<GetRolesResult> Invoke(GetRolesInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetRolesResult> getRoles(GetRolesArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: alicloud:ram/getRoles:getRoles
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Ids List<string>
    A list of ram role IDs.
    NameRegex string
    A regex string to filter results by the role name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    PolicyName string
    Filter results by a specific policy name. If you set this parameter without setting policy_type, the later will be automatically set to System. The resulting roles will be attached to the specified policy.
    PolicyType string
    Filter results by a specific policy type. Valid values are Custom and System. If you set this parameter, you must set policy_name as well.
    Ids []string
    A list of ram role IDs.
    NameRegex string
    A regex string to filter results by the role name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    PolicyName string
    Filter results by a specific policy name. If you set this parameter without setting policy_type, the later will be automatically set to System. The resulting roles will be attached to the specified policy.
    PolicyType string
    Filter results by a specific policy type. Valid values are Custom and System. If you set this parameter, you must set policy_name as well.
    ids List<String>
    A list of ram role IDs.
    nameRegex String
    A regex string to filter results by the role name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    policyName String
    Filter results by a specific policy name. If you set this parameter without setting policy_type, the later will be automatically set to System. The resulting roles will be attached to the specified policy.
    policyType String
    Filter results by a specific policy type. Valid values are Custom and System. If you set this parameter, you must set policy_name as well.
    ids string[]
    A list of ram role IDs.
    nameRegex string
    A regex string to filter results by the role name.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    policyName string
    Filter results by a specific policy name. If you set this parameter without setting policy_type, the later will be automatically set to System. The resulting roles will be attached to the specified policy.
    policyType string
    Filter results by a specific policy type. Valid values are Custom and System. If you set this parameter, you must set policy_name as well.
    ids Sequence[str]
    A list of ram role IDs.
    name_regex str
    A regex string to filter results by the role name.
    output_file str
    File name where to save data source results (after running pulumi preview).
    policy_name str
    Filter results by a specific policy name. If you set this parameter without setting policy_type, the later will be automatically set to System. The resulting roles will be attached to the specified policy.
    policy_type str
    Filter results by a specific policy type. Valid values are Custom and System. If you set this parameter, you must set policy_name as well.
    ids List<String>
    A list of ram role IDs.
    nameRegex String
    A regex string to filter results by the role name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    policyName String
    Filter results by a specific policy name. If you set this parameter without setting policy_type, the later will be automatically set to System. The resulting roles will be attached to the specified policy.
    policyType String
    Filter results by a specific policy type. Valid values are Custom and System. If you set this parameter, you must set policy_name as well.

    getRoles Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Ids List<string>
    A list of ram role IDs.
    Names List<string>
    A list of ram role names.
    Roles List<Pulumi.AliCloud.Ram.Outputs.GetRolesRole>
    A list of roles. Each element contains the following attributes:
    NameRegex string
    OutputFile string
    PolicyName string
    PolicyType string
    Id string
    The provider-assigned unique ID for this managed resource.
    Ids []string
    A list of ram role IDs.
    Names []string
    A list of ram role names.
    Roles []GetRolesRole
    A list of roles. Each element contains the following attributes:
    NameRegex string
    OutputFile string
    PolicyName string
    PolicyType string
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    A list of ram role IDs.
    names List<String>
    A list of ram role names.
    roles List<GetRolesRole>
    A list of roles. Each element contains the following attributes:
    nameRegex String
    outputFile String
    policyName String
    policyType String
    id string
    The provider-assigned unique ID for this managed resource.
    ids string[]
    A list of ram role IDs.
    names string[]
    A list of ram role names.
    roles GetRolesRole[]
    A list of roles. Each element contains the following attributes:
    nameRegex string
    outputFile string
    policyName string
    policyType string
    id str
    The provider-assigned unique ID for this managed resource.
    ids Sequence[str]
    A list of ram role IDs.
    names Sequence[str]
    A list of ram role names.
    roles Sequence[GetRolesRole]
    A list of roles. Each element contains the following attributes:
    name_regex str
    output_file str
    policy_name str
    policy_type str
    id String
    The provider-assigned unique ID for this managed resource.
    ids List<String>
    A list of ram role IDs.
    names List<String>
    A list of ram role names.
    roles List<Property Map>
    A list of roles. Each element contains the following attributes:
    nameRegex String
    outputFile String
    policyName String
    policyType String

    Supporting Types

    GetRolesRole

    Arn string
    Resource descriptor of the role.
    AssumeRolePolicyDocument string
    Authorization strategy of the role. This parameter is deprecated and replaced by document.
    CreateDate string
    Creation date of the role.
    Description string
    Description of the role.
    Document string
    Authorization strategy of the role.
    Id string
    ID of the role.
    Name string
    Name of the role.
    UpdateDate string
    Update date of the role.
    Arn string
    Resource descriptor of the role.
    AssumeRolePolicyDocument string
    Authorization strategy of the role. This parameter is deprecated and replaced by document.
    CreateDate string
    Creation date of the role.
    Description string
    Description of the role.
    Document string
    Authorization strategy of the role.
    Id string
    ID of the role.
    Name string
    Name of the role.
    UpdateDate string
    Update date of the role.
    arn String
    Resource descriptor of the role.
    assumeRolePolicyDocument String
    Authorization strategy of the role. This parameter is deprecated and replaced by document.
    createDate String
    Creation date of the role.
    description String
    Description of the role.
    document String
    Authorization strategy of the role.
    id String
    ID of the role.
    name String
    Name of the role.
    updateDate String
    Update date of the role.
    arn string
    Resource descriptor of the role.
    assumeRolePolicyDocument string
    Authorization strategy of the role. This parameter is deprecated and replaced by document.
    createDate string
    Creation date of the role.
    description string
    Description of the role.
    document string
    Authorization strategy of the role.
    id string
    ID of the role.
    name string
    Name of the role.
    updateDate string
    Update date of the role.
    arn str
    Resource descriptor of the role.
    assume_role_policy_document str
    Authorization strategy of the role. This parameter is deprecated and replaced by document.
    create_date str
    Creation date of the role.
    description str
    Description of the role.
    document str
    Authorization strategy of the role.
    id str
    ID of the role.
    name str
    Name of the role.
    update_date str
    Update date of the role.
    arn String
    Resource descriptor of the role.
    assumeRolePolicyDocument String
    Authorization strategy of the role. This parameter is deprecated and replaced by document.
    createDate String
    Creation date of the role.
    description String
    Description of the role.
    document String
    Authorization strategy of the role.
    id String
    ID of the role.
    name String
    Name of the role.
    updateDate String
    Update date of the role.

    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
    Alibaba Cloud v3.51.0 published on Saturday, Mar 23, 2024 by Pulumi