Skip to content

Resource: awsIamUserPolicyAttachment

Attaches a Managed IAM Policy to an IAM user

\~> NOTE: The usage of this resource conflicts with the awsIamPolicyAttachment resource and will permanently show a difference if both are defined.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsIamPolicyPolicy = new aws.iamPolicy.IamPolicy(this, "policy", {
  description: "A test policy",
  name: "test-policy",
  policy: "{ ... policy JSON ... }",
});
const awsIamUserUser = new aws.iamUser.IamUser(this, "user", {
  name: "test-user",
});
new aws.iamUserPolicyAttachment.IamUserPolicyAttachment(this, "test-attach", {
  policyArn: awsIamPolicyPolicy.arn,
  user: awsIamUserUser.name,
});

Argument Reference

The following arguments are supported:

  • user (Required) - The user the policy should be applied to
  • policyArn (Required) - The ARN of the policy you want to apply

Attributes Reference

No additional attributes are exported.

Import

IAM user policy attachments can be imported using the user name and policy arn separated by /.

$ terraform import aws_iam_user_policy_attachment.test-attach test-user/arn:aws:iam::xxxxxxxxxxxx:policy/test-policy