Class: Chef::Provisioning::AWSDriver::TaggingStrategy::AutoScaling
- Inherits:
-
Object
- Object
- Chef::Provisioning::AWSDriver::TaggingStrategy::AutoScaling
- Defined in:
- lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb
Instance Attribute Summary collapse
-
#auto_scaling_client ⇒ Object
readonly
Returns the value of attribute auto_scaling_client.
-
#desired_tags ⇒ Object
readonly
Returns the value of attribute desired_tags.
-
#group_name ⇒ Object
readonly
Returns the value of attribute group_name.
Instance Method Summary collapse
- #current_tags ⇒ Object
- #delete_tags(tag_keys) ⇒ Object
-
#initialize(auto_scaling_client, group_name, desired_tags) ⇒ AutoScaling
constructor
A new instance of AutoScaling.
- #set_tags(tags) ⇒ Object
Constructor Details
#initialize(auto_scaling_client, group_name, desired_tags) ⇒ AutoScaling
26 27 28 29 30 |
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb', line 26 def initialize(auto_scaling_client, group_name, ) @auto_scaling_client = auto_scaling_client @group_name = group_name = end |
Instance Attribute Details
#auto_scaling_client ⇒ Object (readonly)
Returns the value of attribute auto_scaling_client.
24 25 26 |
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb', line 24 def auto_scaling_client @auto_scaling_client end |
#desired_tags ⇒ Object (readonly)
Returns the value of attribute desired_tags.
24 25 26 |
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb', line 24 def end |
#group_name ⇒ Object (readonly)
Returns the value of attribute group_name.
24 25 26 |
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb', line 24 def group_name @group_name end |
Instance Method Details
#current_tags ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb', line 32 def # http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#describe_tags-instance_method resp = auto_scaling_client.({ filters: [ { name: "auto-scaling-group", values: [group_name] } ] }) Hash[resp..map {|t| [t.key, t.value]}] end |
#delete_tags(tag_keys) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb', line 60 def (tag_keys) # http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#delete_tags-instance_method auto_scaling_client.({ tags: tag_keys.map {|k| { resource_id: group_name, key: k, value: nil, resource_type: "auto-scaling-group", propagate_at_launch: false } } }) end |
#set_tags(tags) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb', line 45 def () # http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#create_or_update_tags-instance_method auto_scaling_client.({ tags: .map {|k,v| { resource_id: group_name, key: k, value: v, resource_type: "auto-scaling-group", propagate_at_launch: false } } }) end |