[英]AWS sdk version 2, create ec2 instance
I might have missed it, but i cant figure out how to create ec2 instance in ruby via the version 2 of the aws sdk.. anyone? 我可能已经错过了,但是我无法弄清楚如何通过aws sdk的版本2在ruby中创建ec2实例。
cant find any solution in http://docs.aws.amazon.com/sdkforruby/api/Aws.html 在http://docs.aws.amazon.com/sdkforruby/api/Aws.html中找不到任何解决方案
Grab a client with 抓住客户
ec2 = Aws::EC2::Client.new(
region: region_name,
credentials: credentials
)
, then launch instances with ec2.run_instances
.See documentation below. ,然后使用ec2.run_instances
启动实例。请ec2.run_instances
下面的文档。 http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#run_instances-instance_method http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#run_instances-instance_method
There are sdk gems for rby. 有供rby使用的sdk宝石。 To install the sdk-2 gem you need to add 要安装sdk-2 gem,您需要添加
gem 'aws-sdk', '~> 2'`
In your Gemfile and install it with bundle install
command. 在您的Gemfile中,并使用bundle install
命令安装它。 After that you can refer this docs for the rest: http://docs.aws.amazon.com/sdkforruby/api/index.html 之后,您可以其余参考该文档: http : //docs.aws.amazon.com/sdkforruby/api/index.html
And examples right there: 那里的例子:
# resource constructors
ec2 = Aws::EC2::Resource.new(region:'us-west-2', credentials: credentials)
# client constructors
ec2 = Aws::EC2::Client.new(region:'us-west-2', credentials: credentials)
The configuration examples are there as well. 配置示例也在那里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.