Adam
Adam

Reputation: 20942

Amazon IAM User + Granting Access to S3

I have a couple of questions about an IAM User and granting access to S3.

Note: I'm using S3.php to write files with this users.

  1. Can the user have a Password set?

  2. After creating the user (have done) should I use a group or user policy to grant access?

  3. I only want this user to be able to write objects (have bucket policy giving global public read). how can I grant just this right? (user policy) and are other rights need to put files in the bucket?

thx

Upvotes: 2

Views: 1083

Answers (1)

Will Palmer
Will Palmer

Reputation: 5972

Point-by-point:

  1. "Can the user have a Password set?" The user can have a password set, though for API access I do not believe a password can be used directly. Nothing about having a password set prevents API access.
  2. "should I use a group or user policy to grant access?" The distinction between user vs group policies is just a matter of organisation. If several of your users require access "for the same reason", then it makes sense to create a group policy. If every user has a specific set of requirements, for reasons which do not overlap, then individual user-policies make more sense. It's basically a question of future administration: If the policy requirements changed in the future, would you be more likely to need to make the same change across multiple users, or to make various individual changes?
  3. "I only want this user to be able to write objects" The policy generator can help with this, but the key things you need to know are:
    • The type of action you're looking for is "s3:PutObject". Depending on what you actually mean by "write", you may need a couple of other permissions as well: "s3:DeleteObject" and "s3:ListBucket" are common extras.
    • The "arn" would be: ""arn:aws:s3:::bucketNameGoesHere/*", or replace the asterisk with something more-specific to limit "puts" to a given prefix"

Below, I have included a basic policy which might do what you want. I expect it will require some tweaking to be exactly what you need:

{
  "Statement": [
    {
      "Sid": "AnyUniqueIdentifierForThePolicyStatementGoesHere",
      "Action": [
        "s3:PutObject"
      ],
      "Effect": "Allow",
      "Resource": [
        "arn:aws:s3:::YourBucketNameGoesHere/*"
      ]
    }
  ]
}

Hopefully that is at least enough to point you in the right direction.

useful links:

Upvotes: 3

Related Questions