1. Packages
  2. AWS
  3. API Docs
  4. iam
  5. getUsers
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

aws.iam.getUsers

Explore with Pulumi AI

aws logo
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

    Use this data source to get the ARNs and Names of IAM Users.

    Example Usage

    All users in an account

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const users = aws.iam.getUsers({});
    
    import pulumi
    import pulumi_aws as aws
    
    users = aws.iam.get_users()
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := iam.GetUsers(ctx, &iam.GetUsersArgs{}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var users = Aws.Iam.GetUsers.Invoke();
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.iam.IamFunctions;
    import com.pulumi.aws.iam.inputs.GetUsersArgs;
    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 users = IamFunctions.getUsers();
    
        }
    }
    
    variables:
      users:
        fn::invoke:
          Function: aws:iam:getUsers
          Arguments: {}
    

    Users filtered by name regex

    Users whose username contains abc

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const users = aws.iam.getUsers({
        nameRegex: ".*abc.*",
    });
    
    import pulumi
    import pulumi_aws as aws
    
    users = aws.iam.get_users(name_regex=".*abc.*")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := iam.GetUsers(ctx, &iam.GetUsersArgs{
    			NameRegex: pulumi.StringRef(".*abc.*"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var users = Aws.Iam.GetUsers.Invoke(new()
        {
            NameRegex = ".*abc.*",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.iam.IamFunctions;
    import com.pulumi.aws.iam.inputs.GetUsersArgs;
    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 users = IamFunctions.getUsers(GetUsersArgs.builder()
                .nameRegex(".*abc.*")
                .build());
    
        }
    }
    
    variables:
      users:
        fn::invoke:
          Function: aws:iam:getUsers
          Arguments:
            nameRegex: .*abc.*
    

    Users filtered by path prefix

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const users = aws.iam.getUsers({
        pathPrefix: "/custom-path",
    });
    
    import pulumi
    import pulumi_aws as aws
    
    users = aws.iam.get_users(path_prefix="/custom-path")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := iam.GetUsers(ctx, &iam.GetUsersArgs{
    			PathPrefix: pulumi.StringRef("/custom-path"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var users = Aws.Iam.GetUsers.Invoke(new()
        {
            PathPrefix = "/custom-path",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.iam.IamFunctions;
    import com.pulumi.aws.iam.inputs.GetUsersArgs;
    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 users = IamFunctions.getUsers(GetUsersArgs.builder()
                .pathPrefix("/custom-path")
                .build());
    
        }
    }
    
    variables:
      users:
        fn::invoke:
          Function: aws:iam:getUsers
          Arguments:
            pathPrefix: /custom-path
    

    Using getUsers

    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 getUsers(args: GetUsersArgs, opts?: InvokeOptions): Promise<GetUsersResult>
    function getUsersOutput(args: GetUsersOutputArgs, opts?: InvokeOptions): Output<GetUsersResult>
    def get_users(name_regex: Optional[str] = None,
                  path_prefix: Optional[str] = None,
                  opts: Optional[InvokeOptions] = None) -> GetUsersResult
    def get_users_output(name_regex: Optional[pulumi.Input[str]] = None,
                  path_prefix: Optional[pulumi.Input[str]] = None,
                  opts: Optional[InvokeOptions] = None) -> Output[GetUsersResult]
    func GetUsers(ctx *Context, args *GetUsersArgs, opts ...InvokeOption) (*GetUsersResult, error)
    func GetUsersOutput(ctx *Context, args *GetUsersOutputArgs, opts ...InvokeOption) GetUsersResultOutput

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

    public static class GetUsers 
    {
        public static Task<GetUsersResult> InvokeAsync(GetUsersArgs args, InvokeOptions? opts = null)
        public static Output<GetUsersResult> Invoke(GetUsersInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetUsersResult> getUsers(GetUsersArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: aws:iam/getUsers:getUsers
      arguments:
        # arguments dictionary

    The following arguments are supported:

    NameRegex string
    Regex string to apply to the IAM users list returned by AWS. This allows more advanced filtering not supported from the AWS API. This filtering is done locally on what AWS returns, and could have a performance impact if the result is large. Combine this with other options to narrow down the list AWS returns.
    PathPrefix string
    Path prefix for filtering the results. For example, the prefix /division_abc/subdivision_xyz/ gets all users whose path starts with /division_abc/subdivision_xyz/. If it is not included, it defaults to a slash (/), listing all users. For more details, check out [list-users in the AWS CLI reference][1].
    NameRegex string
    Regex string to apply to the IAM users list returned by AWS. This allows more advanced filtering not supported from the AWS API. This filtering is done locally on what AWS returns, and could have a performance impact if the result is large. Combine this with other options to narrow down the list AWS returns.
    PathPrefix string
    Path prefix for filtering the results. For example, the prefix /division_abc/subdivision_xyz/ gets all users whose path starts with /division_abc/subdivision_xyz/. If it is not included, it defaults to a slash (/), listing all users. For more details, check out [list-users in the AWS CLI reference][1].
    nameRegex String
    Regex string to apply to the IAM users list returned by AWS. This allows more advanced filtering not supported from the AWS API. This filtering is done locally on what AWS returns, and could have a performance impact if the result is large. Combine this with other options to narrow down the list AWS returns.
    pathPrefix String
    Path prefix for filtering the results. For example, the prefix /division_abc/subdivision_xyz/ gets all users whose path starts with /division_abc/subdivision_xyz/. If it is not included, it defaults to a slash (/), listing all users. For more details, check out [list-users in the AWS CLI reference][1].
    nameRegex string
    Regex string to apply to the IAM users list returned by AWS. This allows more advanced filtering not supported from the AWS API. This filtering is done locally on what AWS returns, and could have a performance impact if the result is large. Combine this with other options to narrow down the list AWS returns.
    pathPrefix string
    Path prefix for filtering the results. For example, the prefix /division_abc/subdivision_xyz/ gets all users whose path starts with /division_abc/subdivision_xyz/. If it is not included, it defaults to a slash (/), listing all users. For more details, check out [list-users in the AWS CLI reference][1].
    name_regex str
    Regex string to apply to the IAM users list returned by AWS. This allows more advanced filtering not supported from the AWS API. This filtering is done locally on what AWS returns, and could have a performance impact if the result is large. Combine this with other options to narrow down the list AWS returns.
    path_prefix str
    Path prefix for filtering the results. For example, the prefix /division_abc/subdivision_xyz/ gets all users whose path starts with /division_abc/subdivision_xyz/. If it is not included, it defaults to a slash (/), listing all users. For more details, check out [list-users in the AWS CLI reference][1].
    nameRegex String
    Regex string to apply to the IAM users list returned by AWS. This allows more advanced filtering not supported from the AWS API. This filtering is done locally on what AWS returns, and could have a performance impact if the result is large. Combine this with other options to narrow down the list AWS returns.
    pathPrefix String
    Path prefix for filtering the results. For example, the prefix /division_abc/subdivision_xyz/ gets all users whose path starts with /division_abc/subdivision_xyz/. If it is not included, it defaults to a slash (/), listing all users. For more details, check out [list-users in the AWS CLI reference][1].

    getUsers Result

    The following output properties are available:

    Arns List<string>
    Set of ARNs of the matched IAM users.
    Id string
    The provider-assigned unique ID for this managed resource.
    Names List<string>
    Set of Names of the matched IAM users.
    NameRegex string
    PathPrefix string
    Arns []string
    Set of ARNs of the matched IAM users.
    Id string
    The provider-assigned unique ID for this managed resource.
    Names []string
    Set of Names of the matched IAM users.
    NameRegex string
    PathPrefix string
    arns List<String>
    Set of ARNs of the matched IAM users.
    id String
    The provider-assigned unique ID for this managed resource.
    names List<String>
    Set of Names of the matched IAM users.
    nameRegex String
    pathPrefix String
    arns string[]
    Set of ARNs of the matched IAM users.
    id string
    The provider-assigned unique ID for this managed resource.
    names string[]
    Set of Names of the matched IAM users.
    nameRegex string
    pathPrefix string
    arns Sequence[str]
    Set of ARNs of the matched IAM users.
    id str
    The provider-assigned unique ID for this managed resource.
    names Sequence[str]
    Set of Names of the matched IAM users.
    name_regex str
    path_prefix str
    arns List<String>
    Set of ARNs of the matched IAM users.
    id String
    The provider-assigned unique ID for this managed resource.
    names List<String>
    Set of Names of the matched IAM users.
    nameRegex String
    pathPrefix String

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo
    AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi