Ruby AWS SDK(v2 / v3)标记点实例

时间:2018-05-22 06:55:20

标签: amazon-web-services aws-sdk aws-sdk-ruby

根据此link,可以标记现货车队实例。标签会自动传播到已启动的实例。是否可以对正常的现场实例进行相同的操作?我的方法到目前为止

ec2 = Aws::EC2::Resource.new({region: region, credentials: creds})
launch_specification ={
  :security_groups => ['ccc'],
  :ebs_optimized => true,
  :image_id => "image_id",
  :instance_type => "type",
  :key_name => "key",
  :placement => {:group_name => "ggg"},
  :user_data => ""        
} 
resp = ec2.client.request_spot_instances(:instance_count => count,
  :launch_specification => launch_specification,
  :spot_price => price.to_s,
  :type => 'one-time',
  :dry_run => false
)
resp.spot_instance_requests.each do |sir|
  ec2.create_tags({
    dry_run: false,
    resources: [sir.spot_instance_request_id],
    tags: [
          {
            key: "owner",
            value: "ooo",
          },
        ],
      })
end

spot_instance_request创建标签,但不会传播到已启动的实例。

0 个答案:

没有答案