chef-provisioning-aws 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +70 -69
- data/Rakefile +22 -2
- data/lib/chef/provider/aws_auto_scaling_group.rb +3 -2
- data/lib/chef/provider/aws_cache_cluster.rb +3 -2
- data/lib/chef/provider/aws_cache_replication_group.rb +5 -4
- data/lib/chef/provider/aws_cache_subnet_group.rb +5 -4
- data/lib/chef/provider/aws_cloudsearch_domain.rb +163 -0
- data/lib/chef/provider/aws_dhcp_options.rb +9 -6
- data/lib/chef/provider/aws_ebs_volume.rb +7 -3
- data/lib/chef/provider/aws_eip_address.rb +8 -7
- data/lib/chef/provider/aws_image.rb +8 -3
- data/lib/chef/provider/aws_instance.rb +14 -2
- data/lib/chef/provider/aws_key_pair.rb +2 -1
- data/lib/chef/provider/aws_launch_configuration.rb +4 -2
- data/lib/chef/provider/aws_load_balancer.rb +18 -0
- data/lib/chef/provider/aws_network_acl.rb +6 -2
- data/lib/chef/provider/aws_network_interface.rb +11 -24
- data/lib/chef/provider/aws_rds_instance.rb +66 -0
- data/lib/chef/provider/aws_rds_subnet_group.rb +89 -0
- data/lib/chef/provider/aws_route_table.rb +42 -23
- data/lib/chef/provider/aws_s3_bucket.rb +32 -8
- data/lib/chef/provider/aws_security_group.rb +11 -4
- data/lib/chef/provider/aws_server_certificate.rb +23 -0
- data/lib/chef/provider/aws_sns_topic.rb +4 -3
- data/lib/chef/provider/aws_sqs_queue.rb +3 -2
- data/lib/chef/provider/aws_subnet.rb +10 -7
- data/lib/chef/provider/aws_vpc.rb +54 -21
- data/lib/chef/provider/aws_vpc_peering_connection.rb +88 -0
- data/lib/chef/provisioning/aws_driver.rb +8 -0
- data/lib/chef/provisioning/aws_driver/aws_provider.rb +45 -76
- data/lib/chef/provisioning/aws_driver/aws_rds_resource.rb +11 -0
- data/lib/chef/provisioning/aws_driver/aws_resource.rb +14 -2
- data/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb +2 -8
- data/lib/chef/provisioning/aws_driver/aws_taggable.rb +18 -0
- data/lib/chef/provisioning/aws_driver/aws_tagger.rb +61 -0
- data/lib/chef/provisioning/aws_driver/credentials2.rb +51 -0
- data/lib/chef/provisioning/aws_driver/driver.rb +214 -162
- data/lib/chef/provisioning/aws_driver/tagging_strategy/ec2.rb +64 -0
- data/lib/chef/provisioning/aws_driver/tagging_strategy/elb.rb +39 -0
- data/lib/chef/provisioning/aws_driver/tagging_strategy/rds.rb +92 -0
- data/lib/chef/provisioning/aws_driver/tagging_strategy/s3.rb +41 -0
- data/lib/chef/provisioning/aws_driver/version.rb +1 -1
- data/lib/chef/resource/aws_cache_cluster.rb +1 -2
- data/lib/chef/resource/aws_cloudsearch_domain.rb +46 -0
- data/lib/chef/resource/aws_dhcp_options.rb +2 -0
- data/lib/chef/resource/aws_ebs_volume.rb +3 -1
- data/lib/chef/resource/aws_eip_address.rb +0 -3
- data/lib/chef/resource/aws_image.rb +3 -0
- data/lib/chef/resource/aws_instance.rb +7 -2
- data/lib/chef/resource/aws_internet_gateway.rb +2 -0
- data/lib/chef/resource/aws_load_balancer.rb +3 -0
- data/lib/chef/resource/aws_network_acl.rb +2 -0
- data/lib/chef/resource/aws_network_interface.rb +3 -1
- data/lib/chef/resource/aws_rds_instance.rb +42 -0
- data/lib/chef/resource/aws_rds_subnet_group.rb +29 -0
- data/lib/chef/resource/aws_route_table.rb +7 -5
- data/lib/chef/resource/aws_s3_bucket.rb +3 -0
- data/lib/chef/resource/aws_security_group.rb +2 -7
- data/lib/chef/resource/aws_server_certificate.rb +21 -0
- data/lib/chef/resource/aws_subnet.rb +2 -0
- data/lib/chef/resource/aws_vpc.rb +4 -1
- data/lib/chef/resource/aws_vpc_peering_connection.rb +73 -0
- data/spec/acceptance/aws_ebs_volume/nodes/ettores-mbp.lan.json +3 -0
- data/spec/aws_support.rb +25 -8
- data/spec/aws_support/aws_resource_run_wrapper.rb +5 -1
- data/spec/aws_support/deep_matcher/match_values_failure_messages.rb +19 -0
- data/spec/aws_support/matchers/create_an_aws_object.rb +1 -1
- data/spec/aws_support/matchers/destroy_an_aws_object.rb +1 -1
- data/spec/aws_support/matchers/have_aws_object_tags.rb +9 -15
- data/spec/aws_support/matchers/match_an_aws_object.rb +1 -1
- data/spec/aws_support/matchers/update_an_aws_object.rb +1 -1
- data/spec/integration/aws_cloudsearch_domain_spec.rb +31 -0
- data/spec/integration/aws_dhcp_options_spec.rb +73 -0
- data/spec/integration/aws_ebs_volume_spec.rb +97 -0
- data/spec/integration/aws_network_acl_spec.rb +51 -0
- data/spec/integration/aws_network_interface_spec.rb +89 -0
- data/spec/integration/aws_rds_instance_spec.rb +150 -0
- data/spec/integration/aws_rds_subnet_group_spec.rb +105 -0
- data/spec/integration/aws_route_table_spec.rb +94 -7
- data/spec/integration/aws_s3_bucket_spec.rb +88 -0
- data/spec/integration/aws_security_group_spec.rb +47 -0
- data/spec/integration/aws_server_certificate_spec.rb +24 -0
- data/spec/integration/aws_subnet_spec.rb +51 -2
- data/spec/integration/aws_vpc_peering_connection_spec.rb +99 -0
- data/spec/integration/aws_vpc_spec.rb +73 -0
- data/spec/integration/load_balancer_spec.rb +101 -0
- data/spec/integration/machine_image_spec.rb +61 -6
- data/spec/integration/machine_spec.rb +26 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/unit/{aws_driver → chef/provisioning/aws_driver}/credentials_spec.rb +0 -0
- data/spec/unit/chef/provisioning/aws_driver/driver_spec.rb +88 -0
- metadata +63 -20
- data/spec/integration/aws_tagged_items_spec.rb +0 -166
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'chef/provisioning/aws_driver/aws_tagger'
|
2
|
+
|
3
|
+
module Chef::Provisioning::AWSDriver::TaggingStrategy
|
4
|
+
module EC2ConvergeTags
|
5
|
+
def aws_tagger
|
6
|
+
@aws_tagger ||= begin
|
7
|
+
ec2_strategy = Chef::Provisioning::AWSDriver::TaggingStrategy::EC2.new(
|
8
|
+
new_resource.driver.ec2_client,
|
9
|
+
new_resource.aws_object_id,
|
10
|
+
new_resource.aws_tags
|
11
|
+
)
|
12
|
+
Chef::Provisioning::AWSDriver::AWSTagger.new(ec2_strategy, action_handler)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
def converge_tags
|
16
|
+
aws_tagger.converge_tags
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module Chef::Provisioning::AWSDriver::TaggingStrategy
|
22
|
+
class EC2
|
23
|
+
|
24
|
+
attr_reader :ec2_client, :aws_object_id, :desired_tags
|
25
|
+
|
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
|
+
|
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
|
+
|
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
|
+
|
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
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'chef/provisioning/aws_driver/aws_tagger'
|
2
|
+
|
3
|
+
module Chef::Provisioning::AWSDriver::TaggingStrategy
|
4
|
+
class ELB
|
5
|
+
|
6
|
+
attr_reader :elb_client, :access_point_name, :desired_tags
|
7
|
+
|
8
|
+
def initialize(elb_client, access_point_name, desired_tags)
|
9
|
+
@elb_client = elb_client
|
10
|
+
@access_point_name = access_point_name
|
11
|
+
@desired_tags = desired_tags
|
12
|
+
end
|
13
|
+
|
14
|
+
def current_tags
|
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
|
21
|
+
|
22
|
+
def set_tags(tags)
|
23
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#add_tags-instance_method
|
24
|
+
elb_client.add_tags({
|
25
|
+
load_balancer_names: [access_point_name],
|
26
|
+
tags: tags.map {|k,v| {key: k, value: v} }
|
27
|
+
})
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete_tags(tag_keys)
|
31
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/ElasticLoadBalancing/Client.html#remove_tags-instance_method
|
32
|
+
elb_client.remove_tags({
|
33
|
+
load_balancer_names: [access_point_name],
|
34
|
+
tags: tag_keys.map {|k| {key: k} }
|
35
|
+
})
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'chef/provisioning/aws_driver/aws_tagger'
|
2
|
+
|
3
|
+
####################
|
4
|
+
# NOTE FROM http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html
|
5
|
+
# "Note that tags are cached for authorization purposes. Because of this, additions
|
6
|
+
# and updates to tags on Amazon RDS resources may take several minutes before they
|
7
|
+
# are available."
|
8
|
+
####################
|
9
|
+
|
10
|
+
module Chef::Provisioning::AWSDriver::TaggingStrategy
|
11
|
+
module RDSConvergeTags
|
12
|
+
def aws_tagger
|
13
|
+
@aws_tagger ||= begin
|
14
|
+
rds_strategy = Chef::Provisioning::AWSDriver::TaggingStrategy::RDS.new(
|
15
|
+
new_resource.driver.rds.client,
|
16
|
+
construct_arn(new_resource),
|
17
|
+
new_resource.aws_tags
|
18
|
+
)
|
19
|
+
Chef::Provisioning::AWSDriver::AWSTagger.new(rds_strategy, action_handler)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def converge_tags
|
23
|
+
aws_tagger.converge_tags
|
24
|
+
end
|
25
|
+
|
26
|
+
# http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Tagging.html#USER_Tagging.ARN
|
27
|
+
def construct_arn(new_resource)
|
28
|
+
@arn ||= begin
|
29
|
+
region = new_resource.driver.aws_config.region
|
30
|
+
name = new_resource.name
|
31
|
+
rds_type = new_resource.rds_tagging_type
|
32
|
+
# Taken from example on https://forums.aws.amazon.com/thread.jspa?threadID=108012
|
33
|
+
account_id = begin
|
34
|
+
u = new_resource.driver.iam.client.get_user
|
35
|
+
# We've got an AWS account root credential or an IAM admin with access rights
|
36
|
+
u[:user][:arn].match('^arn:aws:iam::([0-9]{12}):.*$')[1]
|
37
|
+
rescue AWS::IAM::Errors::AccessDenied => e
|
38
|
+
# We've got an AWS IAM Credential
|
39
|
+
e.to_s.match('^User: arn:aws:iam::([0-9]{12}):.*$')[1]
|
40
|
+
end
|
41
|
+
# arn:aws:rds:<region>:<account number>:<resourcetype>:<name>
|
42
|
+
"arn:aws:rds:#{region}:#{account_id}:#{rds_type}:#{name}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module Chef::Provisioning::AWSDriver::TaggingStrategy
|
49
|
+
class RDS
|
50
|
+
|
51
|
+
attr_reader :rds_client, :rds_object_arn, :desired_tags
|
52
|
+
|
53
|
+
def initialize(rds_client, rds_object_arn, desired_tags)
|
54
|
+
@rds_client = rds_client
|
55
|
+
@rds_object_arn = rds_object_arn
|
56
|
+
@desired_tags = desired_tags
|
57
|
+
end
|
58
|
+
|
59
|
+
def current_tags
|
60
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#list_tags_for_resource-instance_method
|
61
|
+
resp = rds_client.list_tags_for_resource({
|
62
|
+
resource_name: rds_object_arn
|
63
|
+
})
|
64
|
+
Hash[resp.tag_list.map {|t| [t.key, t.value]}]
|
65
|
+
end
|
66
|
+
|
67
|
+
def set_tags(tags)
|
68
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#add_tags_to_resource-instance_method
|
69
|
+
# Unlike EC2, RDS tags can have a nil value
|
70
|
+
tags = tags.map {|k,v|
|
71
|
+
if v.nil?
|
72
|
+
{key: k}
|
73
|
+
else
|
74
|
+
{key: k, value: v}
|
75
|
+
end
|
76
|
+
}
|
77
|
+
rds_client.add_tags_to_resource({
|
78
|
+
resource_name: rds_object_arn,
|
79
|
+
tags: tags
|
80
|
+
})
|
81
|
+
end
|
82
|
+
|
83
|
+
def delete_tags(tag_keys)
|
84
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/RDS/Client.html#remove_tags_from_resource-instance_method
|
85
|
+
rds_client.remove_tags_from_resource({
|
86
|
+
resource_name: rds_object_arn,
|
87
|
+
tag_keys: tag_keys
|
88
|
+
})
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'chef/provisioning/aws_driver/aws_tagger'
|
2
|
+
module Chef::Provisioning::AWSDriver::TaggingStrategy
|
3
|
+
class S3
|
4
|
+
|
5
|
+
attr_reader :s3_client, :bucket_name, :desired_tags
|
6
|
+
|
7
|
+
def initialize(s3_client, bucket_name, desired_tags)
|
8
|
+
@s3_client = s3_client
|
9
|
+
@bucket_name = bucket_name
|
10
|
+
@desired_tags = desired_tags
|
11
|
+
end
|
12
|
+
|
13
|
+
def current_tags
|
14
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#get_bucket_tagging-instance_method
|
15
|
+
resp = s3_client.get_bucket_tagging({
|
16
|
+
bucket: bucket_name
|
17
|
+
})
|
18
|
+
Hash[resp.tag_set.map {|t| [t.key, t.value]}]
|
19
|
+
rescue Aws::S3::Errors::NoSuchTagSet => e
|
20
|
+
# Instead of returning nil or empty, AWS raises an error :)
|
21
|
+
{}
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_tags(tags)
|
25
|
+
# http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Client.html#put_bucket_tagging-instance_method
|
26
|
+
s3_client.put_bucket_tagging({
|
27
|
+
bucket: bucket_name,
|
28
|
+
tagging: {
|
29
|
+
tag_set: tags.map {|k,v| {key: k, value: v} }
|
30
|
+
}
|
31
|
+
})
|
32
|
+
end
|
33
|
+
|
34
|
+
def delete_tags(tag_keys)
|
35
|
+
# S3 doesn't have a client action for deleting individual tags, just ALL tags. But the
|
36
|
+
# put_bucket_tagging method will set the tags to what is provided so we don't need to
|
37
|
+
# worry about this
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -13,7 +13,6 @@ class Chef::Resource::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSResour
|
|
13
13
|
# straight through to AWS, with the exception of security_groups, which
|
14
14
|
# may contain a reference to a Chef aws_security_group resource.
|
15
15
|
|
16
|
-
|
17
16
|
# Cluster Name
|
18
17
|
#
|
19
18
|
# @param :cluster_name [String] unique name for a cluster
|
@@ -54,7 +53,7 @@ class Chef::Resource::AwsCacheCluster < Chef::Provisioning::AWSDriver::AWSResour
|
|
54
53
|
|
55
54
|
# Engine Version
|
56
55
|
#
|
57
|
-
# @param :engine_version [String] The version number of the cache engine to be used for this cache cluster.
|
56
|
+
# @param :engine_version [String] The version number of the cache engine to be used for this cache cluster.
|
58
57
|
attribute :engine_version, kind_of: String, required: true
|
59
58
|
|
60
59
|
# Subnet Group Name
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'chef/provisioning/aws_driver/aws_resource'
|
2
|
+
|
3
|
+
module AWS
|
4
|
+
class CloudSearch
|
5
|
+
class Domain
|
6
|
+
# The version of the AWS sdk we are using doesn't have a model
|
7
|
+
# object for CloudSearch Domains. This empty class is here to
|
8
|
+
# make the reset of chef-provisioning happy.
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Chef::Resource::AwsCloudsearchDomain < Chef::Provisioning::AWSDriver::AWSResource
|
14
|
+
aws_sdk_type ::AWS::CloudSearch::Domain
|
15
|
+
attribute :name, kind_of: String, name_attribute: true
|
16
|
+
attribute :cloudsearch_api_version, equal_to: ["20130101", "20110201"], default: "20130101"
|
17
|
+
|
18
|
+
# Availability Options
|
19
|
+
attribute :multi_az, kind_of: [TrueClass, FalseClass], default: false
|
20
|
+
|
21
|
+
# Scaling Parameters
|
22
|
+
attribute :instance_type, equal_to: ["search.m1.small", "search.m3.medium",
|
23
|
+
"search.m3.large", "search.m3.xlarge",
|
24
|
+
"search.m3.2xlarge"]
|
25
|
+
attribute :partition_count, kind_of: Integer
|
26
|
+
attribute :replication_count, kind_of: Integer
|
27
|
+
|
28
|
+
# Service Access Policies
|
29
|
+
# TODO(ssd): We need to decide how we want to model access policies
|
30
|
+
# For now we just allow the user to shove the policy in via a string.
|
31
|
+
attribute :access_policies, kind_of: String
|
32
|
+
|
33
|
+
|
34
|
+
# Indexing Options
|
35
|
+
# TODO(ssd): Like Access Polcies, we should decide
|
36
|
+
# whether we want a DSL for defining index fields, or just allow the
|
37
|
+
# user to pass in an array properly formated hash.
|
38
|
+
attribute :index_fields, kind_of: Array
|
39
|
+
|
40
|
+
# None of the cloudsearch objects actually have instance-specific
|
41
|
+
# objects in the version of the AWS API we are using. This will
|
42
|
+
# return a hash with some relevant information about the domain.
|
43
|
+
def aws_object
|
44
|
+
driver.cloudsearch.describe_domains(domain_names: [name])[:domain_status_list].find {|d| !d[:deleted] }
|
45
|
+
end
|
46
|
+
end
|
@@ -11,6 +11,8 @@ require 'chef/provisioning/aws_driver/aws_resource_with_entry'
|
|
11
11
|
# - http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_DHCP_Options.html
|
12
12
|
#
|
13
13
|
class Chef::Resource::AwsDhcpOptions < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
|
14
|
+
include Chef::Provisioning::AWSDriver::AWSTaggable
|
15
|
+
|
14
16
|
aws_sdk_type AWS::EC2::DHCPOptions
|
15
17
|
|
16
18
|
#
|
@@ -2,11 +2,13 @@ require 'chef/provisioning/aws_driver/aws_resource_with_entry'
|
|
2
2
|
require 'chef/resource/aws_instance'
|
3
3
|
|
4
4
|
class Chef::Resource::AwsEbsVolume < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
|
5
|
+
include Chef::Provisioning::AWSDriver::AWSTaggable
|
6
|
+
|
5
7
|
aws_sdk_type AWS::EC2::Volume, backcompat_data_bag_name: 'ebs_volumes'
|
6
8
|
|
7
9
|
attribute :name, kind_of: String, name_attribute: true
|
8
10
|
|
9
|
-
attribute :machine, kind_of: [ String, FalseClass, AwsInstance, AWS::EC2::Instance ]
|
11
|
+
attribute :machine, kind_of: [ String, FalseClass, AwsInstance, AWS::EC2::Instance, ::Aws::EC2::Instance ]
|
10
12
|
|
11
13
|
attribute :availability_zone, kind_of: String, default: 'a'
|
12
14
|
attribute :size, kind_of: Integer, default: 8
|
@@ -6,9 +6,6 @@ class Chef::Resource::AwsEipAddress < Chef::Provisioning::AWSDriver::AWSResource
|
|
6
6
|
|
7
7
|
attribute :name, kind_of: String, name_attribute: true
|
8
8
|
|
9
|
-
# guh - every other AWSResourceWithEntry accepts tags EXCEPT this one
|
10
|
-
undef_method(:aws_tags)
|
11
|
-
|
12
9
|
# TODO network interface
|
13
10
|
attribute :machine, kind_of: [String, FalseClass]
|
14
11
|
attribute :associate_to_vpc, kind_of: [TrueClass, FalseClass]
|
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'chef/provisioning/aws_driver/aws_resource_with_entry'
|
2
|
+
require 'chef/provisioning/aws_driver/aws_taggable'
|
2
3
|
|
3
4
|
class Chef::Resource::AwsImage < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
|
5
|
+
include Chef::Provisioning::AWSDriver::AWSTaggable
|
6
|
+
|
4
7
|
aws_sdk_type AWS::EC2::Image,
|
5
8
|
managed_entry_type: :machine_image,
|
6
9
|
managed_entry_id_name: 'image_id'
|
@@ -1,7 +1,12 @@
|
|
1
1
|
require 'chef/provisioning/aws_driver/aws_resource_with_entry'
|
2
|
+
require 'chef/provisioning/aws_driver/aws_taggable'
|
2
3
|
|
3
4
|
class Chef::Resource::AwsInstance < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
|
4
|
-
|
5
|
+
include Chef::Provisioning::AWSDriver::AWSTaggable
|
6
|
+
|
7
|
+
# The require needs to be inside this class otherwise it gets loaded before the rest of the SDK
|
8
|
+
# and starts causing issues - AWS expects to load all this stuff itself
|
9
|
+
aws_sdk_type ::Aws::EC2::Instance,
|
5
10
|
managed_entry_type: :machine,
|
6
11
|
managed_entry_id_name: 'instance_id'
|
7
12
|
|
@@ -13,7 +18,7 @@ class Chef::Resource::AwsInstance < Chef::Provisioning::AWSDriver::AWSResourceWi
|
|
13
18
|
|
14
19
|
def aws_object
|
15
20
|
driver, id = get_driver_and_id
|
16
|
-
result = driver.
|
21
|
+
result = driver.ec2_resource.instance(id) if id
|
17
22
|
result && result.exists? ? result : nil
|
18
23
|
end
|
19
24
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'chef/provisioning/aws_driver/aws_resource'
|
2
2
|
|
3
3
|
class Chef::Resource::AwsInternetGateway < Chef::Provisioning::AWSDriver::AWSResource
|
4
|
+
include Chef::Provisioning::AWSDriver::AWSTaggable
|
5
|
+
|
4
6
|
aws_sdk_type AWS::EC2::InternetGateway, load_provider: false, id: :id
|
5
7
|
|
6
8
|
attribute :name, kind_of: String, name_attribute: true
|
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'chef/provisioning/aws_driver/aws_resource'
|
2
|
+
require 'chef/provisioning/aws_driver/aws_taggable'
|
2
3
|
|
3
4
|
class Chef::Resource::AwsLoadBalancer < Chef::Provisioning::AWSDriver::AWSResource
|
5
|
+
include Chef::Provisioning::AWSDriver::AWSTaggable
|
6
|
+
|
4
7
|
aws_sdk_type AWS::ELB::LoadBalancer
|
5
8
|
|
6
9
|
attribute :name, kind_of: String, name_attribute: true
|
@@ -3,6 +3,8 @@ require 'chef/resource/aws_subnet'
|
|
3
3
|
require 'chef/resource/aws_eip_address'
|
4
4
|
|
5
5
|
class Chef::Resource::AwsNetworkInterface < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
|
6
|
+
include Chef::Provisioning::AWSDriver::AWSTaggable
|
7
|
+
|
6
8
|
aws_sdk_type AWS::EC2::NetworkInterface
|
7
9
|
|
8
10
|
attribute :name, kind_of: String, name_attribute: true
|
@@ -19,7 +21,7 @@ class Chef::Resource::AwsNetworkInterface < Chef::Provisioning::AWSDriver::AWSRe
|
|
19
21
|
|
20
22
|
attribute :security_groups, kind_of: Array #(Array<SecurityGroup>, Array<String>)
|
21
23
|
|
22
|
-
attribute :machine, kind_of: [ String, FalseClass, AwsInstance, AWS::EC2::Instance ]
|
24
|
+
attribute :machine, kind_of: [ String, FalseClass, AwsInstance, AWS::EC2::Instance, ::Aws::EC2::Instance ]
|
23
25
|
|
24
26
|
attribute :device_index, kind_of: Integer
|
25
27
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'chef/provisioning/aws_driver/aws_rds_resource'
|
2
|
+
require 'chef/provisioning/aws_driver/aws_taggable'
|
3
|
+
|
4
|
+
class Chef::Resource::AwsRdsInstance < Chef::Provisioning::AWSDriver::AWSRDSResource
|
5
|
+
include Chef::Provisioning::AWSDriver::AWSTaggable
|
6
|
+
|
7
|
+
aws_sdk_type AWS::RDS::DBInstance, id: :db_instance_identifier
|
8
|
+
|
9
|
+
attribute :db_instance_identifier, kind_of: String, name_attribute: true
|
10
|
+
|
11
|
+
attribute :engine, kind_of: String
|
12
|
+
attribute :engine_version, kind_of: String
|
13
|
+
attribute :db_instance_class, kind_of: String
|
14
|
+
attribute :multi_az, default: false, kind_of: [TrueClass, FalseClass]
|
15
|
+
attribute :allocated_storage, kind_of: Integer
|
16
|
+
attribute :iops, kind_of: Integer
|
17
|
+
attribute :publicly_accessible, kind_of: [TrueClass, FalseClass], default: false
|
18
|
+
attribute :master_username, kind_of: String
|
19
|
+
attribute :master_user_password, kind_of: String
|
20
|
+
attribute :db_name, kind_of: String
|
21
|
+
attribute :port, kind_of: Integer
|
22
|
+
# We cannot pass the resource or an AWS object because there is no AWS model
|
23
|
+
# and that causes lookup_options to fail
|
24
|
+
attribute :db_subnet_group_name, kind_of: String
|
25
|
+
|
26
|
+
# RDS has a ton of options, allow users to set any of them via a
|
27
|
+
# custom Hash
|
28
|
+
attribute :additional_options, kind_of: Hash, default: {}
|
29
|
+
|
30
|
+
def aws_object
|
31
|
+
res = driver.rds.instances[name]
|
32
|
+
if res.exists? && ! ['deleted', 'deleting'].include?(res.status)
|
33
|
+
res
|
34
|
+
else
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def rds_tagging_type
|
40
|
+
"db"
|
41
|
+
end
|
42
|
+
end
|