Skip to content

Instantly share code, notes, and snippets.

@epequeno
Last active January 23, 2018 00:29
Show Gist options
  • Save epequeno/d3c87f2928194307ce79380dae8cf1f3 to your computer and use it in GitHub Desktop.
Save epequeno/d3c87f2928194307ce79380dae8cf1f3 to your computer and use it in GitHub Desktop.
only look for env vars
extern crate rusoto_core;
extern crate rusoto_ec2;
use rusoto_core::{default_tls_client,
EnvironmentProvider,
Region};
use rusoto_ec2::{Ec2Client,
DescribeInstancesRequest,
Ec2};
fn main() {
let dispatcher = default_tls_client().unwrap();
let provider = EnvironmentProvider;
let client = Ec2Client::new(dispatcher, provider, Region::UsEast1);
let req = DescribeInstancesRequest::default();
let res = client.describe_instances(&req).unwrap();
match res.reservations {
Some(reservations) => for r in &reservations {
match r.instances {
Some(ref instances) => for i in instances.iter() {
println!("{:?} - {:?}", i.instance_id.as_ref().unwrap(), i.instance_type.as_ref().unwrap());
},
None => println!("no instances!")
}
},
None => println!("nothing found")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment