class Chef::Resource::AwsSubnet

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:

Public Instance Methods

aws_object() click to toggle source
# 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