Alibaba Cloud v3.63.0 published on Monday, Sep 30, 2024 by Pulumi
alicloud.ram.getUsers
Explore with Pulumi AI
This data source provides a list of RAM users 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 _default = new alicloud.ram.Group("default", {
name: "group1",
comments: "group comments",
force: true,
});
const defaultUser = new alicloud.ram.User("default", {
name: "user-example",
displayName: "displayname",
mobile: "86-18888888888",
email: "hello.uuu@aaa.com",
comments: "yoyoyo",
});
const defaultGroupMembership = new alicloud.ram.GroupMembership("default", {
groupName: _default.name,
userNames: [defaultUser.name],
});
const defaultPolicy = new alicloud.ram.Policy("default", {
policyName: "ram-policy-example",
policyDocument: `\x09\x09\x09{
\x09\x09\x09\x09"Statement": [
\x09\x09\x09\x09 {
\x09\x09\x09\x09\x09"Action": [
\x09\x09\x09\x09\x09"oss:ListObjects",
\x09\x09\x09\x09\x09"oss:ListObjects"
\x09\x09\x09 \x09\x09],
\x09\x09\x09 \x09\x09"Effect": "Deny",
\x09\x09\x09 \x09\x09"Resource": [
\x09\x09\x09\x09\x09\x09"acs:oss:*:*:mybucket",
\x09\x09\x09\x09\x09\x09"acs:oss:*:*:mybucket/*"
\x09\x09\x09 \x09\x09]
\x09\x09\x09\x09 }
\x09\x09 \x09\x09],
\x09\x09\x09\x09"Version": "1"
\x09\x09\x09}
`,
description: "this is a policy example",
force: true,
});
const defaultUserPolicyAttachment = new alicloud.ram.UserPolicyAttachment("default", {
policyName: defaultPolicy.policyName,
userName: defaultUser.name,
policyType: defaultPolicy.type,
});
const usersDs = alicloud.ram.getUsersOutput({
outputFile: "users.txt",
groupName: _default.name,
policyName: defaultPolicy.policyName,
policyType: "Custom",
nameRegex: defaultUser.name,
});
export const firstUserId = usersDs.apply(usersDs => usersDs.users?.[0]?.id);
import pulumi
import pulumi_alicloud as alicloud
default = alicloud.ram.Group("default",
name="group1",
comments="group comments",
force=True)
default_user = alicloud.ram.User("default",
name="user-example",
display_name="displayname",
mobile="86-18888888888",
email="hello.uuu@aaa.com",
comments="yoyoyo")
default_group_membership = alicloud.ram.GroupMembership("default",
group_name=default.name,
user_names=[default_user.name])
default_policy = alicloud.ram.Policy("default",
policy_name="ram-policy-example",
policy_document="""\x09\x09\x09{
\x09\x09\x09\x09"Statement": [
\x09\x09\x09\x09 {
\x09\x09\x09\x09\x09"Action": [
\x09\x09\x09\x09\x09"oss:ListObjects",
\x09\x09\x09\x09\x09"oss:ListObjects"
\x09\x09\x09 \x09\x09],
\x09\x09\x09 \x09\x09"Effect": "Deny",
\x09\x09\x09 \x09\x09"Resource": [
\x09\x09\x09\x09\x09\x09"acs:oss:*:*:mybucket",
\x09\x09\x09\x09\x09\x09"acs:oss:*:*:mybucket/*"
\x09\x09\x09 \x09\x09]
\x09\x09\x09\x09 }
\x09\x09 \x09\x09],
\x09\x09\x09\x09"Version": "1"
\x09\x09\x09}
""",
description="this is a policy example",
force=True)
default_user_policy_attachment = alicloud.ram.UserPolicyAttachment("default",
policy_name=default_policy.policy_name,
user_name=default_user.name,
policy_type=default_policy.type)
users_ds = alicloud.ram.get_users_output(output_file="users.txt",
group_name=default.name,
policy_name=default_policy.policy_name,
policy_type="Custom",
name_regex=default_user.name)
pulumi.export("firstUserId", users_ds.users[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 {
_, err := ram.NewGroup(ctx, "default", &ram.GroupArgs{
Name: pulumi.String("group1"),
Comments: pulumi.String("group comments"),
Force: pulumi.Bool(true),
})
if err != nil {
return err
}
defaultUser, err := ram.NewUser(ctx, "default", &ram.UserArgs{
Name: pulumi.String("user-example"),
DisplayName: pulumi.String("displayname"),
Mobile: pulumi.String("86-18888888888"),
Email: pulumi.String("hello.uuu@aaa.com"),
Comments: pulumi.String("yoyoyo"),
})
if err != nil {
return err
}
_, err = ram.NewGroupMembership(ctx, "default", &ram.GroupMembershipArgs{
GroupName: _default.Name,
UserNames: pulumi.StringArray{
defaultUser.Name,
},
})
if err != nil {
return err
}
defaultPolicy, err := ram.NewPolicy(ctx, "default", &ram.PolicyArgs{
PolicyName: pulumi.String("ram-policy-example"),
PolicyDocument: pulumi.String(` {
"Statement": [
{
"Action": [
"oss:ListObjects",
"oss:ListObjects"
],
"Effect": "Deny",
"Resource": [
"acs:oss:*:*:mybucket",
"acs:oss:*:*:mybucket/*"
]
}
],
"Version": "1"
}
`),
Description: pulumi.String("this is a policy example"),
Force: pulumi.Bool(true),
})
if err != nil {
return err
}
_, err = ram.NewUserPolicyAttachment(ctx, "default", &ram.UserPolicyAttachmentArgs{
PolicyName: defaultPolicy.PolicyName,
UserName: defaultUser.Name,
PolicyType: defaultPolicy.Type,
})
if err != nil {
return err
}
usersDs := ram.GetUsersOutput(ctx, ram.GetUsersOutputArgs{
OutputFile: pulumi.String("users.txt"),
GroupName: _default.Name,
PolicyName: defaultPolicy.PolicyName,
PolicyType: pulumi.String("Custom"),
NameRegex: defaultUser.Name,
}, nil)
ctx.Export("firstUserId", usersDs.ApplyT(func(usersDs ram.GetUsersResult) (*string, error) {
return &usersDs.Users[0].Id, nil
}).(pulumi.StringPtrOutput))
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var @default = new AliCloud.Ram.Group("default", new()
{
Name = "group1",
Comments = "group comments",
Force = true,
});
var defaultUser = new AliCloud.Ram.User("default", new()
{
Name = "user-example",
DisplayName = "displayname",
Mobile = "86-18888888888",
Email = "hello.uuu@aaa.com",
Comments = "yoyoyo",
});
var defaultGroupMembership = new AliCloud.Ram.GroupMembership("default", new()
{
GroupName = @default.Name,
UserNames = new[]
{
defaultUser.Name,
},
});
var defaultPolicy = new AliCloud.Ram.Policy("default", new()
{
PolicyName = "ram-policy-example",
PolicyDocument = @" {
""Statement"": [
{
""Action"": [
""oss:ListObjects"",
""oss:ListObjects""
],
""Effect"": ""Deny"",
""Resource"": [
""acs:oss:*:*:mybucket"",
""acs:oss:*:*:mybucket/*""
]
}
],
""Version"": ""1""
}
",
Description = "this is a policy example",
Force = true,
});
var defaultUserPolicyAttachment = new AliCloud.Ram.UserPolicyAttachment("default", new()
{
PolicyName = defaultPolicy.PolicyName,
UserName = defaultUser.Name,
PolicyType = defaultPolicy.Type,
});
var usersDs = AliCloud.Ram.GetUsers.Invoke(new()
{
OutputFile = "users.txt",
GroupName = @default.Name,
PolicyName = defaultPolicy.PolicyName,
PolicyType = "Custom",
NameRegex = defaultUser.Name,
});
return new Dictionary<string, object?>
{
["firstUserId"] = usersDs.Apply(getUsersResult => getUsersResult.Users[0]?.Id),
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ram.Group;
import com.pulumi.alicloud.ram.GroupArgs;
import com.pulumi.alicloud.ram.User;
import com.pulumi.alicloud.ram.UserArgs;
import com.pulumi.alicloud.ram.GroupMembership;
import com.pulumi.alicloud.ram.GroupMembershipArgs;
import com.pulumi.alicloud.ram.Policy;
import com.pulumi.alicloud.ram.PolicyArgs;
import com.pulumi.alicloud.ram.UserPolicyAttachment;
import com.pulumi.alicloud.ram.UserPolicyAttachmentArgs;
import com.pulumi.alicloud.ram.RamFunctions;
import com.pulumi.alicloud.ram.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) {
var default_ = new Group("default", GroupArgs.builder()
.name("group1")
.comments("group comments")
.force(true)
.build());
var defaultUser = new User("defaultUser", UserArgs.builder()
.name("user-example")
.displayName("displayname")
.mobile("86-18888888888")
.email("hello.uuu@aaa.com")
.comments("yoyoyo")
.build());
var defaultGroupMembership = new GroupMembership("defaultGroupMembership", GroupMembershipArgs.builder()
.groupName(default_.name())
.userNames(defaultUser.name())
.build());
var defaultPolicy = new Policy("defaultPolicy", PolicyArgs.builder()
.policyName("ram-policy-example")
.policyDocument("""
{
"Statement": [
{
"Action": [
"oss:ListObjects",
"oss:ListObjects"
],
"Effect": "Deny",
"Resource": [
"acs:oss:*:*:mybucket",
"acs:oss:*:*:mybucket/*"
]
}
],
"Version": "1"
}
""")
.description("this is a policy example")
.force(true)
.build());
var defaultUserPolicyAttachment = new UserPolicyAttachment("defaultUserPolicyAttachment", UserPolicyAttachmentArgs.builder()
.policyName(defaultPolicy.policyName())
.userName(defaultUser.name())
.policyType(defaultPolicy.type())
.build());
final var usersDs = RamFunctions.getUsers(GetUsersArgs.builder()
.outputFile("users.txt")
.groupName(default_.name())
.policyName(defaultPolicy.policyName())
.policyType("Custom")
.nameRegex(defaultUser.name())
.build());
ctx.export("firstUserId", usersDs.applyValue(getUsersResult -> getUsersResult).applyValue(usersDs -> usersDs.applyValue(getUsersResult -> getUsersResult.users()[0].id())));
}
}
resources:
default:
type: alicloud:ram:Group
properties:
name: group1
comments: group comments
force: true
defaultUser:
type: alicloud:ram:User
name: default
properties:
name: user-example
displayName: displayname
mobile: 86-18888888888
email: hello.uuu@aaa.com
comments: yoyoyo
defaultGroupMembership:
type: alicloud:ram:GroupMembership
name: default
properties:
groupName: ${default.name}
userNames:
- ${defaultUser.name}
defaultPolicy:
type: alicloud:ram:Policy
name: default
properties:
policyName: ram-policy-example
policyDocument: |
{
"Statement": [
{
"Action": [
"oss:ListObjects",
"oss:ListObjects"
],
"Effect": "Deny",
"Resource": [
"acs:oss:*:*:mybucket",
"acs:oss:*:*:mybucket/*"
]
}
],
"Version": "1"
}
description: this is a policy example
force: true
defaultUserPolicyAttachment:
type: alicloud:ram:UserPolicyAttachment
name: default
properties:
policyName: ${defaultPolicy.policyName}
userName: ${defaultUser.name}
policyType: ${defaultPolicy.type}
variables:
usersDs:
fn::invoke:
Function: alicloud:ram:getUsers
Arguments:
outputFile: users.txt
groupName: ${default.name}
policyName: ${defaultPolicy.policyName}
policyType: Custom
nameRegex: ${defaultUser.name}
outputs:
firstUserId: ${usersDs.users[0].id}
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(group_name: Optional[str] = None,
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) -> GetUsersResult
def get_users_output(group_name: Optional[pulumi.Input[str]] = None,
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[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: alicloud:ram/getUsers:getUsers
arguments:
# arguments dictionary
The following arguments are supported:
- Group
Name string - Filter results by a specific group name. Returned users are in the specified group.
- Ids List<string>
- A list of ram user IDs.
- Name
Regex string - A regex string to filter resulting users by their names.
- Output
File string - File name where to save data source results (after running
pulumi preview
). - Policy
Name string - Filter results by a specific policy name. If you set this parameter without setting
policy_type
, the later will be automatically set toSystem
. Returned users are attached to the specified policy. - Policy
Type string - Filter results by a specific policy type. Valid values are
Custom
andSystem
. If you set this parameter, you must setpolicy_name
as well.
- Group
Name string - Filter results by a specific group name. Returned users are in the specified group.
- Ids []string
- A list of ram user IDs.
- Name
Regex string - A regex string to filter resulting users by their names.
- Output
File string - File name where to save data source results (after running
pulumi preview
). - Policy
Name string - Filter results by a specific policy name. If you set this parameter without setting
policy_type
, the later will be automatically set toSystem
. Returned users are attached to the specified policy. - Policy
Type string - Filter results by a specific policy type. Valid values are
Custom
andSystem
. If you set this parameter, you must setpolicy_name
as well.
- group
Name String - Filter results by a specific group name. Returned users are in the specified group.
- ids List<String>
- A list of ram user IDs.
- name
Regex String - A regex string to filter resulting users by their names.
- output
File String - File name where to save data source results (after running
pulumi preview
). - policy
Name String - Filter results by a specific policy name. If you set this parameter without setting
policy_type
, the later will be automatically set toSystem
. Returned users are attached to the specified policy. - policy
Type String - Filter results by a specific policy type. Valid values are
Custom
andSystem
. If you set this parameter, you must setpolicy_name
as well.
- group
Name string - Filter results by a specific group name. Returned users are in the specified group.
- ids string[]
- A list of ram user IDs.
- name
Regex string - A regex string to filter resulting users by their names.
- output
File string - File name where to save data source results (after running
pulumi preview
). - policy
Name string - Filter results by a specific policy name. If you set this parameter without setting
policy_type
, the later will be automatically set toSystem
. Returned users are attached to the specified policy. - policy
Type string - Filter results by a specific policy type. Valid values are
Custom
andSystem
. If you set this parameter, you must setpolicy_name
as well.
- group_
name str - Filter results by a specific group name. Returned users are in the specified group.
- ids Sequence[str]
- A list of ram user IDs.
- name_
regex str - A regex string to filter resulting users by their names.
- 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 toSystem
. Returned users are attached to the specified policy. - policy_
type str - Filter results by a specific policy type. Valid values are
Custom
andSystem
. If you set this parameter, you must setpolicy_name
as well.
- group
Name String - Filter results by a specific group name. Returned users are in the specified group.
- ids List<String>
- A list of ram user IDs.
- name
Regex String - A regex string to filter resulting users by their names.
- output
File String - File name where to save data source results (after running
pulumi preview
). - policy
Name String - Filter results by a specific policy name. If you set this parameter without setting
policy_type
, the later will be automatically set toSystem
. Returned users are attached to the specified policy. - policy
Type String - Filter results by a specific policy type. Valid values are
Custom
andSystem
. If you set this parameter, you must setpolicy_name
as well.
getUsers 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 user IDs.
- Names List<string>
- A list of ram user's name.
- Users
List<Pulumi.
Ali Cloud. Ram. Outputs. Get Users User> - A list of users. Each element contains the following attributes:
- Group
Name string - Name
Regex string - Output
File string - Policy
Name string - Policy
Type string
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids []string
- A list of ram user IDs.
- Names []string
- A list of ram user's name.
- Users
[]Get
Users User - A list of users. Each element contains the following attributes:
- Group
Name string - Name
Regex string - Output
File string - Policy
Name string - Policy
Type string
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- A list of ram user IDs.
- names List<String>
- A list of ram user's name.
- users
List<Get
Users User> - A list of users. Each element contains the following attributes:
- group
Name String - name
Regex String - output
File String - policy
Name String - policy
Type String
- id string
- The provider-assigned unique ID for this managed resource.
- ids string[]
- A list of ram user IDs.
- names string[]
- A list of ram user's name.
- users
Get
Users User[] - A list of users. Each element contains the following attributes:
- group
Name string - name
Regex string - output
File string - policy
Name string - policy
Type string
- id str
- The provider-assigned unique ID for this managed resource.
- ids Sequence[str]
- A list of ram user IDs.
- names Sequence[str]
- A list of ram user's name.
- users
Sequence[Get
Users User] - A list of users. Each element contains the following attributes:
- group_
name str - 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 user IDs.
- names List<String>
- A list of ram user's name.
- users List<Property Map>
- A list of users. Each element contains the following attributes:
- group
Name String - name
Regex String - output
File String - policy
Name String - policy
Type String
Supporting Types
GetUsersUser
- Create
Date string - Creation date of the user.
- Id string
- The original id is user's name, but it is user id in 1.37.0+.
- Last
Login stringDate - (Removed) Last login date of the user. Removed from version 1.79.0.
- Name string
- Name of the user.
- Create
Date string - Creation date of the user.
- Id string
- The original id is user's name, but it is user id in 1.37.0+.
- Last
Login stringDate - (Removed) Last login date of the user. Removed from version 1.79.0.
- Name string
- Name of the user.
- create
Date String - Creation date of the user.
- id String
- The original id is user's name, but it is user id in 1.37.0+.
- last
Login StringDate - (Removed) Last login date of the user. Removed from version 1.79.0.
- name String
- Name of the user.
- create
Date string - Creation date of the user.
- id string
- The original id is user's name, but it is user id in 1.37.0+.
- last
Login stringDate - (Removed) Last login date of the user. Removed from version 1.79.0.
- name string
- Name of the user.
- create_
date str - Creation date of the user.
- id str
- The original id is user's name, but it is user id in 1.37.0+.
- last_
login_ strdate - (Removed) Last login date of the user. Removed from version 1.79.0.
- name str
- Name of the user.
- create
Date String - Creation date of the user.
- id String
- The original id is user's name, but it is user id in 1.37.0+.
- last
Login StringDate - (Removed) Last login date of the user. Removed from version 1.79.0.
- name String
- Name of the user.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.