Use this data source to get the ARNs and Names of IAM Users.
data "aws_iam_users" "users" {}
Users whose username contains abc
data "aws_iam_users" "users" {
name_regex = ".*abc.*"
}
data "aws_iam_users" "users" {
path_prefix = "/custom-path"
}
This data source supports the following arguments:
name_regex
- (Optional) 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
- (Optional) 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.This data source exports the following attributes in addition to the arguments above:
arns
- Set of ARNs of the matched IAM users.names
- Set of Names of the matched IAM users.