简体   繁体   English

将文件从一个帐户中的 AWS S3 存储桶复制到 terraform/python 中另一个帐户中的存储桶

[英]copy files from AWS S3 bucket in one account to bucket in another account in terraform/python

Say if I have some data stored in account A, i want to be able to use some of them in account B (mainly for SageMaker usage), I guess I can copy files from bucket in account A to a bucket in account B, i did find some solutions by using aws cli, but is there a terraform / python solution to achieve this?假设我在账户 A 中存储了一些数据,我希望能够在账户 B 中使用其中一些数据(主要用于 SageMaker),我想我可以将文件从账户 A 中的存储桶复制到账户 B 中的存储桶,我确实通过使用 aws cli 找到了一些解决方案,但是是否有 terraform / python 解决方案来实现这个?

Is there an easy way to make one s3 bucket in account A to be accessible from account B?有没有一种简单的方法可以使帐户 A 中的一个 s3 存储桶可以从帐户 B 访问? & what's the implementation look like in terraform/python (eg: boto3)? &在 terraform/python 中的实现是什么样的(例如:boto3)?

In terraform you can do something like this:在 terraform 你可以这样做:

terraform apply \
    -var="prod_access_key=AAAAAAAAAAAAAAAAAAA" \
    -var="prod_secret_key=SuperSecretKeyForAccountA" \
    -var="test_account_id=123456789012" \
    -var="test_access_key=BBBBBBBBBBBBBBBBBBB" \
    -var="test_secret_key=SuperSecretKeyForAccountB" \
    -var="bucket_name=tf-bucket-in-prod" \

Im not sure where you plan to run python from, but to answer your question you need to permit the IAM Role in Account A to assume an IAM Role in account B. As S3 also allows resource based policies you can create a bucket which includes a resource policy permitting another account:我不确定您计划从哪里运行 python,但要回答您的问题,您需要允许账户 A 中的 IAM 角色承担账户 B 中的 IAM 角色。由于 S3 还允许基于资源的策略,您可以创建一个存储桶,其中包含一个允许另一个帐户的资源策略:

https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-walkthroughs-managing-access-example2.html https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-walkthroughs-managing-access-example2.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 S3 存储桶从一个 AWS 账户复制到另一个 AWS 账户在传输过程中是否安全? - Is copying an S3 bucket from one AWS account to another AWS account secure in transit? 我们可以将一个账户中的存储网关链接到另一个账户中的 s3 存储桶吗? - Can we link storage gateway in one account to s3 bucket in another account? 从一个存储桶到另一个存储桶的 AWS S3 同步命令 - AWS S3 sync command from one bucket to another 使用 Java (Amazon S3) 将 all.txt 文件从一个 object 复制到另一个但在同一个存储桶中 - Copy all .txt files from one object to another but in the same bucket using Java (Amazon S3) 没有前端经验或用户无法访问 AWS 帐户的用户能否将文件上传到 S3 存储桶? - Can users upload files into a S3 bucket without frontend experience or users having access to AWS account? S3 存储桶/AWS 账户的所有者*名称*来自哪里? - Where does the owner *name* for an S3 bucket/AWS account come from? S3 对象从一个存储桶复制到另一个存储桶 - 出现拒绝访问错误 - S3 object copy from one bucket to another - giving Access Denied errors 可以通过 Hive 将数据从一个 s3 存储桶复制到另一个存储桶吗? - Possible to copy data from one s3 bucket to another via Hive? 最简单的 lambda function 将文件从一个 s3 存储桶复制到另一个存储桶 - Simplest lambda function to copy a file from one s3 bucket to another 将文件从 Mac (iCloud) 保存到 S3 存储桶 (AWS) 的脚本 - Script to save files from Mac (iCloud) to S3 bucket (AWS)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM