pub struct Ec2Service { /* private fields */ }Expand description
Amazon EC2 service.
Implementations§
Source§impl Ec2Service
impl Ec2Service
Sourcepub fn with_state(state: SharedEc2State) -> Self
pub fn with_state(state: SharedEc2State) -> Self
Construct a service over a shared state handle (used by the server so persistence/snapshots can be wired in later batches).
Sourcepub fn provision_sync(
&self,
request: &AwsRequest,
) -> Result<AwsResponse, AwsServiceError>
pub fn provision_sync( &self, request: &AwsRequest, ) -> Result<AwsResponse, AwsServiceError>
Synchronous dispatch for the subset of EC2 control-plane actions the CloudFormation provisioner needs (VPC/Subnet/SecurityGroup/RouteTable/ InternetGateway create + delete). Routing through the real handlers keeps CFN-provisioned EC2 resources identical to API-created ones (default SG/NACL/route-table, id formats, tags) instead of re-deriving them. None of these actions need the container runtime.
Sourcepub fn with_runtime(self, runtime: Option<Arc<Ec2Runtime>>) -> Self
pub fn with_runtime(self, runtime: Option<Arc<Ec2Runtime>>) -> Self
Attach a container runtime so RunInstances boots real containers.
Passing None leaves the service in metadata-only mode.
Sourcepub fn with_snapshot_store(self, store: Arc<dyn SnapshotStore>) -> Self
pub fn with_snapshot_store(self, store: Arc<dyn SnapshotStore>) -> Self
Attach a persistence snapshot store so control-plane mutations are
written through to disk. Backing containers are reconciled separately on
restart via Ec2Service::recover_persisted_containers.
Sourcepub fn snapshot_hook(&self) -> Option<SnapshotHook>
pub fn snapshot_hook(&self) -> Option<SnapshotHook>
Build a hook that persists the current EC2 state when invoked, or None
in memory mode. The CloudFormation provisioner mutates state directly
and uses this to write a CFN-provisioned resource through to disk, the
same way a direct mutating API call would.
Clone the shared state handle so the server can expose read-only
introspection endpoints (GET /_fakecloud/ec2/instances).
Sourcepub async fn recover_persisted_containers(&self)
pub async fn recover_persisted_containers(&self)
Rebuild the backing-container runtime state for persisted instances
after a fakecloud restart, mirroring RDS/ElastiCache
recover_persisted_containers.
On an ungraceful restart the new process has a new PID, so the shared
reaper removes every EC2 container labeled with the previous PID; an
instance that persisted as running with a container_id would
otherwise be left pointing at a removed container, with every
subsequent Stop/Start/Reboot/Terminate a silent no-op (bug-hunt
2026-06-15 finding 0.3). For each such instance we flip it to pending
and spawn a fresh backing container in the background, reconciling it to
running (with the new id/IP) when it’s up, or stopped on failure.
Instances persisted as stopped/terminated are left as-is —
StartInstances revives the former. No-op when no runtime is configured
or there are no instances to recover.
Trait Implementations§
Source§impl AwsService for Ec2Service
impl AwsService for Ec2Service
Source§fn service_name(&self) -> &str
fn service_name(&self) -> &str
Source§fn supported_actions(&self) -> &[&str]
fn supported_actions(&self) -> &[&str]
Source§fn handle<'life0, 'async_trait>(
&'life0 self,
request: AwsRequest,
) -> Pin<Box<dyn Future<Output = Result<AwsResponse, AwsServiceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
request: AwsRequest,
) -> Pin<Box<dyn Future<Output = Result<AwsResponse, AwsServiceError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn iam_enforceable(&self) -> bool
fn iam_enforceable(&self) -> bool
FAKECLOUD_IAM=soft|strict). Read moreSource§fn iam_action_for(&self, _request: &AwsRequest) -> Option<IamAction>
fn iam_action_for(&self, _request: &AwsRequest) -> Option<IamAction>
Source§fn iam_condition_keys_for(
&self,
_request: &AwsRequest,
_action: &IamAction,
) -> BTreeMap<String, Vec<String>>
fn iam_condition_keys_for( &self, _request: &AwsRequest, _action: &IamAction, ) -> BTreeMap<String, Vec<String>>
resource_arn. Read morex-amz-tagging, TagResource). Read moreAuto Trait Implementations§
impl !RefUnwindSafe for Ec2Service
impl !UnwindSafe for Ec2Service
impl Freeze for Ec2Service
impl Send for Ec2Service
impl Sync for Ec2Service
impl Unpin for Ec2Service
impl UnsafeUnpin for Ec2Service
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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