chef-provisioning-aws 3.0.4 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +16 -5
- data/Rakefile +15 -6
- data/chef-provisioning-aws.gemspec +17 -17
- data/lib/chef/provider/aws_auto_scaling_group.rb +5 -6
- data/lib/chef/provider/aws_cache_cluster.rb +21 -15
- data/lib/chef/provider/aws_cache_replication_group.rb +12 -8
- data/lib/chef/provider/aws_cache_subnet_group.rb +3 -3
- data/lib/chef/provider/aws_cloudsearch_domain.rb +9 -13
- data/lib/chef/provider/aws_cloudwatch_alarm.rb +10 -12
- data/lib/chef/provider/aws_dhcp_options.rb +18 -21
- data/lib/chef/provider/aws_ebs_volume.rb +24 -26
- data/lib/chef/provider/aws_eip_address.rb +10 -13
- data/lib/chef/provider/aws_elasticsearch_domain.rb +19 -18
- data/lib/chef/provider/aws_iam_instance_profile.rb +5 -7
- data/lib/chef/provider/aws_iam_role.rb +14 -17
- data/lib/chef/provider/aws_image.rb +6 -6
- data/lib/chef/provider/aws_instance.rb +5 -5
- data/lib/chef/provider/aws_internet_gateway.rb +8 -11
- data/lib/chef/provider/aws_key_pair.rb +15 -17
- data/lib/chef/provider/aws_launch_configuration.rb +11 -14
- data/lib/chef/provider/aws_load_balancer.rb +1 -2
- data/lib/chef/provider/aws_nat_gateway.rb +6 -7
- data/lib/chef/provider/aws_network_acl.rb +28 -29
- data/lib/chef/provider/aws_network_interface.rb +25 -27
- data/lib/chef/provider/aws_rds_instance.rb +12 -13
- data/lib/chef/provider/aws_rds_parameter_group.rb +8 -8
- data/lib/chef/provider/aws_rds_subnet_group.rb +8 -9
- data/lib/chef/provider/aws_route_table.rb +19 -20
- data/lib/chef/provider/aws_s3_bucket.rb +22 -25
- data/lib/chef/provider/aws_security_group.rb +268 -285
- data/lib/chef/provider/aws_server_certificate.rb +6 -5
- data/lib/chef/provider/aws_sns_topic.rb +4 -6
- data/lib/chef/provider/aws_sqs_queue.rb +3 -4
- data/lib/chef/provider/aws_subnet.rb +29 -34
- data/lib/chef/provider/aws_vpc.rb +108 -116
- data/lib/chef/provider/aws_vpc_peering_connection.rb +11 -11
- data/lib/chef/provisioning/aws_driver.rb +4 -2
- data/lib/chef/provisioning/aws_driver/aws_provider.rb +234 -241
- data/lib/chef/provisioning/aws_driver/aws_rds_resource.rb +5 -7
- data/lib/chef/provisioning/aws_driver/aws_resource.rb +182 -185
- data/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb +17 -17
- data/lib/chef/provisioning/aws_driver/aws_taggable.rb +13 -15
- data/lib/chef/provisioning/aws_driver/aws_tagger.rb +47 -48
- data/lib/chef/provisioning/aws_driver/credentials.rb +96 -100
- data/lib/chef/provisioning/aws_driver/credentials2.rb +42 -45
- data/lib/chef/provisioning/aws_driver/driver.rb +1349 -1362
- data/lib/chef/provisioning/aws_driver/exceptions.rb +10 -12
- data/lib/chef/provisioning/aws_driver/super_lwrp.rb +60 -60
- data/lib/chef/provisioning/aws_driver/tagging_strategy/auto_scaling.rb +49 -50
- data/lib/chef/provisioning/aws_driver/tagging_strategy/ec2.rb +37 -38
- data/lib/chef/provisioning/aws_driver/tagging_strategy/elasticsearch.rb +14 -15
- data/lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb +29 -31
- data/lib/chef/provisioning/aws_driver/tagging_strategy/rds.rb +39 -40
- data/lib/chef/provisioning/aws_driver/tagging_strategy/s3.rb +41 -43
- data/lib/chef/provisioning/aws_driver/version.rb +5 -5
- data/lib/chef/provisioning/driver_init/aws.rb +2 -2
- data/lib/chef/resource/aws_auto_scaling_group.rb +1 -1
- data/lib/chef/resource/aws_cache_cluster.rb +9 -12
- data/lib/chef/resource/aws_cache_replication_group.rb +9 -11
- data/lib/chef/resource/aws_cache_subnet_group.rb +8 -10
- data/lib/chef/resource/aws_cloudsearch_domain.rb +4 -5
- data/lib/chef/resource/aws_cloudwatch_alarm.rb +17 -18
- data/lib/chef/resource/aws_dhcp_options.rb +2 -2
- data/lib/chef/resource/aws_ebs_volume.rb +10 -10
- data/lib/chef/resource/aws_eip_address.rb +5 -5
- data/lib/chef/resource/aws_elasticsearch_domain.rb +4 -4
- data/lib/chef/resource/aws_iam_instance_profile.rb +4 -5
- data/lib/chef/resource/aws_iam_role.rb +2 -3
- data/lib/chef/resource/aws_image.rb +3 -3
- data/lib/chef/resource/aws_instance.rb +4 -4
- data/lib/chef/resource/aws_internet_gateway.rb +3 -3
- data/lib/chef/resource/aws_key_pair.rb +7 -7
- data/lib/chef/resource/aws_launch_configuration.rb +4 -4
- data/lib/chef/resource/aws_load_balancer.rb +7 -7
- data/lib/chef/resource/aws_nat_gateway.rb +11 -11
- data/lib/chef/resource/aws_network_acl.rb +7 -8
- data/lib/chef/resource/aws_network_interface.rb +9 -9
- data/lib/chef/resource/aws_rds_instance.rb +4 -4
- data/lib/chef/resource/aws_rds_parameter_group.rb +3 -3
- data/lib/chef/resource/aws_rds_subnet_group.rb +4 -4
- data/lib/chef/resource/aws_route53_hosted_zone.rb +37 -40
- data/lib/chef/resource/aws_route53_record_set.rb +22 -24
- data/lib/chef/resource/aws_route_table.rb +7 -7
- data/lib/chef/resource/aws_s3_bucket.rb +7 -7
- data/lib/chef/resource/aws_security_group.rb +10 -10
- data/lib/chef/resource/aws_server_certificate.rb +6 -8
- data/lib/chef/resource/aws_sns_topic.rb +2 -2
- data/lib/chef/resource/aws_sqs_queue.rb +5 -7
- data/lib/chef/resource/aws_subnet.rb +9 -9
- data/lib/chef/resource/aws_vpc.rb +11 -11
- data/lib/chef/resource/aws_vpc_peering_connection.rb +4 -4
- data/spec/aws_support.rb +44 -45
- data/spec/aws_support/aws_resource_run_wrapper.rb +2 -2
- data/spec/aws_support/deep_matcher.rb +2 -3
- data/spec/aws_support/deep_matcher/fuzzy_match_objects.rb +6 -9
- data/spec/aws_support/deep_matcher/match_values_failure_messages.rb +30 -37
- data/spec/aws_support/deep_matcher/matchable_array.rb +0 -1
- data/spec/aws_support/deep_matcher/matchable_object.rb +1 -2
- data/spec/aws_support/deep_matcher/rspec_monkeypatches.rb +4 -4
- data/spec/aws_support/delayed_stream.rb +2 -2
- data/spec/aws_support/matchers/create_an_aws_object.rb +6 -6
- data/spec/aws_support/matchers/destroy_an_aws_object.rb +6 -6
- data/spec/aws_support/matchers/have_aws_object_tags.rb +4 -5
- data/spec/aws_support/matchers/match_an_aws_object.rb +5 -6
- data/spec/aws_support/matchers/update_an_aws_object.rb +6 -7
- data/spec/integration/aws_auto_scaling_group_spec.rb +56 -64
- data/spec/integration/aws_cache_cluster_spec.rb +70 -71
- data/spec/integration/aws_cache_subnet_group_spec.rb +13 -14
- data/spec/integration/aws_cloudsearch_domain_spec.rb +6 -8
- data/spec/integration/aws_cloudwatch_alarm_spec.rb +200 -208
- data/spec/integration/aws_dhcp_options_spec.rb +32 -43
- data/spec/integration/aws_ebs_volume_spec.rb +52 -73
- data/spec/integration/aws_eip_address_spec.rb +24 -31
- data/spec/integration/aws_elasticsearch_domain_spec.rb +31 -33
- data/spec/integration/aws_iam_instance_profile_spec.rb +36 -45
- data/spec/integration/aws_iam_role_spec.rb +39 -46
- data/spec/integration/aws_internet_gateway_spec.rb +64 -75
- data/spec/integration/aws_key_pair_spec.rb +6 -6
- data/spec/integration/aws_launch_configuration_spec.rb +17 -18
- data/spec/integration/aws_nat_gateway_spec.rb +21 -24
- data/spec/integration/aws_network_acl_spec.rb +81 -95
- data/spec/integration/aws_network_interface_spec.rb +28 -43
- data/spec/integration/aws_rds_instance_spec.rb +29 -40
- data/spec/integration/aws_rds_parameter_group_spec.rb +32 -35
- data/spec/integration/aws_rds_subnet_group_spec.rb +30 -40
- data/spec/integration/aws_route53_hosted_zone_spec.rb +205 -205
- data/spec/integration/aws_route_table_spec.rb +118 -136
- data/spec/integration/aws_s3_bucket_spec.rb +19 -27
- data/spec/integration/aws_security_group_spec.rb +369 -388
- data/spec/integration/aws_server_certificate_spec.rb +16 -18
- data/spec/integration/aws_subnet_spec.rb +44 -58
- data/spec/integration/aws_vpc_peering_connection_spec.rb +43 -50
- data/spec/integration/aws_vpc_spec.rb +99 -115
- data/spec/integration/load_balancer_spec.rb +169 -183
- data/spec/integration/machine_batch_spec.rb +24 -31
- data/spec/integration/machine_image_spec.rb +54 -66
- data/spec/integration/machine_spec.rb +216 -237
- data/spec/persistence_file.txt +219 -0
- data/spec/spec_helper.rb +16 -17
- data/spec/unit/chef/provisioning/aws_driver/credentials_spec.rb +67 -74
- data/spec/unit/chef/provisioning/aws_driver/driver_spec.rb +29 -29
- data/spec/unit/chef/provisioning/aws_driver/route53_spec.rb +13 -15
- metadata +4 -3
@@ -1,16 +1,14 @@
|
|
1
1
|
class Chef
|
2
|
-
module Provisioning
|
3
|
-
module AWSDriver
|
4
|
-
module Exceptions
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
module Provisioning
|
3
|
+
module AWSDriver
|
4
|
+
module Exceptions
|
5
|
+
class MultipleSecurityGroupError < RuntimeError
|
6
|
+
def initialize(name, groups)
|
7
|
+
super "Found security groups with ids [#{groups.map(&:id)}] that share name #{name}. " \
|
8
|
+
"Names are unique within VPCs - specify VPC to find by name."
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
14
|
end
|
@@ -1,77 +1,77 @@
|
|
1
|
-
require
|
1
|
+
require "chef/resource/lwrp_base"
|
2
2
|
|
3
3
|
class Chef
|
4
|
-
module Provisioning
|
5
|
-
module AWSDriver
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
4
|
+
module Provisioning
|
5
|
+
module AWSDriver
|
6
|
+
class SuperLWRP < Chef::Resource::LWRPBase
|
7
|
+
#
|
8
|
+
# Add the :default lazy { ... } and :coerce validation_opts to `attribute`
|
9
|
+
#
|
10
|
+
if respond_to?(:properties)
|
11
|
+
# in Chef 12.5+, properties replace attributes and these respond to
|
12
|
+
# coerce and default with a lazy block - no need for overwriting!
|
13
|
+
else
|
14
|
+
def self.attribute(attr_name, validation_opts = {})
|
15
|
+
if validation_opts[:default].is_a?(Chef::DelayedEvaluator)
|
16
|
+
lazy_default = validation_opts.delete(:default)
|
17
|
+
end
|
18
|
+
coerce = validation_opts.delete(:coerce)
|
19
|
+
if lazy_default || coerce
|
20
|
+
define_method(attr_name) do |arg = nil|
|
21
|
+
arg = instance_exec(arg, &coerce) if coerce && !arg.nil?
|
22
22
|
|
23
|
-
|
23
|
+
result = set_or_return(attr_name.to_sym, arg, validation_opts)
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
if result.nil? && arg.nil?
|
26
|
+
result = instance_eval(&lazy_default) if lazy_default
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
result
|
30
|
+
end
|
31
|
+
define_method(:"#{attr_name}=") do |arg|
|
32
|
+
if arg.nil?
|
33
|
+
remove_instance_variable(:"@#{arg}")
|
34
|
+
else
|
35
|
+
set_or_return(attr_name.to_sym, arg, validation_opts)
|
36
|
+
end
|
37
|
+
end
|
34
38
|
else
|
35
|
-
|
39
|
+
super
|
36
40
|
end
|
37
41
|
end
|
38
|
-
else
|
39
|
-
super
|
40
|
-
end
|
41
|
-
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# copy from Chef 12.5 params_validate.rb at http://redirx.me/?t35q.
|
50
|
-
if !method_defined?(:_pv_is)
|
51
|
-
def _pv_is(opts, key, to_be, raise_error: true)
|
52
|
-
return true if !opts.has_key?(key.to_s) && !opts.has_key?(key.to_sym)
|
53
|
-
value = _pv_opts_lookup(opts, key)
|
54
|
-
to_be = [ to_be ].flatten(1)
|
55
|
-
to_be.each do |tb|
|
56
|
-
case tb
|
57
|
-
when Proc
|
58
|
-
return true if instance_exec(value, &tb)
|
59
|
-
when Property
|
60
|
-
validate(opts, { key => tb.validation_options })
|
61
|
-
return true
|
62
|
-
else
|
63
|
-
return true if tb === value
|
43
|
+
# Below chef 12.5 you cannot do `default lazy: { ... }` - this adds that
|
44
|
+
def self.lazy(&block)
|
45
|
+
Chef::DelayedEvaluator.new(&block)
|
64
46
|
end
|
65
47
|
end
|
66
48
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
49
|
+
# copy from Chef 12.5 params_validate.rb at http://redirx.me/?t35q.
|
50
|
+
unless method_defined?(:_pv_is)
|
51
|
+
def _pv_is(opts, key, to_be, raise_error: true)
|
52
|
+
return true if !opts.key?(key.to_s) && !opts.key?(key.to_sym)
|
53
|
+
value = _pv_opts_lookup(opts, key)
|
54
|
+
to_be = [to_be].flatten(1)
|
55
|
+
to_be.each do |tb|
|
56
|
+
case tb
|
57
|
+
when Proc
|
58
|
+
return true if instance_exec(value, &tb)
|
59
|
+
when Property
|
60
|
+
validate(opts, key => tb.validation_options)
|
61
|
+
return true
|
62
|
+
else
|
63
|
+
return true if tb === value
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
if raise_error
|
68
|
+
raise ::Chef::Exceptions::ValidationFailed, "Option #{key} must be one of: #{to_be.join(', ')}! You passed #{value.inspect}."
|
69
|
+
else
|
70
|
+
false
|
71
|
+
end
|
72
|
+
end
|
71
73
|
end
|
72
74
|
end
|
73
75
|
end
|
74
76
|
end
|
75
77
|
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "chef/provisioning/aws_driver/aws_tagger"
|
2
2
|
|
3
3
|
module Chef::Provisioning::AWSDriver::TaggingStrategy
|
4
4
|
module AutoScalingConvergeTags
|
@@ -12,6 +12,7 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
|
|
12
12
|
Chef::Provisioning::AWSDriver::AWSTagger.new(auto_scaling_strategy, action_handler)
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
15
16
|
def converge_tags
|
16
17
|
aws_tagger.converge_tags
|
17
18
|
end
|
@@ -19,58 +20,56 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
|
|
19
20
|
end
|
20
21
|
|
21
22
|
module Chef::Provisioning::AWSDriver::TaggingStrategy
|
22
|
-
class AutoScaling
|
23
|
-
|
24
|
-
attr_reader :auto_scaling_client, :group_name, :desired_tags
|
23
|
+
class AutoScaling
|
24
|
+
attr_reader :auto_scaling_client, :group_name, :desired_tags
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
def initialize(auto_scaling_client, group_name, desired_tags)
|
27
|
+
@auto_scaling_client = auto_scaling_client
|
28
|
+
@group_name = group_name
|
29
|
+
@desired_tags = desired_tags
|
30
|
+
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
32
|
+
def current_tags
|
33
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#describe_tags-instance_method
|
34
|
+
resp = auto_scaling_client.describe_tags(
|
35
|
+
filters: [
|
36
|
+
{
|
37
|
+
name: "auto-scaling-group",
|
38
|
+
values: [group_name]
|
39
|
+
}
|
40
|
+
]
|
41
|
+
)
|
42
|
+
Hash[resp.tags.map { |t| [t.key, t.value] }]
|
43
|
+
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
45
|
+
def set_tags(tags)
|
46
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#create_or_update_tags-instance_method
|
47
|
+
auto_scaling_client.create_or_update_tags(
|
48
|
+
tags: tags.map do |k, v|
|
49
|
+
{
|
50
|
+
resource_id: group_name,
|
51
|
+
key: k,
|
52
|
+
value: v,
|
53
|
+
resource_type: "auto-scaling-group",
|
54
|
+
propagate_at_launch: false
|
55
|
+
}
|
56
|
+
end
|
57
|
+
)
|
58
|
+
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
60
|
+
def delete_tags(tag_keys)
|
61
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/AutoScaling/Client.html#delete_tags-instance_method
|
62
|
+
auto_scaling_client.delete_tags(
|
63
|
+
tags: tag_keys.map do |k|
|
64
|
+
{
|
65
|
+
resource_id: group_name,
|
66
|
+
key: k,
|
67
|
+
value: nil,
|
68
|
+
resource_type: "auto-scaling-group",
|
69
|
+
propagate_at_launch: false
|
70
|
+
}
|
71
|
+
end
|
72
|
+
)
|
73
|
+
end
|
73
74
|
end
|
74
|
-
|
75
|
-
end
|
76
75
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "chef/provisioning/aws_driver/aws_tagger"
|
2
2
|
|
3
3
|
module Chef::Provisioning::AWSDriver::TaggingStrategy
|
4
4
|
module EC2ConvergeTags
|
@@ -12,6 +12,7 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
|
|
12
12
|
Chef::Provisioning::AWSDriver::AWSTagger.new(ec2_strategy, action_handler)
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
15
16
|
def converge_tags
|
16
17
|
aws_tagger.converge_tags
|
17
18
|
end
|
@@ -19,46 +20,44 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
|
|
19
20
|
end
|
20
21
|
|
21
22
|
module Chef::Provisioning::AWSDriver::TaggingStrategy
|
22
|
-
class EC2
|
23
|
-
|
24
|
-
attr_reader :ec2_client, :aws_object_id, :desired_tags
|
23
|
+
class EC2
|
24
|
+
attr_reader :ec2_client, :aws_object_id, :desired_tags
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
def initialize(ec2_client, aws_object_id, desired_tags)
|
27
|
+
@ec2_client = ec2_client
|
28
|
+
@aws_object_id = aws_object_id
|
29
|
+
@desired_tags = desired_tags
|
30
|
+
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
32
|
+
def current_tags
|
33
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#describe_tags-instance_method
|
34
|
+
resp = ec2_client.describe_tags(
|
35
|
+
filters: [
|
36
|
+
{
|
37
|
+
name: "resource-id",
|
38
|
+
values: [aws_object_id]
|
39
|
+
}
|
40
|
+
]
|
41
|
+
)
|
42
|
+
Hash[resp.tags.map { |t| [t.key, t.value] }]
|
43
|
+
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
def set_tags(tags)
|
46
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#create_tags-instance_method
|
47
|
+
# "The value parameter is required, but if you don't want the tag to have a value, specify
|
48
|
+
# the parameter with no value, and we set the value to an empty string."
|
49
|
+
ec2_client.create_tags(
|
50
|
+
resources: [aws_object_id],
|
51
|
+
tags: tags.map { |k, v| { key: k, value: v } }
|
52
|
+
)
|
53
|
+
end
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
def delete_tags(tag_keys)
|
56
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Client.html#delete_tags-instance_method
|
57
|
+
ec2_client.delete_tags(
|
58
|
+
resources: [aws_object_id],
|
59
|
+
tags: tag_keys.map { |k| { key: k } }
|
60
|
+
)
|
61
|
+
end
|
61
62
|
end
|
62
|
-
|
63
|
-
end
|
64
63
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "chef/provisioning/aws_driver/aws_tagger"
|
2
2
|
|
3
3
|
module Chef::Provisioning::AWSDriver::TaggingStrategy
|
4
4
|
class Elasticsearch
|
5
|
-
|
6
5
|
attr_reader :client, :arn, :desired_tags
|
7
6
|
|
8
7
|
def initialize(client, arn, desired_tags)
|
@@ -12,29 +11,29 @@ module Chef::Provisioning::AWSDriver::TaggingStrategy
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def current_tags
|
15
|
-
resp = client.list_tags(
|
16
|
-
Hash[resp.tag_list.map {|t| [t.key, t.value]}]
|
14
|
+
resp = client.list_tags(arn: arn)
|
15
|
+
Hash[resp.tag_list.map { |t| [t.key, t.value] }]
|
17
16
|
rescue ::Aws::ElasticsearchService::Errors::ResourceNotFoundException
|
18
|
-
|
17
|
+
{}
|
19
18
|
end
|
20
19
|
|
21
20
|
def set_tags(tags)
|
22
|
-
tags = tags.map
|
21
|
+
tags = tags.map do |k, v|
|
23
22
|
if v.nil?
|
24
|
-
{key: k}
|
23
|
+
{ key: k }
|
25
24
|
else
|
26
|
-
{key: k, value: v}
|
25
|
+
{ key: k, value: v }
|
27
26
|
end
|
28
|
-
|
29
|
-
client.add_tags(
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
end
|
28
|
+
client.add_tags(
|
29
|
+
arn: arn,
|
30
|
+
tag_list: tags
|
31
|
+
)
|
33
32
|
end
|
34
33
|
|
35
34
|
def delete_tags(tag_keys)
|
36
|
-
client.remove_tags(
|
37
|
-
|
35
|
+
client.remove_tags(arn: arn,
|
36
|
+
tag_keys: tag_keys)
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
@@ -1,39 +1,37 @@
|
|
1
|
-
require
|
1
|
+
require "chef/provisioning/aws_driver/aws_tagger"
|
2
2
|
|
3
3
|
module Chef::Provisioning::AWSDriver::TaggingStrategy
|
4
|
-
class ELB
|
4
|
+
class ELB
|
5
|
+
attr_reader :elb_client, :access_point_name, :desired_tags
|
5
6
|
|
6
|
-
|
7
|
+
def initialize(elb_client, access_point_name, desired_tags)
|
8
|
+
@elb_client = elb_client
|
9
|
+
@access_point_name = access_point_name
|
10
|
+
@desired_tags = desired_tags
|
11
|
+
end
|
7
12
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
# http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#describe_tags-instance_method
|
16
|
-
resp = elb_client.describe_tags({
|
17
|
-
load_balancer_names: [access_point_name]
|
18
|
-
})
|
19
|
-
Hash[resp.tag_descriptions[0].tags.map {|t| [t.key, t.value]}]
|
20
|
-
end
|
13
|
+
def current_tags
|
14
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#describe_tags-instance_method
|
15
|
+
resp = elb_client.describe_tags(
|
16
|
+
load_balancer_names: [access_point_name]
|
17
|
+
)
|
18
|
+
Hash[resp.tag_descriptions[0].tags.map { |t| [t.key, t.value] }]
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
def set_tags(tags)
|
22
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#add_tags-instance_method
|
23
|
+
elb_client.add_tags(
|
24
|
+
load_balancer_names: [access_point_name],
|
25
|
+
tags: tags.map { |k, v| { key: k, value: v } }
|
26
|
+
)
|
27
|
+
end
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
def delete_tags(tag_keys)
|
30
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#remove_tags-instance_method
|
31
|
+
elb_client.remove_tags(
|
32
|
+
load_balancer_names: [access_point_name],
|
33
|
+
tags: tag_keys.map { |k| { key: k } }
|
34
|
+
)
|
35
|
+
end
|
36
36
|
end
|
37
|
-
|
38
|
-
end
|
39
37
|
end
|