-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add API to create instances with multiple network interfaces (#15)
- Loading branch information
Showing
5 changed files
with
224 additions
and
28 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
aws-throwaway/examples/aws-throwaway-test-multiple-instances.rs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use aws_throwaway::{Aws, CleanupResources, Ec2InstanceDefinition, InstanceType}; | ||
use tracing_subscriber::EnvFilter; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout()); | ||
tracing_subscriber::fmt() | ||
.with_env_filter(EnvFilter::from_default_env()) | ||
.with_writer(non_blocking) | ||
.init(); | ||
|
||
println!("Creating instances"); | ||
let aws = Aws::new(CleanupResources::AllResources).await; | ||
let (instance1, instance2) = tokio::join!( | ||
aws.create_ec2_instance(Ec2InstanceDefinition::new(InstanceType::T2Small)), | ||
aws.create_ec2_instance( | ||
Ec2InstanceDefinition::new(InstanceType::T2Small).network_interface_count(2) | ||
) | ||
); | ||
|
||
println!("pinging instance2 from instance1"); | ||
let ip = instance2.private_ip(); | ||
let output = instance1.ssh().shell(&format!("ping {ip} -c 4")).await; | ||
println!("{output}"); | ||
|
||
aws.cleanup_resources().await; | ||
println!("\nAll AWS throwaway resources have been deleted") | ||
} |
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
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
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
Oops, something went wrong.