[英]How can I copy a file from s3 bucket into an ec2 instance using userdata inside a cloudformation template
I need to be able to copy some files from s3 bucket into ec2 instance during launch time .我需要能够在启动期间将一些文件从 s3 存储桶复制到 ec2 实例中。 Is it possible to do so via user data section of the cloudformation template?是否可以通过 cloudformation 模板的用户数据部分来实现?
Fyi, I have the role attached to the instance to access s3 and I am able to copy files using aws cli but I need to be able to do so via user data inside cloudformation without using aws cli, if possible at all.仅供参考,我将角色附加到实例以访问 s3,我能够使用 aws cli 复制文件,但我需要能够通过 cloudformation 中的用户数据进行复制,而无需使用 aws cli,如果可能的话。
Edit--编辑 -
Object in s3 is publicly accessible at the moment and the instance is using a custom red hat ami. s3 中的对象目前是可公开访问的,并且该实例使用的是自定义的 red hat ami。
If the object in Amazon S3 is publicly accessible, you could download it with curl
:如果 Amazon S3 中的对象可公开访问,您可以使用curl
下载它:
curl -o output.file https://my-bucket.s3-us-west-2.amazonaws.com/file.txt
If wget
is installed, you could use that instead.如果安装了wget
,您可以改用它。
If the object is private, it will require authentication using the role.如果对象是私有的,则需要使用角色进行身份验证。 This will require some form of software to be installed, so it would be simpler to just install the AWS CLI.这将需要安装某种形式的软件,因此安装 AWS CLI 会更简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.