Principals - Amazon Simple Storage Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Principals

The Principal element specifies the user, account, service, or other entity that is allowed or denied access to a resource. The following are examples of specifying Principal. For more information, see Principal in the IAM User Guide.

Grant permissions to an Amazon Web Services account

To grant permissions to an Amazon Web Services account, identify the account using the following format.

"AWS":"account-ARN"

The following are examples.

"Principal":{"AWS":"arn:aws-cn:iam::AccountIDWithoutHyphens:root"}
"Principal":{"AWS":["arn:aws-cn:iam::AccountID1WithoutHyphens:root","arn:aws-cn:iam::AccountID2WithoutHyphens:root"]}

Amazon S3 also supports a canonical user ID, which is an obfuscated form of the Amazon Web Services account ID. You can specify this ID using the following format.

"CanonicalUser":"64-digit-alphanumeric-value"

The following is an example.

"Principal":{"CanonicalUser":"64-digit-alphanumeric-value"}

For information about how to find the canonical user ID for your account, see Finding Your Account Canonical User ID.

Important

When you use a canonical user ID in a policy, Amazon S3 might change the canonical ID to the corresponding Amazon Web Services account ID. This does not impact the policy because both of these IDs identify the same account.

Grant permissions to an IAM user

To grant permission to an IAM user within your account, you must provide an "AWS":"user-ARN" name-value pair.

"Principal":{"AWS":"arn:aws-cn:iam::account-number-without-hyphens:user/username"}

For detailed examples that provide step-by-step instructions, see Example 1: Bucket owner granting its users bucket permissions and Example 3: Bucket owner granting permissions to objects it does not own.

Grant anonymous permissions

To grant permission to everyone, also referred as anonymous access, you set the wildcard ("*") as the Principal value. For example, if you configure your bucket as a website, you want all the objects in the bucket to be publicly accessible.

"Principal":"*"
"Principal":{"Amazon":"*"}

Using "Principal": "*" with an Allow effect in a resource-based policy allows anyone, even if they’re not signed in to Amazon, to access your resource.

Using "Principal" : { "Amazon" : "*" } with an Allow effect in a resource-based policy allows any root user, IAM user, assumed-role session, or federated user in any account in the same partition to access your resource.

For anonymous users, these two methods are equivalent. For more information, see All principals in the IAM User Guide.

You cannot use a wildcard to match part of a principal name or ARN.

Important

Because anyone can create an Amazon Web Services account, the security level of these two methods is equivalent, even though they function differently.

Warning

Use caution when granting anonymous access to your Amazon S3 bucket. When you grant anonymous access, anyone in the world can access your bucket. We highly recommend that you never grant any kind of anonymous write access to your S3 bucket.

Require access through CloudFront URLs

You can require that your users access your Amazon S3 content by using Amazon CloudFront URLs instead of Amazon S3 URLs. To do this, create a CloudFront origin access identity (OAI). Then, change the permissions either on your bucket or on the objects in your bucket. The format for specifying the OAI in a Principal statement is as follows.

"Principal":{"CanonicalUser":"Amazon S3 Canonical User ID assigned to origin access identity"}

For more information, see Using an Origin Access Identity to Restrict Access to Your Amazon S3 Content in the Amazon CloudFront Developer Guide.