Essential cookies keep authentication working. With your permission, we also use analytics cookies to understand and improve the product. Read our Privacy Policy

DataEngPrep.tech
QuestionsPracticeAI CoachDashboardPricingBlog
ProLogin
Home/Questions/General/Other/How do bucket policies handle the Principal element for cross-account roles?

How do bucket policies handle the Principal element for cross-account roles?

General/Othereasy2 min read

Reviewed by Aditya Kumar · Last reviewed 2026-08-08

When handling cross account roles, the Principal element in an S3 bucket policy specifies the Amazon Resource Name (ARN) of the IAM role in the external AWS account that is being granted access. This…

🤖 Analyze Your Answer
Frequency
Low
Asked at 1 company
Category
243
questions in General/Other
Difficulty Split
151E|43M|49H
in this category
Total Bank
1,863
across 7 categories
Asked at these companies
Capco

Why This Question Matters

This easy-level General/Other question appears frequently in data engineering interviews at companies like Capco. While less common, it tests deeper understanding that distinguishes strong candidates.

How to Approach This

Start by clearly defining the core concept being asked about. Interviewers want to see that you understand the fundamentals before diving into implementation details. Structure your answer with a definition, then explain the practical application with a concise example. The expert answer includes a code example that demonstrates the implementation pattern.

Expert Answer
300 wordsIncludes code

When handling cross-account roles, the Principal element in an S3 bucket policy specifies the Amazon Resource Name (ARN) of the IAM role in the external AWS account that is being granted access. This establishes a trust relationship, allowing the bucket in Account A to permit actions by a specific role in Account B.

Mechanics of Cross-Account Access

The Principal element uses the format "AWS": "arn:aws:iam::ACCOUNT-ID:role/ROLE-NAME". For instance, if a bucket in Account A needs to grant access to a role named CrossAccountRole in Account B (ID 123456789012), the bucket policy's Principal would be "AWS": "arn:aws:iam::123456789012:role/CrossAccountRole". This is a resource-based policy, directly granting permissions on the S3 bucket to an external IAM identity.

Crucially, for this cross-account access to function, the IAM role in Account B must also have a trust policy that permits sts:AssumeRole from the identity that will be using it (e.g., a user or service in Account B). This two-part permission model ensures that both the resource (S3 bucket) and the identity (IAM role) explicitly allow the interaction.

Example and Best Practices

Consider a scenario where Account A's bucket my-data-bucket needs to allow Account B's DataProcessorRole to read objects from a specific prefix.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::123456789012:role/DataProcessorRole"
      },
      "Action": [
        "s3:GetObject",
        "s3:ListBucket"
      ],
      "Resource": [
        "arn:aws:s3:::my-data-bucket/processed-data/*",
        "arn:aws:s3:::my-data-bucket"
      ],
      "Condition": {
        "IpAddress": {
          "aws:SourceIp": "203.0.113.0/24"
        }
      }
    }
  ]
}

This example demonstrates applying the principle of least privilege by specifying only s3:GetObject and s3:ListBucket actions, limiting the Resource to a specific prefix, and adding a Condition for a source IP address. Additional conditions like aws:MultiFactorAuthPresent can further enhance security.

In the interview, also mention the importance of the sts:AssumeRole permission on the cross-account role's trust policy, as it's a common point of misconfiguration for cross-account access.

⚡
Pro Tip

Pro-Move: 'We use bucket policies for cross-account analytics share; Principal is the consumer account's role. Documented in runbook.'

Want all answers as a PDF for offline study?
Seven focused volumes with 750+ in-depth answers — Answer Vault →

Related General/Other Questions

hardHave you worked on Data Warehousing projects?FreemediumHow would you read data from a web API? What steps would you follow after reading the data?FreehardRetrieve the most recent sale_timestamp for each product (Latest Transaction).FreehardWhat is the difference between OLTP and OLAP?FreemediumWhat is the difference between SQL and NoSQL databases?Free

Level up your prep

Recommended
Educative
Educative Unlimited

800+ hands-on courses — Grokking System Design, Coding Patterns, and AI mock interviews for your DE loop.

Start learning →

Some links below are affiliate links. If you buy through them we may earn a small commission at no extra cost to you — it helps keep DataEngPrep free.

According to DataEngPrep.tech, this is one of the most frequently asked General/Other interview questions, reported at 1 company. DataEngPrep.tech maintains an editor-reviewed database of 1,863 data engineering interview questions across 7 categories.

← Back to all questionsMore General/Other questions →
Categories
All QuestionsSQLSpark / Big DataPython / CodingSystem DesignCloud / ToolsBehavioral
By Company
AmazonGoogleDatabricksSnowflakeAWSAzureMicrosoftNetflixUberTCS
Interview Guides
All GuidesTop SQL QuestionsTop Spark QuestionsPySpark QuestionsTop Python QuestionsTop System DesignKafka QuestionsAirflow QuestionsSQL Window FunctionsETL QuestionsData Modeling
Products
AI Interview CoachAnswer AnalyzerSQL PlaygroundResume AnalyzerAnswer Vault PDFsPricing
Company
About & Editorial PolicyContact UsAI DisclosureDisclaimerTerms of ServicePrivacy Policy
© 2026 DataEngPrep.tech. All rights reserved.
AboutBlogContactDisclaimer