I'm playing around with Chef to launch EC2 insta开发者_如何学Gonces. Everything is working pretty well, but Chef doesn't seem to have the ability to tag the instances. Am I missing something?
Otherwise, what's the preferred Ruby library for achieving this? Can I do it without requiring additional gems?
Thanks
Version 0.5.12 of the knife-ec2
Gem supports tagging EC2 instances on creation with the --tags
option.
knife ec2 server create [... your options...] --tags Tag=Value
Know this is old, but was browsing about and spotted it. Another alternative is to use the AWS community cookbook - assuming you have key creds - if you want to do things programatically as part of the recipe.
aws = data_bag_item('mydatabag', 'creds')
aws_resource_tag node['ec2']['instance_id'] do
aws_access_key aws['access_key']
aws_secret_access_key aws['secret_key']
tags({
"foo" => "bar"
})
action :update
end
Usually chef is used to install things on the instance. I'm not exactly sure how you start a node with chef, but maybe you can share this and I'll extend my answer?
Otherwise, fog is a great library to do these things. I just skimmed over the source and it seems to support tagging as well.
To get fog: gem install fog
.
精彩评论