Cross account bucket access
RES has the ability to mount buckets from other AWS accounts, provided these buckets have the right permissions. In the following scenario, a RES environment in Account A wants to mount an S3 bucket in Account B.
Step 1: Create an IAM Role in the account that RES is deployed in (this will be referred to as Account A):
-
Sign in to the AWS Management Console for the RES account that needs access to the S3 bucket (Account A).
-
Open the IAM Console:
-
Navigate to the IAM dashboard.
-
In the navigation pane, choose Policies.
-
-
Create a Policy:
-
Choose Create policy.
-
Select the JSON tab.
-
Paste the following JSON policy (replace
with the name of the S3 bucket located in Account B):<BUCKET-NAME>
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:GetObject", "s3:PutObject", "s3:ListBucket", "s3:DeleteObject", "s3:AbortMultipartUpload" ], "Resource": [ "arn:aws:s3:::
<BUCKET-NAME>
", "arn:aws:s3:::<BUCKET-NAME>
/*" ] } ] } -
Choose Next.
-
-
Review and create the policy:
-
Provide a name for the policy (for example, "S3AccessPolicy").
-
Add an optional description to explain the purpose of the policy.
-
Review the policy and choose Create policy.
-
-
Open the IAM Console:
-
Navigate to the IAM dashboard.
-
In the navigation pane, choose Roles.
-
-
Create a Role:
-
Choose Create role.
-
Choose Custom trust policy as the type of trusted entity.
-
Paste the following JSON policy (replace
with the actual account ID of Account A,<ACCOUNT_ID>
with the environment name of the RES deployment, and<ENVIRONMENT_NAME>
with the AWS region RES is deployed to):<REGION>
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::
<ACCOUNT_ID>
:role/<ENVIRONMENT_NAME>
-custom-credential-broker-lambda-role-<REGION>
" }, "Action": "sts:AssumeRole" } ] } -
Choose Next.
-
-
Attach Permissions Policies:
-
Search for and select the policy you created earlier.
-
Choose Next.
-
-
Tag, Review, and Create the Role:
-
Enter a role name (for example, "S3AccessRole").
-
Under Step 3, choose Add Tag, then enter the following key and value:
-
Key:
res:Resource
-
Value:
s3-bucket-iam-role
-
-
Review the role and choose Create role.
-
-
Use the IAM Role in RES:
-
Copy the IAM role ARN that you created.
-
Log into the RES console.
-
In the left navigation pane, choose S3 Bucket.
-
Choose Add Bucket and fill out the form with the cross-account S3 bucket ARN.
-
Choose the Advanced settings - optional dropdown.
-
Enter the role ARN in the IAM role ARN field.
-
Choose Add Bucket.
-
Step 2: Modify the bucket policy in Account B
-
Sign in to the AWS Management Console for Account B.
-
Open the S3 Console:
-
Navigate to the S3 dashboard.
-
Select the bucket you want to grant access to.
-
-
Edit the Bucket Policy:
-
Select the Permissions tab and choose Bucket policy.
-
Add the following policy to grant the IAM role from Account A access to the bucket (replace
<AccountA_ID>
with the actual account ID of Account A and<BUCKET-NAME>
with the name of the S3 bucket):{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::AccountA_ID:role/S3AccessRole" }, "Action": [ "s3:GetObject", "s3:PutObject", "s3:ListBucket", "s3:DeleteObject", "s3:AbortMultipartUpload" ], "Resource": [ "arn:aws:s3:::
<BUCKET-NAME>
", "arn:aws:s3:::<BUCKET-NAME>
/*" ] } ] } -
Choose Save.
-