cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Community Discussions
Connect with fellow community members to discuss general topics related to the Databricks platform, industry trends, and best practices. Share experiences, ask questions, and foster collaboration within the community.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Access AWS Resource In Another Account without STS

Blasti
New Contributor II

The EC2 instance profile I setup in the master AWS account can assume an S3/Dynamo access role in another S3 account. How do i setup in Databricks/AWS so that when I use Python Boto3 to access S3 and Dynamo without using STS to assume the role. 

2 REPLIES 2

Kaniz
Community Manager
Community Manager

Hi @BlastiTo access Amazon S3 and DynamoDB from Databricks using Python Boto3 without explicitly assuming an STS role, you can follow these steps:

  1. Amazon S3 Access:

    • Create a session using your AWS access key ID and secret access key. You can do this as follows:
      import boto3
      session = boto3.Session(
          aws_access_key_id='YOUR_ACCESS_KEY',
          aws_secret_access_key='YOUR_SECRET_KEY'
      )
      
    • Use the session to get an S3 resource:
      s3 = session.resource('s3')
      
    • Now you can perform S3 operations using the s3 resource.
  2. DynamoDB Access:

    • Similarly, for DynamoDB, you can pass the access key and secret key directly in your code:
      import boto3
      session = boto3.Session(
          aws_access_key_id='YOUR_ACCESS_KEY',
          aws_secret_access_key='YOUR_SECRET_KEY'
      )
      client = session.client('dynamodb')
      
    • Now you can use the client to interact with DynamoDB.

Remember to replace 'YOUR_ACCESS_KEY' and 'YOUR_SECRET_KEY' with your actual AWS credentials. Keep in mind that embedding keys directly in the code is not the recommended way to access AWS resources with Boto3. Itโ€™s better to use IAM roles or environment variables for security reasons12

 

Blasti
New Contributor II

Hey Kaniz, i am sorry about the confusion. I should have made my question more clear. I mean to access without using IAM assume role or access key as if the i am access resource within the same aws account.

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!