Specifying Resources in a Policy
The following is the common Amazon Resource Name (ARN) format to identify any resources in AWS.
arn:partition:service:region:namespace:relative-id
For your Amazon S3 resources,
awsis a common partition name. If your resources are in China (Beijing) region,aws-cnis the partition name.s3is the service.you don't specify region and namespace.
For Amazon S3, it can be a
bucket-nameor abucket-name/object-key. You can use wild card.
Then the ARN format for Amazon S3 resources reduces to:
arn:aws:s3:::bucket_name
arn:aws:s3:::bucket_name/key_nameThe following are examples of Amazon S3 resource ARNs.
This ARN identifies the
/developers/design_info.docobject in theexamplebucketbucket.arn:aws:s3:::examplebucket/developers/design_info.docYou can use wildcards as part of the resource ARN. You can use wildcard characters (* and ?) within any ARN segment (the parts separated by colons). An asterisk (*) represents any combination of zero or more characters and a question mark (?) represents any single character. You can have use multiple * or ? characters in each segment, but a wildcard cannot span segments.
This ARN uses wildcard '*' in relative-ID part of the ARN to identify all objects in the
examplebucketbucket.arn:aws:s3:::examplebucket/*This ARN uses '*' to indicate all Amazon S3 resources (all bucket and objects in your account).
arn:aws:s3:::*This ARN uses both wildcards, '*', and '?', in the relative-ID part. It identifies all objects in buckets such as
example1bucket,example2bucket,example3bucketand so on.arn:aws:s3:::example?bucket/*
You can use policy variables in Amazon S3 ARNs. At policy evaluation time, these predefined variables are replaced by their corresponding values. Suppose you organize your bucket as a collection of folders, one folder for each of your users. The folder name is the same as the user name. To grant users permission to their folders, you can specify a policy variable in the resource ARN:
arn:aws:s3:::bucket_name/developers/${aws:username}/At run time, when the policy is evaluated, the variable
${aws:username}in the resource ARN is substituted with the user name making the request.
For more information, see the following resources:
Resource in the IAM User Guide
IAM Policy Variables Overview in the IAM User Guide.
ARNs in the AWS General Reference
For more information about other access policy language elements, see Access Policy Language Overview.

