<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article How to use Databricks Autoloader across AWS accounts in Technical Blog</title>
    <link>https://community.databricks.com/t5/technical-blog/how-to-use-databricks-autoloader-across-aws-accounts/ba-p/68621</link>
    <description>&lt;P&gt;&lt;LI-TOC indent="15" liststyle="disc" maxheadinglevel="2"&gt;&lt;/LI-TOC&gt;&lt;/P&gt;
&lt;H2&gt;Introduction&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;This is a step-by-step guide to set up an AWS cross-account &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/en/ingestion/auto-loader/index.html" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Databricks Autoloader&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; connection in the &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/en/ingestion/auto-loader/file-notification-mode.html" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;File Notification mode&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;. This will allow you to automatically load data from an S3 bucket in one AWS account (Account A) into a Databricks workspace in another AWS account (Account B).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MohanaBasak_1-1715182407285.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/7501i9B9188A78D3B92ED/image-size/large?v=v2&amp;amp;px=999" role="button" title="MohanaBasak_1-1715182407285.png" alt="MohanaBasak_1-1715182407285.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Databricks Autoloader can either automatically set up SNS and SQS, or we can manually create the resources and then use them in the Autoloader. In either case, we will need an instance profile in Account B to access the SNS and SQS in Account A.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;&lt;SPAN&gt;Understanding Key Services:&lt;/SPAN&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;Before proceeding, let's clarify the purpose of the relevant services in AWS.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SNS (Simple Notification Service)&lt;BR /&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;A href="https://aws.amazon.com/sns/" target="_self"&gt;SNS&lt;/A&gt; is a fully managed pub/sub messaging service that enables seamless message delivery from publishers to subscribers. Autoloader file notification uses an SNS to get notifications whenever a file lands in S3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SQS (Simple Queue Service)&lt;BR /&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;A href="https://aws.amazon.com/sqs/" target="_blank"&gt;SQS&lt;/A&gt; is a fully managed message queuing service that offers scalable, reliable, and distributed message queues. Autoloader uses an SQS to durably store messages from SNS. When the autoloader stream is started, it processes messages from the SQS to identify the new files.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Role-Based Access to Buckets&lt;BR /&gt;&lt;/STRONG&gt;&lt;SPAN&gt;To access &lt;A href="https://aws.amazon.com/s3/" target="_blank"&gt;S3 buckets&lt;/A&gt; in another AWS account, you need to define &lt;A href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html" target="_self"&gt;IAM roles&lt;/A&gt; with policies that grant the necessary permissions. These roles establish trust relationships and ensure secure access to resources across accounts.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Trust Relationship&lt;BR /&gt;&lt;/STRONG&gt;&lt;SPAN&gt;A &lt;A href="https://aws.amazon.com/blogs/security/how-to-use-trust-policies-with-iam-roles/" target="_blank"&gt;trust relationship&lt;/A&gt; in AWS IAM defines which entities are trusted to assume a particular IAM role. When setting up cross-account access, trust relationships determine which accounts or entities can assume roles in other accounts.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Bucket Policy&lt;BR /&gt;&lt;/STRONG&gt;&lt;SPAN&gt;A &lt;A href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html" target="_blank"&gt;bucket policy&lt;/A&gt; in AWS S3 sets permissions for objects within a bucket, controlling access at the bucket and object level. It's written in JSON format and specifies who can access the bucket and what actions they can perform.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2&gt;&lt;SPAN&gt;Create S3 bucket and cross-account instance profile&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;Now that we understand the relevant AWS services, we can get started setting up a cross-account Autoloader connection.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Create an S3 bucket in Account A. An example name could be &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;acc-a-autol-input&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Create an instance profile in Account B (refer steps 1 to 4 under &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/en/connect/storage/tutorial-s3-instance-profile.html#step-1-create-an-instance-profile-using-the-aws-console" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Step 1: Create an instance profile using the AWS console&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Add the policy provided below to the Account B instance profile role to access the bucket in Account A. This policy gives the instance profile created in Step 2 access to the S3 bucket created in Step 1.&lt;/SPAN&gt;&lt;LI-CODE lang="php"&gt;{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::acc-a-autol-input"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:DeleteObject",
                "s3:PutObjectAcl"
            ],
            "Resource": [
                "arn:aws:s3:::acc-a-autol-input/*"
            ]
        }
    ]
}&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Add a pass role for this instance profile role. This must be added to the role that created the Databricks deployment (refer steps 1 to 8 under &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/en/connect/storage/tutorial-s3-instance-profile.html#step-5-add-the-s3-iam-role-to-the-ec2-policy" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Step 5: Add the S3 IAM role to the EC2 policy&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&amp;nbsp;&lt;SPAN&gt;Go to Account A and add a bucket policy to the bucket in Account A. This S3 bucket policy will grant the instance profile created in Step 2 access to the S3 bucket created in Step 1 in a different account.&lt;/SPAN&gt;&lt;LI-CODE lang="php"&gt;{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Example permissions",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::&amp;lt;account_b_id&amp;gt;:role/acc_b_instance_profile"
            },
            "Action": [
                "s3:GetBucketLocation",
                "s3:ListBucket"
            ],
            "Resource": "arn:aws:s3:::acc-a-autol-input"
        },
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::&amp;lt;account_b_id&amp;gt;:role/acc_b_instance_profile"
            },
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:DeleteObject",
                "s3:PutObjectAcl"
            ],
            "Resource": "arn:aws:s3:::acc-a-autol-input/*"
        }
    ]
}&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Execute steps 1 to 5 under &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/en/connect/storage/tutorial-s3-instance-profile.html#step-6-add-the-instance-profile-to-databricks" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Step 6: Add the instance profile to Databricks&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; in the Databricks Workspace console.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;H2&gt;&lt;SPAN&gt;Use Autoloader to create SNS-SQS across accounts&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;For Autoloader to automatically create SNS-SQS, you will need an IAM role with access to create SNS and SQS:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Create an IAM role in Account A. This will have permissions to auto-create SNS-SQS for Autoloader.&lt;/SPAN&gt;
&lt;OL class="lia-list-style-type-lower-alpha"&gt;
&lt;LI&gt;&lt;SPAN&gt;Role name example: &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;acc_a_autol_auto_create_role&lt;/SPAN&gt;&lt;/I&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Policy name example: &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;acc_a_autol_auto_create_policy &lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN&gt;– This policy lets Databricks autoloader create an SNS and an SQS with prefix &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;databricks-auto-ingest-*&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN&gt; during the stream initialization of the autoloader job.&lt;/SPAN&gt;&lt;LI-CODE lang="php"&gt;{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "DatabricksAutoLoaderSetup",
            "Effect": "Allow",
            "Action": [
                "s3:GetBucketNotification",
                "s3:PutBucketNotification",
                "sns:ListSubscriptionsByTopic",
                "sns:GetTopicAttributes",
                "sns:SetTopicAttributes",
                "sns:CreateTopic",
                "sns:TagResource",
                "sns:Publish",
                "sns:Subscribe",
                "sqs:CreateQueue",
                "sqs:DeleteMessage",
                "sqs:ReceiveMessage",
                "sqs:SendMessage",
                "sqs:GetQueueUrl",
                "sqs:GetQueueAttributes",
                "sqs:SetQueueAttributes",
                "sqs:TagQueue",
                "sqs:ChangeMessageVisibility"
            ],
            "Resource": [
                "arn:aws:s3:::acc-a-autol-input",
                "arn:aws:sqs:&amp;lt;aws_region&amp;gt;:&amp;lt;account_a_id&amp;gt;:databricks-auto-ingest-*",
                "arn:aws:sns:&amp;lt;aws_region&amp;gt;:&amp;lt;account_a_id&amp;gt;:databricks-auto-ingest-*"
            ]
        },
        {
            "Sid": "DatabricksAutoLoaderList",
            "Effect": "Allow",
            "Action": [
                "sqs:ListQueues",
                "sqs:ListQueueTags",
                "sns:ListTopics"
            ],
            "Resource": "*"
        },
        {
            "Sid": "DatabricksAutoLoaderTeardown",
            "Effect": "Allow",
            "Action": [
                "sns:Unsubscribe",
                "sns:DeleteTopic",
                "sqs:DeleteQueue"
            ],
            "Resource": [
                "arn:aws:sqs:&amp;lt;aws_region&amp;gt;:&amp;lt;account_a_id&amp;gt;:databricks-auto-ingest-*",
                "arn:aws:sns:&amp;lt;aws_region&amp;gt;:&amp;lt;account_a_id&amp;gt;:databricks-auto-ingest-*"
            ]
        }
    ]
}&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Trust Relationship – lets the instance profile assume this role.&lt;/SPAN&gt;&lt;LI-CODE lang="php"&gt;{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::&amp;lt;account_b_id&amp;gt;:role/acc_b_instance_profile"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;It needs to be added to the instance profile In Account B. Add this to the existing policy in instance profile IAM role &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;acc_b_instance_profile&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;LI-CODE lang="php"&gt;        {
            "Sid": "AssumeRoleAccA",
            "Effect": "Allow",
            "Action": "sts:AssumeRole",
            "Resource": "arn:aws:iam::&amp;lt;account_a_id&amp;gt;:role/acc_a_autol_auto_create_role"
        }&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Run and test the Autoloader code from a Notebook in your Databricks Workspace:&lt;/SPAN&gt;&lt;LI-CODE lang="python"&gt;options = {
   "cloudFiles.format": "parquet",
   "cloudFiles.schemaLocation": "s3://acc-a-autol-input/schema/auto/",
   "cloudFiles.useNotifications": True,
   "cloudFiles.roleArn": "arn:aws:iam::&amp;lt;account_a_id&amp;gt;:role/acc_a_autol_auto_create_role",
}

df = (
   spark.readStream.format("cloudFiles")
   .options(**options)
   .load("s3://acc-a-autol-input/data/auto/")
)

(
   df.writeStream.option("checkpointLocation", "s3://acc-a-autol-input/checkpoint/auto1/1/")
   .start("s3://acc-a-autol-input/output/auto/")
)&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;SPAN&gt;This Autoloader code will auto-create an SNS and an SQS with names similar to:&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;EM&gt;databricks-auto-ingest-query-fb599288-a1ea-4443-8d31-ed66d86fd9aa-source-0&lt;/EM&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;EM&gt;databricks-auto-ingest-query-fb599288-a1ea-4443-8d31-ed66d86fd9aa-source-0&lt;/EM&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;These will get created once during the Stream Initialization of the Autoloader.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2&gt;&lt;SPAN&gt;Manually create SNS-SQS for cross-account Autoloader&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;If you want to manually create SNS-SQS and link this to the Autoloader, follow these steps:&lt;/SPAN&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Create an SNS in Account A called &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;acc_a_autol_sns.&lt;/SPAN&gt;&lt;/I&gt;
&lt;OL class="lia-list-style-type-lower-alpha"&gt;
&lt;LI style="font-weight: 400;" aria-level="2"&gt;&lt;SPAN&gt;Type: Standard&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="2"&gt;&lt;SPAN&gt;Access policy of the SNS to read events from S3 bucket in Acc A:&lt;/SPAN&gt;&lt;I&gt;&lt;/I&gt;&lt;LI-CODE lang="php"&gt;{
  "Version": "2008-10-17",
  "Id": "notificationPolicy",
  "Statement": [
    {
      "Sid": "allowS3Notification",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": "SNS:Publish",
      "Resource": "arn:aws:sns:&amp;lt;aws_region&amp;gt;:&amp;lt;account_a_id&amp;gt;:acc_a_autol_sns",
      "Condition": {
        "ArnLike": {
          "aws:SourceArn": "arn:aws:s3:*:*:acc-a-autol-input"
        }
      }
    }
  ]
}&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&amp;nbsp;&lt;SPAN&gt;Create an SQS in Account A called &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;acc_a_autol_sqs.&lt;/SPAN&gt;&lt;/I&gt;
&lt;OL class="lia-list-style-type-lower-alpha"&gt;
&lt;LI style="font-weight: 400;" aria-level="2"&gt;&lt;SPAN&gt;Type: Standard&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="2"&gt;&lt;SPAN&gt;Access policy of the SQS to get messages from the SNS:&lt;/SPAN&gt;&lt;LI-CODE lang="php"&gt;{
  "Version": "2008-10-17",
  "Id": "notificationPolicy",
  "Statement": [
    {
      "Sid": "allowS3Notification",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": "SQS:SendMessage",
      "Resource": "arn:aws:sqs:&amp;lt;aws_region&amp;gt;:&amp;lt;account_a_id&amp;gt;:acc_a_autol_sqs",
      "Condition": {
        "ArnLike": {
          "aws:SourceArn": "arn:aws:sns:&amp;lt;aws_region&amp;gt;:&amp;lt;account_a_id&amp;gt;:acc_a_autol_sns"
        }
      }
    }
  ]
}&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Subscribe to the above SNS&lt;/SPAN&gt;&lt;I&gt;&lt;/I&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&amp;nbsp;&lt;SPAN&gt;Create an S3 bucket event notification&lt;/SPAN&gt;
&lt;OL class="lia-list-style-type-lower-alpha"&gt;
&lt;LI style="font-weight: 400;" aria-level="2"&gt;&lt;SPAN&gt;Name: &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;databricks-autol-events&lt;/SPAN&gt;&lt;/I&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="2"&gt;&lt;SPAN&gt;Prefix: &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;data/manual/&lt;/SPAN&gt;&lt;/I&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="2"&gt;&lt;SPAN&gt;All object create events&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="2"&gt;&lt;SPAN&gt;Destination: Put the SNS ARN&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Create an IAM role with SNS-SQS Autoloader auto-create policy in Account A&lt;/SPAN&gt;
&lt;OL class="lia-list-style-type-lower-alpha"&gt;
&lt;LI style="font-weight: 400;" aria-level="2"&gt;&lt;SPAN&gt;Role Name: &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;acc_a_autol_manual_create_role&lt;/SPAN&gt;&lt;/I&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="2"&gt;&lt;SPAN&gt;Policy Name: &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;acc_a_autol_manual_create_policy &lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN&gt;– This policy lets Databricks autoloader access to the SNS and SQS created in Steps 1 and 2.&lt;/SPAN&gt;&lt;LI-CODE lang="php"&gt;{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "DatabricksAutoLoaderUse",
            "Effect": "Allow",
            "Action": [
                "s3:GetBucketNotification",
                "sns:ListSubscriptionsByTopic",
                "sns:GetTopicAttributes",
                "sns:TagResource",
                "sns:Publish",
                "sqs:DeleteMessage",
                "sqs:ReceiveMessage",
                "sqs:SendMessage",
                "sqs:GetQueueUrl",
                "sqs:GetQueueAttributes",
                "sqs:TagQueue",
                "sqs:ChangeMessageVisibility"
            ],
            "Resource": [
                "arn:aws:sqs:&amp;lt;aws_region&amp;gt;:&amp;lt;account_a_id&amp;gt;:acc_a_autol_sqs",
                "arn:aws:sns:&amp;lt;aws_region&amp;gt;:&amp;lt;account_a_id&amp;gt;:acc_a_autol_sns",
                "arn:aws:s3:::acc-a-autol-input"
            ]
        }
    ]
}&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Trust Relationship – lets the instance profile assume this role.&lt;/SPAN&gt;&lt;LI-CODE lang="php"&gt;{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::&amp;lt;account_b_id&amp;gt;:role/acc_b_instance_profile"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;SPAN&gt;Add this to the existing policy in instance profile IAM role &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;acc_b_instance_profile&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;       {
            "Sid": "AssumeManualRoleAccA",
            "Effect": "Allow",
            "Action": "sts:AssumeRole",
            "Resource": "arn:aws:iam::&amp;lt;account_a_id&amp;gt;:role/acc_a_autol_manual_create_role"
        }&lt;/LI-CODE&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;H2&gt;Test cross-account Autoloader connection&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;Run and test the Autoloader code from a notebook in Databricks Workspace:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;options = {
   "cloudFiles.format": "parquet",
   "cloudFiles.schemaLocation": "s3://acc-a-autol-input/schema/manual/",
   "cloudFiles.useNotifications": True,
   "cloudFiles.roleArn": "arn:aws:iam::&amp;lt;account_a_id&amp;gt;:role/acc_a_autol_manual_create_role",
   "cloudFiles.queueUrl": "https://sqs.&amp;lt;aws_region&amp;gt;.amazonaws.com/&amp;lt;account_a_id&amp;gt;/acc_a_autol_sqs"
}

df = (
   spark.readStream.format("cloudFiles")
   .options(**options)
   .load("s3://acc-a-autol-input/data/manual/")
)

(
   df.writeStream.option("checkpointLocation", "s3://acc-a-autol-input/checkpoint/manual1/1/")
   .start("s3://acc-a-autol-input/output/manual/")
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;By following these steps, you should be able to successfully set up a cross-account Autoloader connection with Databricks.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 28 May 2024 13:30:20 GMT</pubDate>
    <dc:creator>MohanaBasak</dc:creator>
    <dc:date>2024-05-28T13:30:20Z</dc:date>
    <item>
      <title>How to use Databricks Autoloader across AWS accounts</title>
      <link>https://community.databricks.com/t5/technical-blog/how-to-use-databricks-autoloader-across-aws-accounts/ba-p/68621</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MohanaBasak_0-1715182388562.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/7500i20A6A637ECD6EEAC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MohanaBasak_0-1715182388562.png" alt="MohanaBasak_0-1715182388562.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 13:30:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/technical-blog/how-to-use-databricks-autoloader-across-aws-accounts/ba-p/68621</guid>
      <dc:creator>MohanaBasak</dc:creator>
      <dc:date>2024-05-28T13:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Databricks Autoloader across AWS accounts</title>
      <link>https://community.databricks.com/t5/technical-blog/how-to-use-databricks-autoloader-across-aws-accounts/bc-p/80684#M235</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;Thanks a lot for this excellent and detailed write up. I have tried to configure this myself but for some reason couldn't make it work.&lt;/P&gt;&lt;P&gt;My cluster was able to assume the&amp;nbsp;&lt;SPAN&gt;instance profile in Account B successfully. I was then able to use boto3 in a Notebook to assume the role in Account A and to get the appropriate S3 object from Account A.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sts_client = boto3.client('sts')
assumed_role_object = sts_client.assume_role(
    RoleArn=role_arn,
    RoleSessionName=session_name,
    ExternalId=external_id
)

# Get the temporary credentials
credentials = assumed_role_object['Credentials']

# Create an S3 client using the temporary credentials
s3_client = boto3.client(
    's3',
    aws_access_key_id=credentials['AccessKeyId'],
    aws_secret_access_key=credentials['SecretAccessKey'],
    aws_session_token=credentials['SessionToken']
)

# Try to get the object
response = s3_client.get_object(Bucket=bucket_name, Key=file_key)
    
# Read some of the content
content = response['Body'].read(1024)  # Read first 1KB
print(f"Successfully accessed the file. First 1KB of content:\n{content}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I then attempted to use spark for this and got an&amp;nbsp;AccessDeniedException:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyspark.sql import SparkSession

# Initialize Spark session
spark = SparkSession.builder.appName("S3DataReadTest").getOrCreate()

# Configure Spark to use AWS IAM role
spark.conf.set("spark.hadoop.fs.s3a.aws.credentials.provider", "org.apache.hadoop.fs.s3a.auth.AssumedRoleCredentialProvider")
spark.conf.set("spark.hadoop.fs.s3a.assumed.role.arn", role_arn)
spark.conf.set("spark.hadoop.fs.s3a.assumed.role.session.name", role_session_name)
spark.conf.set("spark.hadoop.fs.s3a.assumed.role.external.id", role_external_id)
spark.conf.set("spark.hadoop.fs.s3a.assumed.role.sts.endpoint", "sts.amazonaws.com")

# Read the data
data_df = spark.read.format("csv").load(s3_bucket_path)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I also tried to use the temporary credentials I got from the successful assume_role command in boto3, but that didn't work either:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;spark = SparkSession.builder \
    .config("spark.hadoop.fs.s3a.access.key", credentials['AccessKeyId']) \
    .config("spark.hadoop.fs.s3a.secret.key", credentials['SecretAccessKey']) \
    .config("spark.hadoop.fs.s3a.session.token", credentials['SessionToken']) \
    .config("spark.hadoop.fs.s3a.aws.credentials.provider", "org.apache.hadoop.fs.s3a.TemporaryAWSCredentialsProvider") \
    .config("spark.hadoop.fs.s3a.impl", "org.apache.hadoop.fs.s3a.S3AFileSystem") \
    .config("spark.hadoop.com.amazonaws.services.s3.enableV4", "true") \
    .config("spark.hadoop.fs.s3a.endpoint", "s3.us-east-1.amazonaws.com") \
    .getOrCreate()

# Attempt to read the file
print(f"Attempting to read file: {s3_path}")
df = spark.read.csv(s3_path, header=True, inferSchema=True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any idea what the issue could be? Any insight would be appreciated!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;* By the way, for some reason the boto3 access worked for me when using a private cluster, but didn't work on a shared cluster (even though the instance profile was assumed in both cases). &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;When running this on a shared cluster:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Assume the role
sts_client = boto3.client('sts')
assumed_role_object = sts_client.assume_role(
    RoleArn=role_arn,
    RoleSessionName=session_name,
    ExternalId=external_id
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;EM&gt;I get the following error:&lt;/EM&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;N&lt;SPAN class=""&gt;oCredentialsError: &lt;/SPAN&gt;Unable to locate credentials&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 08:56:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/technical-blog/how-to-use-databricks-autoloader-across-aws-accounts/bc-p/80684#M235</guid>
      <dc:creator>iddoi</dc:creator>
      <dc:date>2024-07-26T08:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Databricks Autoloader across AWS accounts</title>
      <link>https://community.databricks.com/t5/technical-blog/how-to-use-databricks-autoloader-across-aws-accounts/bc-p/80755#M237</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/113816"&gt;@iddoi&lt;/a&gt;&amp;nbsp;This blog is specifically for Databricks Autoloader setup using an Instance Profile in Databricks. If you are trying to read data from an S3 bucket (either in the same AWS account, or a different one) to a Databricks notebook, the recommended approach is to use &lt;A href="https://docs.databricks.com/en/connect/unity-catalog/index.html" target="_self"&gt;Unity Catalog (UC)&lt;/A&gt;. With UC, you will not need any instance profile, or need to set any Spark configs. Once you successfully set a connection to an S3 bucket with UC (storage credential and external location), you will directly be able to read from that bucket.&lt;/P&gt;
&lt;P&gt;If you are not using UC, and you are trying to connect using an Instance Profile, the bucket in the other AWS account will be accessible if the instance profile permissions are properly set. With this also you will not need any Spark configs if the Instance Profile setup is correct.&lt;/P&gt;
&lt;P&gt;That said, I was able to read from an S3 bucket by using your boto3 STS code to get temporary credentials, and then setting hadoop credentials in this way:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;aws_access_key_id=credentials['AccessKeyId']
aws_secret_access_key=credentials['SecretAccessKey']
aws_session_token=credentials['SessionToken']

sc._jsc.hadoopConfiguration().set("fs.s3a.aws.credentials.provider", "org.apache.hadoop.fs.s3a.TemporaryAWSCredentialsProvider")
sc._jsc.hadoopConfiguration().set("fs.s3a.access.key", aws_access_key_id)
sc._jsc.hadoopConfiguration().set("fs.s3a.secret.key", aws_secret_access_key)
sc._jsc.hadoopConfiguration().set("fs.s3a.session.token", aws_session_token)

data_df = spark.read.format("csv").load('s3://acc-a-autol-input/rnd-2022-notes.csv')
display(data_df)&lt;/LI-CODE&gt;
&lt;P&gt;I hope this helps. Again, Unity Catalog is the recommended way of reading data from S3 to Databricks.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 18:44:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/technical-blog/how-to-use-databricks-autoloader-across-aws-accounts/bc-p/80755#M237</guid>
      <dc:creator>MohanaBasak</dc:creator>
      <dc:date>2024-07-26T18:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Databricks Autoloader across AWS accounts</title>
      <link>https://community.databricks.com/t5/technical-blog/how-to-use-databricks-autoloader-across-aws-accounts/bc-p/117409#M557</link>
      <description>&lt;P&gt;If you have migrated to UC and are looking for a way to set up Auto Loader file Notification in UC-enabled clusters, then read the latest blog here -&amp;nbsp;&lt;A href="https://community.databricks.com/t5/technical-blog/how-to-set-up-autoloader-in-file-notification-mode-on-aws-using/ba-p/117048" target="_blank"&gt;https://community.databricks.com/t5/technical-blog/how-to-set-up-autoloader-in-file-notification-mode-on-aws-using/ba-p/117048&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 May 2025 15:40:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/technical-blog/how-to-use-databricks-autoloader-across-aws-accounts/bc-p/117409#M557</guid>
      <dc:creator>MohanaBasak</dc:creator>
      <dc:date>2025-05-01T15:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Databricks Autoloader across AWS accounts</title>
      <link>https://community.databricks.com/t5/technical-blog/how-to-use-databricks-autoloader-across-aws-accounts/bc-p/148798#M922</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/21882"&gt;@MohanaBasak&lt;/a&gt;&amp;nbsp;, thank you for the blog post, that's very useful. We're using Databricks autoloader (with notification mode without using UC) to load files across aws accounts. The databricks job is in account B and the s3 bucket / sqs-to-be-created-by-autoloader / sns-to-be-created-by-autoloader are in account A. The only difference is that our databricks job in account B needs to write to account B's S3 and Glue (not writting to account A's S3 as you described in the blog post). I believe that it's a common use case. Do you think after the account B role `arn:aws:iam::&amp;lt;account_b_id&amp;gt;:role/acc_b_instance_profile` has assumed the the account A role `arn:aws:iam::&amp;lt;account_a_id&amp;gt;:role/acc_a_autol_auto_create_role`, the databricks job would lose its original permissions (given to `arn:aws:iam::&amp;lt;account_b_id&amp;gt;:role/acc_b_instance_profile`) to write to account B's S3 and Glue? Or the databricks job is smart enough to only assume the role when using autoloader with SQS/SNS, and skip assuming the role (so using the original `arn:aws:iam::&amp;lt;account_a_id&amp;gt;:role/acc_a_autol_auto_create_role`) when writing to account B's S3 and Glue?&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Feb 2026 12:25:09 GMT</pubDate>
      <guid>https://community.databricks.com/t5/technical-blog/how-to-use-databricks-autoloader-across-aws-accounts/bc-p/148798#M922</guid>
      <dc:creator>427430</dc:creator>
      <dc:date>2026-02-19T12:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Databricks Autoloader across AWS accounts</title>
      <link>https://community.databricks.com/t5/technical-blog/how-to-use-databricks-autoloader-across-aws-accounts/bc-p/149110#M932</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/22524"&gt;@427430&lt;/a&gt;&amp;nbsp;I haven't tested this out, but I would say that if the instance profile attached to the cluster has access to write out into the S3 bucket of Acc B, it should be able to. Having said that, please use the UC version of this -&amp;nbsp;&lt;A href="https://community.databricks.com/t5/technical-blog/how-to-set-up-autoloader-in-file-notification-mode-on-aws-using/ba-p/117048" target="_blank"&gt;https://community.databricks.com/t5/technical-blog/how-to-set-up-autoloader-in-file-notification-mode-on-aws-using/ba-p/117048&lt;/A&gt;. UC is the Databricks recommended approach to interact with any cloud storage, and yes, if you use this approach, you should be able to write to a bucket in Acc B.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Feb 2026 22:05:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/technical-blog/how-to-use-databricks-autoloader-across-aws-accounts/bc-p/149110#M932</guid>
      <dc:creator>MohanaBasak</dc:creator>
      <dc:date>2026-02-23T22:05:11Z</dc:date>
    </item>
  </channel>
</rss>

