Skip to content

Data Source: awsIamUsers

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

Example Usage

All users in an account

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.dataAwsIamUsers.DataAwsIamUsers(this, "users", {});

Users filtered by name regex

Users whose username contains abc

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.dataAwsIamUsers.DataAwsIamUsers(this, "users", {
  nameRegex: ".*abc.*",
});

Users filtered by path prefix

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.dataAwsIamUsers.DataAwsIamUsers(this, "users", {
  pathPrefix: "/custom-path",
});

Argument Reference

The following arguments are supported:

  • nameRegex - (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.
  • pathPrefix - (Optional) Path prefix for filtering the results. For example, the prefix /divisionAbc/subdivisionXyz/ gets all users whose path starts with /divisionAbc/subdivisionXyz/. 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.

Attributes Reference

  • arns - Set of ARNs of the matched IAM users.
  • names - Set of Names of the matched IAM users.