Created
February 9, 2015 18:07
-
-
Save j1n6/8f51d9ff0092785f2b9d to your computer and use it in GitHub Desktop.
Get vpc id, put file at /usr/lib/ruby/vendor_ruby/facter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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