AWS S3 cross account access with Lambda and sts AssumeRole | Fine grained control with Bucket Policy

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ธ.ค. 2024

ความคิดเห็น • 19

  • @beyondthecloud
    @beyondthecloud  ปีที่แล้ว

    Please provide your valuable feedback in the comment section. Please like share and subscribe for more upcoming content.

  • @EdwardSileo
    @EdwardSileo ปีที่แล้ว +1

    So, I think, I have looked at EVERY youtube video on cross account access, and this is the one that actually works. I finally understand it too: The lambda role has to have assume role of the other account role, and the other account role has to have a trust relationship with the lambda role. That was the secret sauce / Rosetta Stone for me . Thank you, thank you, thank you.

    • @beyondthecloud
      @beyondthecloud  ปีที่แล้ว

      Thanks lot for your comment. Really glad you liked the content and it was helpful.

  • @pupun813
    @pupun813 ปีที่แล้ว

    Very nice. Yes Lambda access is very useful in multiple use cases

  • @yogibisai647
    @yogibisai647 ปีที่แล้ว

    Very useful

  • @shovan3112
    @shovan3112 ปีที่แล้ว

    Can you please help me with a few lines on code the same lambda fuction - how to copy files as well (cross account). Bucket name and path (sub-folders) for source and target can come from variables. You've already given FullS3Access policy so shouldn't be a problem it should work. Please share the code for this.

    • @beyondthecloud
      @beyondthecloud  ปีที่แล้ว

      To copy the contents of one S3 bucket to another using AWS Lambda in Python, you can use the boto3 library, which is the official AWS SDK for Python. Make sure you have the boto3 library included in your Lambda deployment package.
      Here's a simple example Lambda function that copies the contents of one S3 bucket to another:
      import boto3
      def lambda_handler(event, context):
      source_bucket = 'your-source-bucket'
      destination_bucket = 'your-destination-bucket'
      # Create an S3 client
      s3 = boto3.client('s3')
      # List all objects in the source bucket
      objects = s3.list_objects(Bucket=source_bucket)['Contents']
      # Copy each object to the destination bucket
      for obj in objects:
      key = obj['Key']
      copy_source = {'Bucket': source_bucket, 'Key': key}
      destination_key = key # You can modify this if you want to change the key in the destination bucket
      s3.copy_object(CopySource=copy_source, Bucket=destination_bucket, Key=destination_key)
      return {
      'statusCode': 200,
      'body': 'S3 content copied successfully!'
      }
      Remember to replace 'your-source-bucket' and 'your-destination-bucket' with your actual source and destination bucket names.
      Note: Ensure that the Lambda execution role has the necessary permissions to read from the source S3 bucket and write to the destination S3 bucket. The role should at least have the AmazonS3ReadOnlyAccess and AmazonS3FullAccess policies attached.

  • @bepositive6525
    @bepositive6525 ปีที่แล้ว +1

    👍🏻

  • @ammarkhalid2872
    @ammarkhalid2872 6 หลายเดือนก่อน

    what to do if we are using ec2 instead of lambda ??

    • @beyondthecloud
      @beyondthecloud  6 หลายเดือนก่อน

      for your use case please find the below link. Same use case I have explained.
      th-cam.com/video/skutntARAfw/w-d-xo.html

  • @vaibhavjain1in
    @vaibhavjain1in 7 หลายเดือนก่อน

    Hey bro, I need some help with AWS. Would you please help me with a small project?

  • @MohamedRoushdy
    @MohamedRoushdy 5 หลายเดือนก่อน

    Would you mind sharing your python code with us? Thank you in advance.

    • @beyondthecloud
      @beyondthecloud  4 หลายเดือนก่อน

      Yes sure, dis you check the description box?

    • @MohamedRoushdy
      @MohamedRoushdy 2 หลายเดือนก่อน

      @@beyondthecloud I beg your pardon, I cannot see any links to the source code. this is why I'm sending you this comment.

  • @घाटीरानमाणूस
    @घाटीरानमाणूस 11 หลายเดือนก่อน

    RoleSessionName :- Need your hep to understand this. I'm unable to get this info.

    • @beyondthecloud
      @beyondthecloud  10 หลายเดือนก่อน

      Thanks for your comment. What are you unable to understand?

    • @घाटीरानमाणूस
      @घाटीरानमाणूस 10 หลายเดือนก่อน

      I was confused about "RoleSessionName". From where we can get that. But now i got that solution.