
How Can a Dev Account Access a Private S3 Bucket in a Production Account?
Learn how to securely enable cross-account access so an AWS Dev account can access a private S3 bucket in a Production account. This article covers the IAM roles, bucket policies, trust relationships, and interview concepts needed to implement secure cross-account S3 access.
Introduction
A few months ago, our organization separated workloads into multiple AWS accounts to improve security and management. The production environment was hosted in a dedicated AWS account, while developers worked from a separate development account.
The development team regularly built application images, deployment packages, and CI/CD artifacts that needed to be consumed by production workloads. To centralize and securely store these files, the production account maintained an Amazon S3 bucket named:
You can watch the video here
Github repo
dev-imageA common requirement is:
How can one AWS account securely access an S3 bucket located in another AWS account?A common requirement quickly emerged:
How can the Development Account securely access an S3 bucket hosted inside the Production Account without making the bucket public?
The development team needed access to:
- Application images
- Deployment artifacts
- CI/CD build outputs
- Static assets shared across environments
- Backup files

-
At first, making the bucket public looked like the easiest option.
But exposing internal files publicly is one of the most common AWS security mistakes and can easily lead to serious data exposure incidents.
Press enter or click to view image in full size
At first, the easy option looked tempting:
Make the bucket public.But that would have been a terrible decision.
Public buckets are one of the most common causes of AWS security incidents. Exposing internal artifacts or backups publicly can become a disaster very quickly.
This is called:
Secure Cross-Account S3 AccessThe goal was simple:
- Keep the bucket private
- Allow only the Dev Account to access it
- Avoid public exposure
- Provide secure and controlled permissions
In this guide, we will implement that exact real-world setup step-by-step using:
- Amazon S3 Bucket Policies
- IAM Policies
- AWS CLI
By the end, the Dev Account will be able to securely upload, download, list, and manage objects inside the Production Account’s S3 bucket without using public access or complicated AssumeRole configurations.
In this guide, we will configure secure cross-account access between two AWS accounts using:
- Create an S3 bucket
- Grant full access from another AWS account
- Configure IAM permissions
- Test upload, download, and delete operations
This setup is widely used in:
- Multi-account AWS architectures
- Centralized logging
- Shared storage
- CI/CD pipelines
- Backup systems
- DevOps automation
Press enter or click to view image in full size
The setup looked like this:
| Account | Purpose | Account ID || --------- | ---------------- | -------------- || Prod Account | Bucket Owner | 787047727908 || Dev Account | Accessing Bucket | 824184071604 |Bucket name:
dev-imagesArchitecture
Development B(IAM Permissions) | | VAmazon S3 Bucket (dev-image) ^ | |Bucket Policy | |Production A(Bucket Owner)Step 1 — Login to AWS Prod Account
Open:
Login using Prod Account credentials.
Step 2 — Open Amazon S3
Open:
Step 3 — Create the S3 Bucket
Click:
Create bucketProvide the following details:
| Field | Value || ------------------- | ---------------------------- || Bucket Name | `dev-images` || AWS Region | Choose your preferred region || Object Ownership | ACLs disabled || Block Public Access | Keep enabled |Click:
Create bucketYour bucket is now created successfully.
Step 4 — Open Bucket Permissions
Click the bucket:
dev-imagesGo to:
PermissionsStep 5 — Add Cross-Account Bucket Policy
Scroll down to:
Bucket PolicyClick:
EditPaste the following policy:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowDevAccount", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::824184071604:user/developer-access" }, "Action": "s3:*", "Resource": [ "arn:aws:s3:::dev-image507", "arn:aws:s3:::dev-image507/*" ] } ]}Click:
Save changesBucket-side configuration is now completed.
Understanding the Bucket Policy
Principal
"Principal": { "AWS": "arn:aws:iam::787047727908:developer-access"}This means:
Allow AWS Dev Account - developer-access user to access this bucket.Action
"Action": "s3:*"This grants:
- Upload permissions
- Download permissions
- Delete permissions
- List bucket permissions
- Full S3 operations
Resource
Bucket-Level Access
"arn:aws:s3:::dev-images"Used for:
- ListBucket
- Bucket metadata operations
Object-Level Access
"arn:aws:s3:::dev-images/*"Used for:
- GetObject
- PutObject
- DeleteObject
Both are mandatory for complete access.
Step 6 — Login to AWS Dev Account
Logout from Prod Account .
Login using Dev Account credentials.
If using root user in Dev account, IAM policy is NOT required because root already has full permissions.
Only bucket policy in Prod account is enough.
However, if you are using an IAM user or IAM role in the Dev account, then you must create an IAM policy and attach it to that user or role to allow access to the S3 bucket.
Step 7 — Create IAM User in Dev Account
Login to Dev Account:
824184071604Open:
Go to:
Users → Create userUser name:
developer-accessEnable:
- Access key access
Create user.
Step 8 — Create Access Key
Create Secret key & Access Key
Login to AWS Console → open IAM Console → go to
Users → click your IAM user → open Security credentials tab → scroll to Access keys → click Create access key → select Command Line Interface (CLI) → tick checkbox → click Next → click Create access key → copy Access Key ID and Secret Access Key → run:Open:
Security credentialsScroll to:
Access keysClick:
Create access keySelect:
Command Line Interface (CLICreate access key.
Copy:
- Access Key ID
- Secret Access Key
Step 9 — Attach IAM Policy to User
Open user:
developer-accessGo to:
Permissions → Add permissionsChoose:
Create inline policySelect:
JSONPaste:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "s3:*", "Resource": [ "arn:aws:s3:::dev-image507", "arn:aws:s3:::dev-image507/*" ] } ]}Policy name:
dev-image507-accessCreate policy.
Step 10 — Attach Policy to IAM User
Go to:
IAM → UsersSelect your IAM user.
Click:
Add permissionsChoose:
Attach policies directlySelect:
dev-images-full-accessClick:
Add permissionsIAM configuration is now completed.
Step 1 — Open EC2 Console — dev account
Login to:
Open:
Step 2 — Launch Ubuntu Server
Click:
Launch instanceName:
ubuntu-serverAMI:
Ubuntu Server 24.04/26.04 LTSInstance type:
t2.microStep 9.3 — Create Key Pair
Click:
Create new key pairName:
ubuntu-keyKey type:
RSAFormat:
.pemClick:
Create key pairStep 9.4 — Configure Network
Allow:
- SSH
- HTTP
- HTTPS
Keep:
Allow SSH traffic from My IPStep 9.5 — Launch Instance
Click:
Launch instanceStep 9.6 — Connect to Ubuntu Server
Open terminal where
.pem file exists.Run:
chmod 400 ubuntu-key.pemGet EC2 public IP.
Connect:
ssh -i ubuntu-key.pem ubuntu@<PUBLIC IP>Step 10 — Configure AWS CLI
Run:
Install AWS CLI on ubuntu
sudo apt updatesudo apt install unzip curl -ycurl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"unzip awscliv2.zipsudo ./aws/installaws --versionConfigure credentials
aws configureEnter:
- AWS Access Key
- AWS Secret Key
- AWS Region
- json
Use credentials from Dev Account.
Verify if it is authenticating to correct account
aws sts get-caller-identityThis command is used to verify which AWS identity is currently configured and being used by the AWS CLI.
It helps confirm:
- Current AWS account
- IAM user or IAM role
- Whether the correct credentials are configured
- Which account your commands will run against
Example output:
{ "UserId": "AIDA37ZJS4W2EKP2WQ3EY", "Account": "8241840716010", "Arn": "arn:aws:iam::824184071610:user/developer-access"}From this output:
-
Accountshows the AWS account ID currently authenticated
-
Arnshows the exact IAM identity being used
-
developer-accessis the IAM user configured throughaws configure
This command is commonly used while troubleshooting:
- AccessDenied errors
- Wrong AWS account access
- Incorrect credentials
- Cross-account access issues
- IAM permission problems
It is one of the fastest ways to validate whether AWS CLI is pointing to the correct account and identity before debugging permissions or policies.
Step 11 — Verify Access
List Bucket
aws s3 ls s3://dev-image507Upload File
aws s3 cp test.txt s3://dev-image507/Download File
aws s3 cp s3://dev-image507/test.txt .Delete File
aws s3 rm s3://dev-image507/test.txtWhy AssumeRole is not required?
AssumeRole is NOT needed in our case.Because we are using:
"Principal": { "AWS": "arn:aws:iam::787047727908:root"with direct bucket policy + IAM policy.
That is called:
Direct Cross-Account AccessAWS Dev Account directly accesses the bucket using its own IAM user/role credentials.
AssumeRole is used when:- You want temporary credentials
- Centralized access management
- More secure enterprise access pattern
- Cross-account role switching
- Avoid giving direct bucket permissions to entire account/users
Your current setup flow is:
IAM User/Role in Dev Account | |IAM Policy Allows Access | |S3 Bucket Policy in Account A Trusts Account B | |Access GrantedNo STS.
No AssumeRole.
No role switching.
Just direct access.
Common Mistakes
Missing Object-Level ARN
Wrong:
"arn:aws:s3:::dev-images"This only grants bucket-level access.
You also need:
"arn:aws:s3:::dev-images/*"for object operations.
Missing IAM Policy in Dev Account
Bucket policy alone does not work.
AWS evaluates:
- Bucket Policy
- IAM Policy
Both must allow access.
Confusing Public Access With Cross-Account Access
This configuration:
- Is NOT public
- Only allows Dev Account
- Keeps bucket private from everyone else
Conclusion
Cross-account S3 access is one of the most important concepts in AWS multi-account environments. Many engineers struggle with it because they misunderstand how bucket policies and IAM policies work together.
The reality is simple:
- Bucket policy grants trust
- IAM policy grants permission
- Both are required
By implementing this setup correctly, you create a secure and scalable architecture where AWS accounts can safely share storage resources without exposing data publicly.
This approach is production-grade and commonly used for:
- Shared DevOps artifacts
- Centralized logging systems
- Terraform state management
- Backup repositories
- Application asset sharing
- Enterprise multi-account AWS environments
Once you understand this pattern, many AWS cross-account designs become significantly easier to implement and troubleshoot.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article