github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/iam/getUsers.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package iam 5 6 import ( 7 "context" 8 "reflect" 9 10 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 11 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 ) 13 14 // Use this data source to get the ARNs and Names of IAM Users. 15 // 16 // ## Example Usage 17 // 18 // ### All users in an account 19 // 20 // <!--Start PulumiCodeChooser --> 21 // ```go 22 // package main 23 // 24 // import ( 25 // 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 27 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 28 // 29 // ) 30 // 31 // func main() { 32 // pulumi.Run(func(ctx *pulumi.Context) error { 33 // _, err := iam.GetUsers(ctx, nil, nil) 34 // if err != nil { 35 // return err 36 // } 37 // return nil 38 // }) 39 // } 40 // 41 // ``` 42 // <!--End PulumiCodeChooser --> 43 // 44 // ### Users filtered by name regex 45 // 46 // Users whose username contains `abc` 47 // 48 // <!--Start PulumiCodeChooser --> 49 // ```go 50 // package main 51 // 52 // import ( 53 // 54 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 55 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 56 // 57 // ) 58 // 59 // func main() { 60 // pulumi.Run(func(ctx *pulumi.Context) error { 61 // _, err := iam.GetUsers(ctx, &iam.GetUsersArgs{ 62 // NameRegex: pulumi.StringRef(".*abc.*"), 63 // }, nil) 64 // if err != nil { 65 // return err 66 // } 67 // return nil 68 // }) 69 // } 70 // 71 // ``` 72 // <!--End PulumiCodeChooser --> 73 // 74 // ### Users filtered by path prefix 75 // 76 // <!--Start PulumiCodeChooser --> 77 // ```go 78 // package main 79 // 80 // import ( 81 // 82 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 83 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 84 // 85 // ) 86 // 87 // func main() { 88 // pulumi.Run(func(ctx *pulumi.Context) error { 89 // _, err := iam.GetUsers(ctx, &iam.GetUsersArgs{ 90 // PathPrefix: pulumi.StringRef("/custom-path"), 91 // }, nil) 92 // if err != nil { 93 // return err 94 // } 95 // return nil 96 // }) 97 // } 98 // 99 // ``` 100 // <!--End PulumiCodeChooser --> 101 func GetUsers(ctx *pulumi.Context, args *GetUsersArgs, opts ...pulumi.InvokeOption) (*GetUsersResult, error) { 102 opts = internal.PkgInvokeDefaultOpts(opts) 103 var rv GetUsersResult 104 err := ctx.Invoke("aws:iam/getUsers:getUsers", args, &rv, opts...) 105 if err != nil { 106 return nil, err 107 } 108 return &rv, nil 109 } 110 111 // A collection of arguments for invoking getUsers. 112 type GetUsersArgs struct { 113 // 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. 114 NameRegex *string `pulumi:"nameRegex"` 115 // 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]. 116 PathPrefix *string `pulumi:"pathPrefix"` 117 } 118 119 // A collection of values returned by getUsers. 120 type GetUsersResult struct { 121 // Set of ARNs of the matched IAM users. 122 Arns []string `pulumi:"arns"` 123 // The provider-assigned unique ID for this managed resource. 124 Id string `pulumi:"id"` 125 NameRegex *string `pulumi:"nameRegex"` 126 // Set of Names of the matched IAM users. 127 Names []string `pulumi:"names"` 128 PathPrefix *string `pulumi:"pathPrefix"` 129 } 130 131 func GetUsersOutput(ctx *pulumi.Context, args GetUsersOutputArgs, opts ...pulumi.InvokeOption) GetUsersResultOutput { 132 return pulumi.ToOutputWithContext(context.Background(), args). 133 ApplyT(func(v interface{}) (GetUsersResult, error) { 134 args := v.(GetUsersArgs) 135 r, err := GetUsers(ctx, &args, opts...) 136 var s GetUsersResult 137 if r != nil { 138 s = *r 139 } 140 return s, err 141 }).(GetUsersResultOutput) 142 } 143 144 // A collection of arguments for invoking getUsers. 145 type GetUsersOutputArgs struct { 146 // 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. 147 NameRegex pulumi.StringPtrInput `pulumi:"nameRegex"` 148 // 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]. 149 PathPrefix pulumi.StringPtrInput `pulumi:"pathPrefix"` 150 } 151 152 func (GetUsersOutputArgs) ElementType() reflect.Type { 153 return reflect.TypeOf((*GetUsersArgs)(nil)).Elem() 154 } 155 156 // A collection of values returned by getUsers. 157 type GetUsersResultOutput struct{ *pulumi.OutputState } 158 159 func (GetUsersResultOutput) ElementType() reflect.Type { 160 return reflect.TypeOf((*GetUsersResult)(nil)).Elem() 161 } 162 163 func (o GetUsersResultOutput) ToGetUsersResultOutput() GetUsersResultOutput { 164 return o 165 } 166 167 func (o GetUsersResultOutput) ToGetUsersResultOutputWithContext(ctx context.Context) GetUsersResultOutput { 168 return o 169 } 170 171 // Set of ARNs of the matched IAM users. 172 func (o GetUsersResultOutput) Arns() pulumi.StringArrayOutput { 173 return o.ApplyT(func(v GetUsersResult) []string { return v.Arns }).(pulumi.StringArrayOutput) 174 } 175 176 // The provider-assigned unique ID for this managed resource. 177 func (o GetUsersResultOutput) Id() pulumi.StringOutput { 178 return o.ApplyT(func(v GetUsersResult) string { return v.Id }).(pulumi.StringOutput) 179 } 180 181 func (o GetUsersResultOutput) NameRegex() pulumi.StringPtrOutput { 182 return o.ApplyT(func(v GetUsersResult) *string { return v.NameRegex }).(pulumi.StringPtrOutput) 183 } 184 185 // Set of Names of the matched IAM users. 186 func (o GetUsersResultOutput) Names() pulumi.StringArrayOutput { 187 return o.ApplyT(func(v GetUsersResult) []string { return v.Names }).(pulumi.StringArrayOutput) 188 } 189 190 func (o GetUsersResultOutput) PathPrefix() pulumi.StringPtrOutput { 191 return o.ApplyT(func(v GetUsersResult) *string { return v.PathPrefix }).(pulumi.StringPtrOutput) 192 } 193 194 func init() { 195 pulumi.RegisterOutputType(GetUsersResultOutput{}) 196 }