Skip to content

Instantly share code, notes, and snippets.

@j1n6
Created February 9, 2015 18:07
Show Gist options
  • Save j1n6/8f51d9ff0092785f2b9d to your computer and use it in GitHub Desktop.
Save j1n6/8f51d9ff0092785f2b9d to your computer and use it in GitHub Desktop.
Get vpc id, put file at /usr/lib/ruby/vendor_ruby/facter
require "net/http"
require "facter"
require "facter/ec2"
# vpc-id is in a newer metadata api rev than the usual EC2 facts
Facter.add(:ec2_vpc_id) do
setcode do
if !Facter.value('ec2_instance_id').nil? && !Facter.value('ec2_mac').nil?
mac = Facter.value('ec2_mac')
Facter.value("ec2_network_interfaces_macs_#{mac}_vpc_id")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment