Aws policy attachment

Hi, I cannot differentiate between aws_iam_user_policy_attachment and aws_iam_policy_attachment, and I have tried to use aws_iam_policy_attachment, but I was not able to use it. There was an error in ```
resource “aws_iam_policy_attachment” “test-attach” {
name = “test-attachment”
users = [aws_iam_user.user.name]
roles = [aws_iam_role.role.name]
groups = [aws_iam_group.group.name]
policy_arn = aws_iam_policy.policy.arn
}

aws_iam_user_policy_attachment:

Attaches a Managed IAM Policy to an IAM user
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment

aws_iam_policy_attachment

Attaches a Managed IAM Policy to user(s), role(s), and/or group(s)
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy_attachment

I think the difference is clear, the 1st one can only used with user.

Thanks,
Trung.

1 Like

Thanks a lot, Trung!

1 Like