-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aws Tags #190
Aws Tags #190
Conversation
@tyler-ball this is ready for a review |
@chef/ociv work re: aws tagging |
The tag example is still failing like #189 correct? |
action :allocate | ||
end | ||
|
||
aws_instance 'ref-machine-1' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm - I totally didn't think about the fact that most people are going to use machine
and that doesn't support tag attributes. This solution (having to use aws_instance
with the same name as the machine) seems less than intuitive. And I don't want to add a tag
attribute to machine
because that would require a new release of chef-provisioning... And whatever solution we use will have to work for machine, machine_batch and load_balancer.
Its not awesome, but I think we should read a tags
field in the machine_options and load_balancer_options like so:
machine 'test' do
machine_options bootstrap_options: {
aws_tags: {'key' => 'value'}
}
end
machine_batch 'test-batch' do
machine_options bootstrap_options: {
aws_tags: {'key' => 'value'}
}
machine 'test1'
machine 'test2'
end
machine_image 'test-image' do
machine_options bootstrap_options: {
aws_tags: {'key' => 'value'}
}
image_options bootstrap_options: {
aws_tags: {'key' => 'value'}
}
end
load_balancer 'test_lb' do
load_balancer_options aws_tags: {'key' => 'value'}
end
@jkeiser what do you think of this? Its a weird dual-user-interface problem, but I don't want to add a base provider_tags
attribute to these resources in chef-provisioning because that implies all providers support tags.
Long term, I want to fix this by having machine
in a recipe lookup the correct AwsInstance
resource using the new resource mapping introduced in Chef 12. Then
machine 'ref-machine-1` do
aws_tags :marco => 'polo'
end
would correctly instantiate a AwsInstance
resource and apply the aws_tags
to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm +1 on using *_options for instances and load balancers over how it is currently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also like to add that even though tagging machines and load balancers isn't ideal with this branch, I would press that we still merge these changes pending a good review. This is a feature that is much needed and we can improve it in a new branch.
Yes, that's how I discovered it. The aws tag spec that tags an aws_instance is terminated properly. I was hoping it was some issue with the recipe I am overlooking. |
@@ -221,6 +223,29 @@ def destroy_aws_object(obj) | |||
raise NotImplementedError, :destroy_aws_object | |||
end | |||
|
|||
# TODO documentation and tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some yarddoc here?
The specs and the matcher look great! There is only a few missing specs I would like to see: aws_ebs_volume 'ref' do
aws_tags {'aaa' => 'a'}
end
aws_ebs_volume 'ref' do
aws_tags {'bbb' => 'b'}
end should only have the The other spec should test that when the aws_ebs_volume 'ref' do
aws_tags {'aaa' => 'a'}
end
aws_ebs_volume 'ref' should still contain the tags |
Good call on the tests. The first case I was handling, but the second case uncovered a bug where the tags were being wiped out because the default aws_tags attribute is {}. Since we may want that functionality I removed the default {} and handle the nil attribute in #converge_tags. |
@Patrick-Wright you should be able to rebase against master and have your ref work! |
ad99fc2
to
29af92d
Compare
a6914b7
to
a24e55d
Compare
👍 Great job! |
It doesn't seem to work on security groups when you use 'add_machine_options' |
@danieljimenez you need to use the aws_tags attribute with the resource. aws_security_group 'blah' do
aws_tags :tag_name => 'value'
# other attrs
end the readme has some additional details: https://github.com/chef/chef-provisioning-aws#aws-resources |
@Patrick-Wright I did this:
|
@danieljimenez good find. Looks like AwsSecurityGroup resource is requiring _with_entry, but is subclassing AWSResource. I'll try updating this locally, but do you see an immediate issue changing that to AWSResourceWithEntry? |
@Patrick-Wright Ah! I updated security groups to subclass It looks like this exposed an issue with tags! I'll file a bug. |
Tracking this new issue in #204 |
Support tagging for AWS resources which are "taggable".