Class: Chef::Resource::AwsSubnet

Inherits:
Provisioning::AWSDriver::AWSResourceWithEntry
  • Object
show all
Defined in:
lib/chef/resource/aws_subnet.rb

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:

Instance Method Summary collapse

Instance Method Details

#aws_objectObject



82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/chef/resource/aws_subnet.rb', line 82

def aws_object
  driver, id = get_driver_and_id
  result = driver.ec2.subnets[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::InvalidSubnetID::NotFound
      result = nil
    end
  end
  result
end