使用CLI启动AWS实例时如何传递用户数据 [英] how to pass in the user-data when launching AWS instances using CLI

查看:71
本文介绍了使用CLI启动AWS实例时如何传递用户数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AWS CLI启动实例,命令是: AWS EC2运行实例

I'm using the AWS CLI to launch instances, and the command is: aws ec2 run-instances

我期望将脚本作为用户数据传递. 所以我做了: 数据= base64 ./my_script 在我的Mac OSX上,然后通过以下方式传递数据: aws ec2 run-instances --user-data $ DATA

what i'm expecting is to pass in a script as the user-data. so, I did: DATA=base64 ./my_script on my Mac OSX, and then pass the DATA by: aws ec2 run-instances --user-data $DATA

但是,实例启动后什么也没发生

BUT, nothing happened after the instance launched

那么,我应该怎么做?

谢谢!

推荐答案

不需要自己对数据进行base64编码.

There is no need to base64 encode the data yourself.

您可以在文件名/路径前添加file://

You can prefix a file name/path with file://

所以

aws ec2 run-instances --user-data file://my_script

aws ec2 run-instances --user-data file:///full/path/to/my_script

这篇关于使用CLI启动AWS实例时如何传递用户数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆