chef-provisioning-aws 0.4.0 → 0.5.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +2 -0
  3. data/lib/chef/provider/aws_auto_scaling_group.rb +30 -41
  4. data/lib/chef/provider/aws_dhcp_options.rb +70 -0
  5. data/lib/chef/provider/aws_ebs_volume.rb +182 -34
  6. data/lib/chef/provider/aws_eip_address.rb +63 -60
  7. data/lib/chef/provider/aws_key_pair.rb +18 -27
  8. data/lib/chef/provider/aws_launch_configuration.rb +50 -0
  9. data/lib/chef/provider/aws_route_table.rb +122 -0
  10. data/lib/chef/provider/aws_s3_bucket.rb +42 -49
  11. data/lib/chef/provider/aws_security_group.rb +252 -59
  12. data/lib/chef/provider/aws_sns_topic.rb +10 -26
  13. data/lib/chef/provider/aws_sqs_queue.rb +16 -38
  14. data/lib/chef/provider/aws_subnet.rb +85 -32
  15. data/lib/chef/provider/aws_vpc.rb +163 -23
  16. data/lib/chef/provisioning/aws_driver.rb +18 -1
  17. data/lib/chef/provisioning/aws_driver/aws_provider.rb +206 -0
  18. data/lib/chef/provisioning/aws_driver/aws_resource.rb +186 -0
  19. data/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb +114 -0
  20. data/lib/chef/provisioning/aws_driver/driver.rb +317 -255
  21. data/lib/chef/provisioning/aws_driver/resources.rb +8 -5
  22. data/lib/chef/provisioning/aws_driver/super_lwrp.rb +45 -0
  23. data/lib/chef/provisioning/aws_driver/version.rb +1 -1
  24. data/lib/chef/resource/aws_auto_scaling_group.rb +15 -13
  25. data/lib/chef/resource/aws_dhcp_options.rb +57 -0
  26. data/lib/chef/resource/aws_ebs_volume.rb +20 -22
  27. data/lib/chef/resource/aws_eip_address.rb +50 -25
  28. data/lib/chef/resource/aws_image.rb +20 -0
  29. data/lib/chef/resource/aws_instance.rb +20 -0
  30. data/lib/chef/resource/aws_internet_gateway.rb +16 -0
  31. data/lib/chef/resource/aws_key_pair.rb +6 -10
  32. data/lib/chef/resource/aws_launch_configuration.rb +15 -0
  33. data/lib/chef/resource/aws_load_balancer.rb +16 -0
  34. data/lib/chef/resource/aws_network_interface.rb +16 -0
  35. data/lib/chef/resource/aws_route_table.rb +76 -0
  36. data/lib/chef/resource/aws_s3_bucket.rb +8 -18
  37. data/lib/chef/resource/aws_security_group.rb +49 -19
  38. data/lib/chef/resource/aws_sns_topic.rb +14 -15
  39. data/lib/chef/resource/aws_sqs_queue.rb +16 -14
  40. data/lib/chef/resource/aws_subnet.rb +87 -17
  41. data/lib/chef/resource/aws_vpc.rb +137 -15
  42. data/spec/integration/aws_security_group_spec.rb +55 -0
  43. data/spec/spec_helper.rb +8 -2
  44. data/spec/support/aws_support.rb +211 -0
  45. metadata +33 -10
  46. data/lib/chef/provider/aws_launch_config.rb +0 -43
  47. data/lib/chef/provider/aws_provider.rb +0 -22
  48. data/lib/chef/provisioning/aws_driver/aws_profile.rb +0 -73
  49. data/lib/chef/resource/aws_launch_config.rb +0 -14
  50. data/lib/chef/resource/aws_resource.rb +0 -10
  51. data/spec/chef_zero_rspec_helper.rb +0 -8
  52. data/spec/unit/provider/aws_subnet_spec.rb +0 -67
  53. data/spec/unit/resource/aws_subnet_spec.rb +0 -23
@@ -1,7 +1,10 @@
1
- resources = %w(sqs_queue sns_topic ebs_volume s3_bucket auto_scaling_group launch_config vpc security_group eip_address subnet)
1
+ # Module under which all AWS resources live
2
2
 
3
- resources.each do |r|
4
- Chef::Log.debug "AWS driver loading resource: #{r}"
5
- require "chef/resource/aws_#{r}"
6
- require "chef/provider/aws_#{r}"
3
+ class Chef
4
+ module Provisioning
5
+ module AWSDriver
6
+ module Resources
7
+ end
8
+ end
9
+ end
7
10
  end
@@ -0,0 +1,45 @@
1
+ require 'chef/resource/lwrp_base'
2
+
3
+ class Chef
4
+ module Provisioning
5
+ module AWSDriver
6
+ class SuperLWRP < Chef::Resource::LWRPBase
7
+ #
8
+ # Add the :lazy_default and :coerce validation_opts to `attribute`
9
+ #
10
+ def self.attribute(attr_name, validation_opts={})
11
+ lazy_default = validation_opts.delete(:lazy_default)
12
+ coerce = validation_opts.delete(:coerce)
13
+ if lazy_default || coerce
14
+ define_method(attr_name) do |arg=nil|
15
+ arg = instance_exec(arg, &coerce) if coerce && !arg.nil?
16
+
17
+ result = set_or_return(attr_name.to_sym, arg, validation_opts)
18
+
19
+ if result.nil? && arg.nil?
20
+ result = instance_eval(&lazy_default) if lazy_default
21
+ end
22
+
23
+ result
24
+ end
25
+ define_method(:"#{attr_name}=") do |arg|
26
+ if arg.nil?
27
+ remove_instance_variable(:"@#{arg}")
28
+ else
29
+ set_or_return(attr_name.to_sym, arg, validation_opts)
30
+ end
31
+ end
32
+ else
33
+ super
34
+ end
35
+ end
36
+
37
+ # FUUUUUU cloning
38
+ def load_prior_resource(*args)
39
+ Chef::Log.debug "Overloading #{self.resource_name} load_prior_resource with NOOP"
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  module Provisioning
3
3
  module AWSDriver
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
6
6
  end
7
7
  end
@@ -1,17 +1,19 @@
1
- require 'chef/resource/aws_resource'
2
- require 'chef/provisioning/aws_driver'
1
+ require 'chef/provisioning/aws_driver/aws_resource'
3
2
 
4
- class Chef::Resource::AwsAutoScalingGroup < Chef::Resource::AwsResource
5
- self.resource_name = 'aws_auto_scaling_group'
6
- self.databag_name = 'auto_scaling_groups'
3
+ class Chef::Resource::AwsAutoScalingGroup < Chef::Provisioning::AWSDriver::AWSResource
4
+ aws_sdk_type AWS::AutoScaling::Group
7
5
 
8
- actions :create, :delete, :nothing
9
- default_action :create
6
+ attribute :name, kind_of: String, name_attribute: true
7
+ attribute :options, kind_of: Hash, default: {}
8
+ attribute :availability_zones, kind_of: Array
9
+ attribute :desired_capacity, kind_of: Integer
10
+ attribute :launch_configuration, kind_of: String
11
+ attribute :min_size, kind_of: Integer
12
+ attribute :max_size, kind_of: Integer
13
+ attribute :load_balancers, kind_of: Array, coerce: proc { |value| [value].flatten }
10
14
 
11
- attribute :name, :kind_of => String, :name_attribute => true
12
- attribute :desired_capacity, :kind_of => Integer
13
- attribute :launch_config, :kind_of => String
14
- attribute :min_size, :kind_of => Integer, :default => 1
15
- attribute :max_size, :kind_of => Integer, :default => 4
16
- attribute :load_balancers, :kind_of => Array
15
+ def aws_object
16
+ result = driver.auto_scaling.groups[name]
17
+ result && result.exists? ? result : nil
18
+ end
17
19
  end
@@ -0,0 +1,57 @@
1
+ require 'chef/provisioning/aws_driver/aws_resource_with_entry'
2
+
3
+ #
4
+ # DHCP options for use by VPCs.
5
+ #
6
+ # If you specify nothing, the DHCP options set will use 'AmazonProvidedDNS' for its
7
+ # domain name servers and all other values will be empty.
8
+ #
9
+ # API documentation for the AWS Ruby SDK for DHCP Options (and the object returned from `aws_object` can be found here:
10
+ #
11
+ # - http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_DHCP_Options.html
12
+ #
13
+ class Chef::Resource::AwsDhcpOptions < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
14
+ aws_sdk_type AWS::EC2::DHCPOptions
15
+
16
+ #
17
+ # The Chef "idempotence name" of this DHCP options set.
18
+ #
19
+ attribute :name, kind_of: String, name_attribute: true
20
+
21
+ #
22
+ # A domain name of your choice (e.g., example.com).
23
+ #
24
+ attribute :domain_name, kind_of: String
25
+
26
+ #
27
+ # The IP addresses of domain name servers. You can specify up to four addresses.
28
+ #
29
+ # Defaults to "AmazonProvidedDNS"
30
+ #
31
+ attribute :domain_name_servers, kind_of: Array, coerce: proc { |v| Array[v].flatten }
32
+
33
+ #
34
+ # The IP addresses of Network Time Protocol (NTP) servers. You can specify up to four addresses.
35
+ #
36
+ attribute :ntp_servers, kind_of: Array, coerce: proc { |v| Array[v].flatten }
37
+
38
+ #
39
+ # The IP addresses of NetBIOS name servers. You can specify up to four addresses.
40
+ #
41
+ attribute :netbios_name_servers, kind_of: Array, coerce: proc { |v| Array[v].flatten }
42
+
43
+ #
44
+ # Value indicating the NetBIOS node type (1, 2, 4, or 8). For more information about the values, go to RFC 2132. We recommend you only use 2 at this time (broadcast and multicast are currently not supported).
45
+ #
46
+ attribute :netbios_node_type, kind_of: Integer
47
+
48
+ attribute :dhcp_options_id, kind_of: String, aws_id_attribute: true, lazy_default: proc {
49
+ name =~ /^dopt-[a-f0-9]{8}$/ ? name : nil
50
+ }
51
+
52
+ def aws_object
53
+ driver, id = get_driver_and_id
54
+ result = driver.ec2.dhcp_options[id] if id
55
+ result && result.exists? ? result : nil
56
+ end
57
+ end
@@ -1,31 +1,29 @@
1
- require 'chef/resource/aws_resource'
2
- require 'chef/provisioning/aws_driver'
1
+ require 'chef/provisioning/aws_driver/aws_resource_with_entry'
2
+ require 'chef/resource/aws_instance'
3
3
 
4
- class Chef::Resource::AwsEbsVolume < Chef::Resource::AwsResource
5
- self.resource_name = 'aws_ebs_volume'
6
- self.databag_name = 'ebs_volumes'
4
+ class Chef::Resource::AwsEbsVolume < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
5
+ aws_sdk_type AWS::EC2::Volume, backcompat_data_bag_name: 'ebs_volumes'
7
6
 
8
- actions :create, :delete, :nothing
9
- default_action :create
7
+ attribute :name, kind_of: String, name_attribute: true
10
8
 
11
- stored_attribute :volume_id
12
- stored_attribute :created_at
9
+ attribute :machine, kind_of: [ String, FalseClass, AwsInstance, AWS::EC2::Instance ]
13
10
 
14
- attribute :name, :kind_of => String, :name_attribute => true
15
- attribute :volume_name, :kind_of => String
11
+ attribute :availability_zone, kind_of: String
12
+ attribute :size, kind_of: Integer
13
+ attribute :snapshot, kind_of: String
16
14
 
17
- attribute :size
18
- attribute :mount_point
19
- attribute :availability_zone
15
+ attribute :iops, kind_of: Integer
16
+ attribute :volume_type, kind_of: String
17
+ attribute :encrypted, kind_of: [ TrueClass, FalseClass ]
18
+ attribute :device, kind_of: String
20
19
 
20
+ attribute :volume_id, kind_of: String, aws_id_attribute: true, lazy_default: proc {
21
+ name =~ /^vol-[a-f0-9]{8}$/ ? name : nil
22
+ }
21
23
 
22
- def initialize(*args)
23
- super
24
+ def aws_object
25
+ driver, id = get_driver_and_id
26
+ result = driver.ec2.volumes[id] if id
27
+ result && result.exists? && ![:deleted, :deleting].include?(result.status) ? result : nil
24
28
  end
25
-
26
- def after_created
27
- super
28
- end
29
-
30
-
31
29
  end
@@ -1,29 +1,54 @@
1
- require 'chef/resource/aws_resource'
2
- require 'chef/provisioning/aws_driver'
3
- require 'chef/provisioning/machine_spec'
4
-
5
- class Chef::Resource::AwsEipAddress < Chef::Resource::AwsResource
6
- self.resource_name = 'aws_eip_address'
7
- self.databag_name = 'eip_addresses'
8
-
9
- actions :create, :delete, :nothing, :associate, :disassociate
10
- default_action :associate
11
-
12
- stored_attribute :public_ip
13
- stored_attribute :domain
14
-
15
- attribute :name, :kind_of => String, :name_attribute => true
16
- attribute :associate_to_vpc, :kind_of => [TrueClass, FalseClass], :default => false
17
- attribute :machine, :kind_of => String
18
- attribute :instance_id, :kind_of => String
19
-
20
- def initialize(*args)
21
- super
1
+ require 'chef/provisioning/aws_driver/aws_resource_with_entry'
2
+ require 'ipaddr'
3
+
4
+ class Chef::Resource::AwsEipAddress < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
5
+ aws_sdk_type AWS::EC2::ElasticIp, option_names: [ :public_ip ], id: :public_ip, managed_entry_id_name: 'public_ip', backcompat_data_bag_name: 'eip_addresses'
6
+
7
+ attribute :name, kind_of: String, name_attribute: true
8
+
9
+ # TODO network interface
10
+ attribute :machine, kind_of: [String, FalseClass]
11
+ attribute :associate_to_vpc, kind_of: [TrueClass, FalseClass]
12
+
13
+ #
14
+ # Desired public IP address to associate with this Chef resource.
15
+ #
16
+ # Defaults to 'name' if name is an IP address.
17
+ #
18
+ # If the IP address is already allocated to your account, Chef will ensure it is
19
+ # linked to the current . Thus, this is a way to associate an existing AWS IP
20
+ # with Chef:
21
+ #
22
+ # ```ruby
23
+ # aws_eip_address 'frontend_ip' do
24
+ # public_ip '205.32.21.0'
25
+ # end
26
+ # ```
27
+ #
28
+ attribute :public_ip, kind_of: String, aws_id_attribute: true, coerce: proc { |v| IPAddr.new(v); v },
29
+ lazy_default: proc {
30
+ begin
31
+ IPAddr.new(name)
32
+ name
33
+ rescue
34
+ end
35
+ }
36
+
37
+ def aws_object
38
+ driver, public_ip = get_driver_and_id
39
+ result = driver.ec2.elastic_ips[public_ip] if public_ip
40
+ result && result.exists? ? result : nil
22
41
  end
23
42
 
24
- def after_created
25
- super
43
+ def action(*args)
44
+ # Backcompat for associate and disassociate
45
+ if args == [ :associate ]
46
+ super(:create)
47
+ elsif args == [ :disassociate ]
48
+ machine false
49
+ super(:create)
50
+ else
51
+ super
52
+ end
26
53
  end
27
-
28
-
29
54
  end
@@ -0,0 +1,20 @@
1
+ require 'chef/provisioning/aws_driver/aws_resource_with_entry'
2
+
3
+ class Chef::Resource::AwsImage < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
4
+ aws_sdk_type AWS::EC2::Image,
5
+ managed_entry_type: :machine_image,
6
+ managed_entry_id_name: 'image_id',
7
+ load_provider: false
8
+
9
+ attribute :name, kind_of: String, name_attribute: true
10
+
11
+ attribute :image_id, kind_of: String, aws_id_attribute: true, lazy_default: proc {
12
+ name =~ /^ami-[a-f0-9]{8}$/ ? name : nil
13
+ }
14
+
15
+ def aws_object
16
+ driver, id = get_driver_and_id
17
+ result = driver.ec2.images[id] if id
18
+ result && result.exists? ? result : nil
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'chef/provisioning/aws_driver/aws_resource_with_entry'
2
+
3
+ class Chef::Resource::AwsInstance < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
4
+ aws_sdk_type AWS::EC2::Instance,
5
+ managed_entry_type: :machine,
6
+ managed_entry_id_name: 'instance_id',
7
+ load_provider: false
8
+
9
+ attribute :name, kind_of: String, name_attribute: true
10
+
11
+ attribute :instance_id, kind_of: String, aws_id_attribute: true, lazy_default: proc {
12
+ name =~ /^i-[a-f0-9]{8}$/ ? name : nil
13
+ }
14
+
15
+ def aws_object
16
+ driver, id = get_driver_and_id
17
+ result = driver.ec2.instances[id] if id
18
+ result && result.exists? ? result : nil
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ require 'chef/provisioning/aws_driver/aws_resource'
2
+
3
+ class Chef::Resource::AwsInternetGateway < Chef::Provisioning::AWSDriver::AWSResource
4
+ aws_sdk_type AWS::EC2::InternetGateway, load_provider: false, id: :id
5
+
6
+ attribute :name, kind_of: String, name_attribute: true
7
+
8
+ attribute :internet_gateway_id, kind_of: String, aws_id_attribute: true, lazy_default: proc {
9
+ name =~ /^igw-[a-f0-9]{8}$/ ? name : nil
10
+ }
11
+
12
+ def aws_object
13
+ result = driver.ec2.internet_gateways[internet_gateway_id]
14
+ result && result.exists? ? result : nil
15
+ end
16
+ end
@@ -1,11 +1,7 @@
1
- require 'chef/provisioning'
2
- require 'chef/resource/aws_resource'
1
+ require 'chef/provisioning/aws_driver/aws_resource'
3
2
 
4
- class Chef::Resource::AwsKeyPair < Chef::Resource::AwsResource
5
- self.resource_name = 'aws_key_pair'
6
-
7
- actions :create, :delete, :nothing
8
- default_action :create
3
+ class Chef::Resource::AwsKeyPair < Chef::Provisioning::AWSDriver::AWSResource
4
+ aws_sdk_type AWS::EC2::KeyPair, id: :name
9
5
 
10
6
  # Private key to use as input (will be generated if it does not exist)
11
7
  attribute :private_key_path, :kind_of => String
@@ -17,8 +13,8 @@ class Chef::Resource::AwsKeyPair < Chef::Resource::AwsResource
17
13
  # TODO what is the right default for this?
18
14
  attribute :allow_overwrite, :kind_of => [TrueClass, FalseClass], :default => false
19
15
 
20
- # Proc that runs after the resource completes. Called with (resource, private_key, public_key)
21
- def after(&block)
22
- block ? @after = block : @after
16
+ def aws_object
17
+ result = driver.ec2.key_pairs[name]
18
+ result && result.exists? ? result : nil
23
19
  end
24
20
  end
@@ -0,0 +1,15 @@
1
+ require 'chef/provisioning/aws_driver/aws_resource'
2
+
3
+ class Chef::Resource::AwsLaunchConfiguration < Chef::Provisioning::AWSDriver::AWSResource
4
+ aws_sdk_type AWS::AutoScaling::LaunchConfiguration, id: :name
5
+
6
+ attribute :name, kind_of: String, name_attribute: true
7
+ attribute :image, kind_of: [ String, AWS::EC2::Image ]
8
+ attribute :instance_type, kind_of: String
9
+ attribute :options, kind_of: Hash, default: {}
10
+
11
+ def aws_object
12
+ result = driver.auto_scaling.launch_configurations[name]
13
+ result && result.exists? ? result : nil
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ require 'chef/provisioning/aws_driver/aws_resource'
2
+
3
+ class Chef::Resource::AwsLoadBalancer < Chef::Provisioning::AWSDriver::AWSResource
4
+ aws_sdk_type AWS::ELB::LoadBalancer, load_provider: false
5
+
6
+ attribute :name, kind_of: String, name_attribute: true
7
+
8
+ attribute :load_balancer_id, kind_of: String, aws_id_attribute: true, lazy_default: proc {
9
+ name =~ /^elb-[a-f0-9]{8}$/ ? name : nil
10
+ }
11
+
12
+ def aws_object
13
+ result = driver.elb.load_balancers[name]
14
+ result && result.exists? ? result : nil
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'chef/provisioning/aws_driver/aws_resource'
2
+
3
+ class Chef::Resource::AwsNetworkInterface < Chef::Provisioning::AWSDriver::AWSResource
4
+ aws_sdk_type AWS::EC2::NetworkInterface, load_provider: false, id: :id
5
+
6
+ attribute :name, kind_of: String, name_attribute: true
7
+
8
+ attribute :network_interface_id, kind_of: String, aws_id_attribute: true, lazy_default: proc {
9
+ name =~ /^eni-[a-f0-9]{8}$/ ? name : nil
10
+ }
11
+
12
+ def aws_object
13
+ result = driver.ec2.network_interfaces[network_interface_id]
14
+ result && result.exists? ? result : nil
15
+ end
16
+ end
@@ -0,0 +1,76 @@
1
+ require 'chef/provisioning/aws_driver/aws_resource_with_entry'
2
+
3
+ #
4
+ # An AWS route table, specifying where to route traffic destined for particular
5
+ # sets of IPs.
6
+ #
7
+ # `name` is not guaranteed unique for an AWS account; therefore, Chef will
8
+ # store the route table ID associated with this name in your Chef server in the
9
+ # data bag `data/aws_route_Table/<name>`.
10
+ #
11
+ # API documentation for the AWS Ruby SDK for VPCs (and the object returned from `aws_object` can be found here:
12
+ #
13
+ # - http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/EC2/RouteTable.html
14
+ #
15
+ class Chef::Resource::AwsRouteTable < Chef::Provisioning::AWSDriver::AWSResourceWithEntry
16
+ aws_sdk_type AWS::EC2::RouteTable
17
+
18
+ require 'chef/resource/aws_vpc'
19
+
20
+ #
21
+ # The name of this route table.
22
+ #
23
+ attribute :name, kind_of: String, name_attribute: true
24
+
25
+ #
26
+ # The VPC of this route table.
27
+ #
28
+ # May be one of:
29
+ # - The name of an `aws_vpc` Chef resource.
30
+ # - An actual `aws_vpc` resource.
31
+ # - An AWS `VPC` object.
32
+ #
33
+ # This is required for new route tables.
34
+ #
35
+ attribute :vpc, kind_of: [ String, AwsVpc, AWS::EC2::VPC ], required: true
36
+
37
+ #
38
+ # The routes for this route table.
39
+ #
40
+ # If specified, this must be a complete specification of all routes: it will
41
+ # add any new routes and remove any old ones.
42
+ #
43
+ # This is in the form of a Hash, like so:
44
+ #
45
+ # ```ruby
46
+ # main_routes '10.0.0.0/8' => 'internal_vpn',
47
+ # '0.0.0.0/0' => :internet_gateway
48
+ # ```
49
+ #
50
+ # The destination (the left side of the `=>`) is always a CIDR block.
51
+ # The target (the right side of the `=>`) can be one of several things:
52
+ # - { internet_gateway: <AWS Internet Gateway ID or object> }
53
+ # - { instance: <Chef machine name or resource, AWS Instance ID or object> }
54
+ # - { network_interface: <AWS Network Interface ID or object> }
55
+ # - <AWS Internet Gateway, Instance or Network Interface <ID or object)>
56
+ # - Chef machine name
57
+ # - Chef machine resource
58
+ #
59
+ attribute :routes, kind_of: Hash
60
+
61
+ attribute :route_table_id, kind_of: String, aws_id_attribute: true, lazy_default: proc {
62
+ name =~ /^rtb-[a-f0-9]{8}$/ ? name : nil
63
+ }
64
+
65
+ def aws_object
66
+ driver, id = get_driver_and_id
67
+ result = driver.ec2.route_tables[id] if id
68
+ begin
69
+ # try accessing it to find out if it exists
70
+ result.vpc if result
71
+ rescue AWS::EC2::Errors::InvalidRouteTableID::NotFound
72
+ result = nil
73
+ end
74
+ result
75
+ end
76
+ end