awscc_iam_user_policy (Resource)

Adds or updates an inline policy document that is embedded in the specified IAM user. An IAM user can also have a managed policy attached to it. To attach a managed policy to a user, use AWS::IAM::User. To create a new managed policy, use AWS::IAM::ManagedPolicy. For information about policies, see Managed policies and inline policies in the IAM User Guide. For information about the maximum number of inline policies that you can embed in a user, see IAM and quotas in the IAM User Guide.

Example Usage

IAM user embedded inline policy document

The following example creates inline policy and attaches it to an IAM user

resource "awscc_iam_user_policy" "example" {
  policy_name = "sample_iam_user_policy"
  user_name   = awscc_iam_user.example.id

  policy_document = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Action = [
          "s3:ListAllMyBuckets",
          "s3:GetBucketLocation",
        ]
        Effect   = "Allow"
        Resource = "arn:aws:s3:::*"
      },
    ]
  })
}

resource "awscc_iam_user" "example" {
  user_name = "sample_iam_user"
}

Schema

Required

Optional

Read-Only

Import

Import is supported using the following syntax:

$ terraform import awscc_iam_user_policy.example <resource ID>