Preporato

SAA-C03 Study Guide

Design Secure ArchitecturesSecure Access to AWS ResourcesCross-Account Access & Resource Sharing

Key Concepts

  • Cross-account IAM roles

  • Resource-based policies

  • AWS Resource Access Manager (RAM)

  • Trust policies and trust relationships

  • External ID for third-party access

Cross-Account Access & Resource Sharing

Overview

In enterprise AWS environments, resources often need to be shared across multiple accounts. AWS provides two primary mechanisms for cross-account access: IAM roles with trust policies for temporary access, and AWS Resource Access Manager (RAM) for long-term resource sharing.

Understanding when to use each approach is critical for the SAA-C03 exam. IAM roles provide fine-grained, temporary access control, while RAM simplifies sharing of supported AWS resources without duplicating them across accounts.

Key Decision

IAM Roles: Best for temporary access, API calls, and fine-grained permissions AWS RAM: Best for long-term sharing of supported resources (VPCs, Transit Gateways, etc.) without duplication

Exam Tip

Exam questions often present scenarios where you must choose between IAM roles, resource-based policies, and RAM. RAM is the answer when sharing VPC subnets, Transit Gateways, or Route 53 Resolver rules across accounts in an organization.


Architecture Diagram

Cross-Account Access Methods
Figure 1: Comparison of cross-account access methods - IAM Roles vs AWS RAM

Key Concepts

Cross-Account Access with IAM Roles

IAM Role-Based Access

IAM roles enable temporary, on-demand access to resources in another account.

How It Works:

  1. Target account creates role with trust policy
  2. Source account grants permission to assume the role
  3. User/application assumes the role and receives temporary credentials
  4. Credentials expire automatically

Best For:

  • API/CLI access to another account
  • Temporary elevated permissions
  • Programmatic cross-account operations
  • Fine-grained permission control

AWS Resource Access Manager (RAM)

AWS RAM

AWS RAM enables long-term sharing of supported resources without duplicating them.

How It Works:

  1. Owner account creates a resource share
  2. Specifies resources and principals (accounts, OUs, organization)
  3. Within Organizations: Access is automatic
  4. Outside Organizations: Invitation must be accepted
  5. Shared resources appear natively in consumer account consoles

Best For:

  • VPC subnet sharing (centralized VPC model)
  • Transit Gateway sharing
  • Route 53 Resolver rules
  • License Manager configurations
  • Long-term, persistent resource access

Shareable Resources via RAM

Common RAM Shareable Resources

ServiceResource TypeUse Case
Amazon VPCSubnetsCentralized VPC, shared networking
Amazon VPCTransit GatewaysHub-and-spoke network topology
Amazon VPCPrefix ListsShared IP address management
Route 53Resolver RulesCentralized DNS resolution
AWS License ManagerLicense ConfigurationsCentralized license management
AWS GlueData Catalogs, DatabasesShared data lake access
Amazon AuroraDB ClustersCross-account database cloning
AWS OutpostsOutpost ResourcesShared on-premises infrastructure
EC2Capacity ReservationsShared compute capacity

How It Works

Method 1: IAM Role-Based Cross-Account Access

IAM Cross-Account Flow
Figure 2: Step-by-step IAM role-based cross-account access

Step 1: Create Role in Target Account

JSONTrust Policy (Target Account)
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::SOURCE-ACCOUNT-ID:root"
      },
      "Action": "sts:AssumeRole",
      "Condition": {
        "StringEquals": {
          "sts:ExternalId": "unique-external-id"
        }
      }
    }
  ]
}

Step 2: Attach Permissions Policy to Role

JSONPermissions Policy (Target Account Role)
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:GetObject",
        "s3:ListBucket"
      ],
      "Resource": [
        "arn:aws:s3:::shared-bucket",
        "arn:aws:s3:::shared-bucket/*"
      ]
    }
  ]
}

Step 3: Grant AssumeRole Permission in Source Account

JSONIAM Policy (Source Account)
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "sts:AssumeRole",
      "Resource": "arn:aws:iam::TARGET-ACCOUNT-ID:role/CrossAccountRole"
    }
  ]
}

Method 2: Resource-Based Policies

Some AWS services support resource-based policies that directly grant cross-account access:

JSONS3 Bucket Policy for Cross-Account Access
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "CrossAccountAccess",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::OTHER-ACCOUNT-ID:root"
      },
      "Action": [
        "s3:GetObject",
        "s3:ListBucket"
      ],
      "Resource": [
        "arn:aws:s3:::my-bucket",
        "arn:aws:s3:::my-bucket/*"
      ]
    }
  ]
}

Services Supporting Resource-Based Policies

ServiceResourcePolicy Name
Amazon S3BucketsBucket Policy
Amazon SQSQueuesQueue Policy
Amazon SNSTopicsTopic Policy
AWS KMSKeysKey Policy
AWS LambdaFunctionsFunction Policy
Amazon ECRRepositoriesRepository Policy
AWS Secrets ManagerSecretsResource Policy

Method 3: AWS RAM Resource Sharing

Creating a Resource Share

SHCreate RAM Resource Share (CLI)
# Create resource share
aws ram create-resource-share \
  --name "SharedVPCSubnets" \
  --resource-arns arn:aws:ec2:us-east-1:123456789012:subnet/subnet-abc123 \
  --principals arn:aws:organizations::123456789012:ou/o-abc123/ou-def456 \
  --permission-arns arn:aws:ram::aws:permission/AWSRAMDefaultPermissionSubnet

# List resource shares
aws ram get-resource-shares --resource-owner SELF

# View shared resources
aws ram list-resources --resource-owner SELF

RAM Within AWS Organizations

Organization Integration

When sharing within AWS Organizations:

  • No invitations required - Access is automatic
  • Share with entire org or specific OUs - No need to list individual accounts
  • Enable organizational sharing - Must be enabled in RAM settings
  • Trusted access - Enable RAM trusted access in Organizations

Use Cases

Use Case 1: Centralized VPC Architecture

Scenario: Network team manages VPCs, application teams need subnets.

Solution: Use RAM to share VPC subnets with application accounts.

Centralized VPC Benefits
  • Single VPC managed by network team
  • Shared subnets used by multiple accounts
  • Centralized control over network configuration
  • Reduced IP address waste - No duplicate VPCs needed
  • Simplified connectivity - All workloads in same VPC

Use Case 2: Transit Gateway Sharing

Scenario: Multiple accounts need connectivity to on-premises data center.

Solution: Network account owns Transit Gateway, shares via RAM.

Use Case 3: Third-Party Vendor Access

Scenario: External vendor needs access to S3 bucket for data processing.

Solution: IAM role with external ID to prevent confused deputy problem.

Use Case 4: Centralized DNS

Scenario: Central DNS team manages Route 53 Resolver rules.

Solution: Share Resolver rules via RAM to all accounts in organization.


Best Practices

Cross-Account Best Practices
  1. Use External ID for Third-Party Access - Prevents confused deputy attacks
  2. Prefer RAM for Long-Term Sharing - Simpler management, native console access
  3. Use Organizations Integration - Automatic sharing, no invitations needed
  4. Apply Least Privilege - Grant minimum necessary permissions
  5. Audit with CloudTrail - Log all cross-account access
  6. Use Managed Permissions in RAM - Define precise access controls
  7. Require MFA for Sensitive Roles - Add condition to trust policies

Choosing the Right Method

When to Use Each Method

ScenarioRecommended MethodWhy
Temporary API access to another accountIAM Role (AssumeRole)Temporary credentials, fine-grained control
Share VPC subnets with multiple accountsAWS RAMNative sharing, no duplication
Grant S3 access to specific external accountS3 Bucket PolicyDirect resource-based policy
Share Transit Gateway across organizationAWS RAMCentralized network sharing
CI/CD pipeline deploying to production accountIAM Role (AssumeRole)Temporary deployment credentials
Share Route 53 Resolver rulesAWS RAMDNS centralization
Lambda in Account A triggers Lambda in Account BResource Policy + IAM RoleCross-account invocation

Common Exam Scenarios

Exam Scenarios

ScenarioSolutionKey Point
Network team manages VPCs, app teams need accessRAM subnet sharingCentralized VPC model
External vendor needs temporary S3 accessIAM role with External IDPrevents confused deputy
Share Transit Gateway with 50 accountsRAM with organization sharingNo need to list each account
Account A Lambda needs to write to Account B DynamoDBIAM role assumptionTemporary credentials for API calls
Centralize Route 53 DNS across organizationRAM Resolver rule sharingDNS centralization
Share Aurora cluster for cloningRAM Aurora sharingCross-account database cloning
Development account needs read-only prod accessIAM role with read permissionsLeast privilege cross-account

Common Pitfalls

Pitfall 1: Not Using External ID

Mistake: Granting cross-account role access to third parties without External ID.

Why it's dangerous:

  • Confused deputy attack possible
  • Malicious actor could trick service into accessing your resources
  • Common vulnerability in multi-tenant architectures

Correct Approach:

  • Always require External ID in trust policy for third-party access
  • Generate unique, unpredictable External IDs
  • Share External ID securely with trusted party only
Pitfall 2: Using RAM Without Organization Integration

Mistake: Sharing resources via RAM without enabling Organizations integration.

Why it matters:

  • Requires manual invitations for each account
  • Cannot share with OUs directly
  • More operational overhead

Correct Approach:

  • Enable RAM trusted access in AWS Organizations
  • Enable sharing within organization in RAM settings
  • Share with OUs instead of individual accounts
Pitfall 3: Overly Broad Trust Policies

Mistake: Using "Principal": {"AWS": "*"} in trust policies.

Why it's dangerous:

  • Any AWS account could assume the role
  • Defeats purpose of cross-account security
  • Major security vulnerability

Correct Approach:

  • Specify exact principal ARNs
  • Use conditions (External ID, source account)
  • Limit to specific users/roles, not entire accounts
Pitfall 4: Duplicating Resources Instead of Sharing

Mistake: Creating duplicate VPCs, Transit Gateways in each account.

Why it matters:

  • Increased cost and complexity
  • IP address exhaustion
  • Difficult to maintain consistency
  • Network connectivity challenges

Correct Approach:

  • Use centralized network architecture
  • Share resources via RAM where supported
  • Single source of truth for network resources

Test Your Knowledge

Q

Which AWS service is used to share VPC subnets across accounts without duplication?

AIAM Roles
BAWS RAM
CVPC Peering
DAWS Organizations
Q

What is the purpose of External ID in cross-account role trust policies?

ATo identify the AWS region
BTo encrypt credentials
CTo prevent the confused deputy problem
DTo enable MFA
Q

When sharing resources via RAM within AWS Organizations, what happens?

AInvitations must be manually accepted
BAccess is automatically granted
CResources are duplicated to each account
DIAM roles are automatically created
Q

A company wants development teams to deploy resources into shared VPC subnets managed by the network team. What is the BEST approach?

ACreate separate VPCs for each team
BShare VPC subnets via AWS RAM
CUse VPC Peering between accounts
DCreate IAM roles for each subnet


Quick Reference

RAM CLI Commands

SHCommon RAM CLI Commands
# Create resource share
aws ram create-resource-share --name <name> --resource-arns <arns> --principals <principals>

# List your resource shares
aws ram get-resource-shares --resource-owner SELF

# List resource shares shared with you
aws ram get-resource-shares --resource-owner OTHER-ACCOUNTS

# Accept resource share invitation
aws ram accept-resource-share-invitation --resource-share-invitation-arn <arn>

# List shared resources
aws ram list-resources --resource-owner SELF

# Delete resource share
aws ram delete-resource-share --resource-share-arn <arn>

# Enable sharing with Organizations
aws ram enable-sharing-with-aws-organization

Cross-Account Access Comparison

Method Comparison

AspectIAM RolesResource PoliciesAWS RAM
Access TypeTemporaryPermanentPermanent
Credential TypeSTS temporaryCaller credentialsCaller credentials
Setup ComplexityMediumLowLow
Supported ResourcesAll (via API)Select servicesSelect resources
Organization IntegrationManualManualAutomatic
Console AccessSwitch roleDirectNative appearance
Best ForAPI access, temp elevationSimple sharingVPC, TGW, persistent sharing

Further Reading

Related AWS Services

IAMRAMOrganizations