pub struct Ec2Instance { /* private fields */ }Expand description
Represents a currently running EC2 instance and provides various methods for interacting with the instance.
This type implements serde Serialize/Deserialize to allow you to save and restore the instance from disk.
After restoring Ec2Instance in this way you need to call the Ec2Instance::init method.
Implementations§
Source§impl Ec2Instance
impl Ec2Instance
Sourcepub fn public_ip(&self) -> Option<IpAddr>
pub fn public_ip(&self) -> Option<IpAddr>
Use this address to connect to this instance from outside of AWS
Sourcepub fn private_ip(&self) -> IpAddr
pub fn private_ip(&self) -> IpAddr
Use this address to connect to this instance from within AWS
Sourcepub fn connect_ip(&self) -> IpAddr
pub fn connect_ip(&self) -> IpAddr
Use this address to get the private or public IP that aws-throwaway is using to ssh to the instance.
Whether or not this is public is decided by crate::AwsBuilder::use_public_addresses.
You should use this address if you want to connect to the instance from your local machine
Sourcepub fn network_interfaces(&self) -> &[NetworkInterface]
pub fn network_interfaces(&self) -> &[NetworkInterface]
List of all network interfaces attached to this instance.
Includes the primary interface that has the ip returned by Ec2Instance::private_ip as well as all other interfaces attached to this instance at the time it was created.
Sourcepub fn client_private_key(&self) -> &str
pub fn client_private_key(&self) -> &str
Use this as the private key of your machine when connecting to this instance
Sourcepub fn host_public_key_bytes(&self) -> &[u8] ⓘ
pub fn host_public_key_bytes(&self) -> &[u8] ⓘ
Use this for authenticating a host programmatically
Sourcepub fn openssh_known_hosts_line(&self) -> String
pub fn openssh_known_hosts_line(&self) -> String
Insert this into your known_hosts file to avoid errors due to unknown fingerprints
Sourcepub fn ssh_instructions(&self) -> String
pub fn ssh_instructions(&self) -> String
Get a list of commands that the user can paste into bash to manually open an ssh connection to this instance.
Sourcepub async fn terminate(self, aws: &Aws)
pub async fn terminate(self, aws: &Aws)
Delete this instance.
Prefer using Aws::cleanup_resources at end of runtime as it will automatically destroy all resources, not just this one instance.
However this method can be useful when you have a single instance that you would like to terminate before the rest.
Aws instance must be passed in manually here since Ec2Instances can be deserialized when there is no Aws instance.
Sourcepub async fn init(&mut self) -> Result<()>
pub async fn init(&mut self) -> Result<()>
After deserializing Ec2Instance this method must be called to recreate the ssh connection.
No need to call after creating via crate::Aws::create_ec2_instance
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Ec2Instance
impl<'de> Deserialize<'de> for Ec2Instance
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Ec2Instance
impl !RefUnwindSafe for Ec2Instance
impl Send for Ec2Instance
impl Sync for Ec2Instance
impl Unpin for Ec2Instance
impl !UnwindSafe for Ec2Instance
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more