How can I structure an IAM policy document for granting specific permissions for an IAM user or even group?

164    Asked by Aalapprabhakaran in AWS , Asked on Jan 30, 2024

 I have been assigned a specific task that is related to access control for my particular AWS Resources by using the technology of IAM. How can you structure an IAM policy document for granting specific permissions such as reading access to an S3 bucket and writing access to a DynamoDB table for an IAM user or group?

Answered by Charles Parr

In the context of AWS, to achieve this particular objective, you would first need to create an IAM policy document with the required permissions. Here is the example given by using AWS Identity and accessing management policy JSON syntax:-

{
  “Version”: “2012-10-17”,
  “Statement”: [
    {
      “Effect”: “Allow”,
      “Action”: [
        “s3:GetObject”,
        “s3:ListBucket”
      ],
      “Resource”: [
        “arn:aws:s3:::your_bucket_name”,
        “arn:aws:s3:::your_bucket_name/*”
      ]
    },
    {
      “Effect”: “Allow”,
      “Action”: [
        “dynamodb:PutItem”,
        “dynamodb:GetItem”,
        “dynamodb:UpdateItem”,
        “dynamodb:Scan”,
        “dynamodb:Query”
      ],
      “Resource”: “arn:aws:dynamodb:your_region:your_account_id:table/your_table_name”
    }
  ]
}

You can replace placeholders such as ‘your bucket name’, ‘your region’, ‘your account id’ and ‘your table name’ with your real AWS resources name.



Your Answer

Interviews

Parent Categories