Struct tsunami::TsunamiBuilder[][src]

#[must_use]
pub struct TsunamiBuilder { /* fields omitted */ }

Use this to prepare and execute a new tsunami.

A tsunami consists of one or more MachineSetups that will be spawned as EC2 spot instances. See TsunamiBuilder#add_set) for how to construct a tsunami.

Methods

impl TsunamiBuilder
[src]

Add a new (named) machine setup template, and set how many instances of that type should be spawned as part of the tsunami.

let mut b = TsunamiBuilder::default();
b.add_set(
    "server",
    1,
    MachineSetup::new("m5.large", "ami-e18aa89b", |ssh| {
        ssh.cmd("yum install nginx").map(|out| {
            println!("{}", out);
        })
    }),
);
b.add_set(
    "client",
    10,
    MachineSetup::new("m5.large", "ami-e18aa89b", |ssh| {
        ssh.cmd("yum install wget").map(|out| {
            println!("{}", out);
        })
    }),
);

Set up the machines in a specific EC2 Region.

The default region is us-east-1. Available regions are listed here

By default, all spawned instances are launched in a single Placement Group using the cluster policy. This ensures that all the instances are located in the same availability region, and in close proximity to one another.

This places some restrictions on the launched instances, and causes it to be more likely for placements to fail. Call this method to disable clustering. This will leave instance placing entirely up to ec2, which may choose to place your instances in disparate availability zones.

Limit how long we should wait for spot requests to be satisfied before giving up.

Set the maxium lifetime of spawned spot instances.

EC2 spot instances are normally subject to termination at any point. This library instead uses defined duration instances, which cost slightly more, but are never prematurely terminated. The lifetime of such instances must be declared in advance (1-6 hours), and can be changed with this method.

The default duration is 1 hour.

Set the logging target for this tsunami.

By default, logging is disabled (i.e., the default logger is slog::Discard).

Enable logging to terminal.

Spin up a tsunami batching the defined machine sets in this builder.

When all instances are up and running, the given closure will be called with a handle to all spawned hosts. When the closure exits, the instances are all terminated automatically.

This method uses the rusoto EnvironmentProvider, which uses standard AWS environtment variables for authentication.

let mut b = TsunamiBuilder::default();
// ...
b.run(|vms: HashMap<String, Vec<Machine>>| {
    println!("==> {}", vms["server"][0].private_ip);
    for c in &vms["client"] {
        println!(" -> {}", c.private_ip);
    }
    Ok(())
}).unwrap();

Spin up a tsunami batching the defined machine sets in this builder with a custom credentials provider.

When all instances are up and running, the given closure will be called with a handle to all spawned hosts. When the closure exits, the instances are all terminated automatically.

// https://github.com/rusoto/rusoto/blob/master/AWS-CREDENTIALS.md
let sts = rusoto_sts::StsClient::new(
    rusoto_core::default_tls_client().unwrap(),
    rusoto_core::EnvironmentProvider,
    rusoto_core::Region::UsEast1,
);
let provider = rusoto_sts::StsAssumeRoleSessionCredentialsProvider::new(
    sts,
    "arn:aws:sts::1122334455:role/myrole".to_owned(),
    "session-name".to_owned(),
    None,
    None,
    None,
    None,
);

let mut b = TsunamiBuilder::default();
// ...
b.run_as(provider, |vms: HashMap<String, Vec<Machine>>| {
    println!("==> {}", vms["server"][0].private_ip);
    for c in &vms["client"] {
        println!(" -> {}", c.private_ip);
    }
    Ok(())
}).unwrap();

Trait Implementations

impl Default for TsunamiBuilder
[src]

Returns the "default value" for a type. Read more

Auto Trait Implementations