2 releases
Uses old Rust 2015
0.1.1 | Mar 20, 2017 |
---|---|
0.1.0 | Mar 19, 2017 |
#45 in #zone
22 downloads per month
8KB
127 lines
aws_instance_metadata
This is a small Rust library to pull AWS instance metadata for the currently running AWS instance from the AWS EC2 metadata web service (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html).
It currently only supports basic identity metadata; region, availability zone, instance type, account id, instance id, AMI id (image_id), and private IP.
Documentation: https://docs.rs/aws_instance_metadata
Distributed under the terms of the MIT license.
Example
Cargo.toml:
[dependencies]
aws_instance_metadata = "0.1"
main.rs:
extern crate aws_instance_metadata;
fn main() {
let metadata = aws_instance_metadata::get().unwrap();
println!("instance_id: {:?}", metadata.instance_id);
println!("region: {:?}", metadata.region());
println!("ip: {:?}", metadata.private_ip());
}
lib.rs
:
aws_instance_metadata is a module for retrieving instance metadata when running on AWS EC2 instances.
Instance metadata (or, meta-data) is a service that Amazon provides that uses a fixed IP address and a simple HTTP API to retrieve information about the currently running EC2 instance. This metadata is typically used for reducing the amount of configuration required in software that uses the AWS APIs. For example, the current AWS region can be retrieved so that an SDK can be configured to make API calls within that region, rather than having to configure software with the correct region explicitly.
Examples
extern crate aws_instance_metadata;
fn main() {
let metadata = aws_instance_metadata::get().unwrap();
println!("instance_id: {:?}", metadata.instance_id);
println!("region: {:?}", metadata.region());
println!("ip: {:?}", metadata.private_ip());
}
Dependencies
~19–28MB
~546K SLoC