Class: Chef::Resource::AwsSubnet

Overview

An AWS subnet is a sub-section of a VPC, walled gardens within the walled garden; they share a space of IP addresses with other subnets in the VPC but can otherwise be walled off from each other.

‘name` is not guaranteed unique for an AWS account; therefore, Chef will store the subnet ID associated with this name in your Chef server in the data bag `data/aws_subnet/<name>`.

API documentation for the AWS Ruby SDK for VPCs (and the object returned from ‘aws_object` can be found here:

Constant Summary

Constants inherited from Provisioning::AWSDriver::AWSResource

Provisioning::AWSDriver::AWSResource::NOT_PASSED

Instance Method Summary collapse

Methods included from Provisioning::AWSDriver::AWSTaggable

included

Methods inherited from Provisioning::AWSDriver::AWSResourceWithEntry

#delete_managed_entry, #get_id_from_managed_entry, #save_managed_entry, #to_s

Methods inherited from Provisioning::AWSDriver::AWSResource

#action, #action=, #aws_object_id, get_aws_object, get_aws_object_id, #initialize, lookup_options

Methods inherited from Provisioning::AWSDriver::SuperLWRP

#_pv_is, attribute, lazy

Constructor Details

This class inherits a constructor from Chef::Provisioning::AWSDriver::AWSResource

Instance Method Details

#aws_objectObject



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/chef/resource/aws_subnet.rb', line 93

def aws_object
  driver, id = get_driver_and_id
  result = driver.ec2_resource.subnet(id) if id
  if result
    begin
      # Try to access it to see if it exists (no `exists?` method)
      result.vpc_id
    rescue ::Aws::EC2::Errors::InvalidSubnetIDNotFound
      result = nil
    end
  end
  result
end