VM::EC2::Instance::Located - determine if code is executing on an EC2 instance
my $result = VM::EC2::Instance::Located::at_ec2(); if($result) { print "Running at EC2\n"; } else { print "Not running at EC2\n"; }
Provides a function that determines if code is executing on an EC2 instance.
Currently implemented by resolving instnace-data.ec2.internal. It will succeed on an ec2 instance and fail otherwise.
Determines if the code is running at EC2.
The answer is cached because typically the result does not change unless you're able to move processes between an EC2 instance an a non EC2 instance.
Returns a boolean value answering the question.
To install VM::EC2::Instance::Located, copy and paste the appropriate command in to your terminal.
cpanm
cpanm VM::EC2::Instance::Located
CPAN shell
perl -MCPAN -e shell install VM::EC2::Instance::Located
For more information on module installation, please visit the detailed CPAN module installation guide.