如何在 AWS s3 和 AWS ec2 之间传输文件 [英] How to transfer files between AWS s3 and AWS ec2
问题描述
我正在使用 AWS ec2 实例.在这种情况下,我生成了一些文件.这些操作由用户数据完成.
I am using AWS ec2 instance. On this instance I'm resulting some files. These operations are done by user data.
现在我想通过在用户数据本身中编写代码来将这些文件存储在 s3 上.
Now I want to store those files on s3 by writing code in user data itself.
- 那么如何将这些文件存储在 s3 上?
- 有相关教程吗?
推荐答案
使用最新的 AWS CLI (http://aws.amazon.com/cli/) 您可以使用以下命令将文件从您的 Ec2 实例甚至您的本地机器复制到 S3 存储.
Using the most recent AWS CLI (http://aws.amazon.com/cli/) you can use the following commands to copy files from your Ec2 Instance or even you local machine to S3 storage.
aws s3 cp myfolder s3://mybucket/myfolder --recursive
然后你会得到类似的东西:
You'll then get something like:
upload: myfolder/file1.txt to s3://mybucket/myfolder/file1.txt
upload: myfolder/subfolder/file1.txt to s3://mybucket/myfolder/subfolder/file1.txt
如果这是您第一次使用 aws
CLI 工具,那么您需要运行:
If this is your first usage of the aws
CLI tool then you'll need to run:
aws 配置
这将要求您输入访问密钥 &秘密以及指定默认区域.
This will ask you to enter your access key & secret along with specifying a default region.
这篇关于如何在 AWS s3 和 AWS ec2 之间传输文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!