microvms_app/control/services.rs
1// SPDX-License-Identifier: Apache-2.0
2//! The two calls outside the MicroVMs API that `ensure_image` makes: the caller's account,
3//! for the image ARN, and the artifact upload (#221, IMAGE-8).
4//!
5//! [`BuildServices`] is the port. `Sandbox::with_build_services` takes one, a test records
6//! the calls and answers them, and production gets `SignedBuildServices` (in
7//! `microvms-edges`, re-exported as `microvms_core::control::SignedBuildServices`) through the
8//! plane's adapters on the first `ensure_image`. The account comes from STS because
9//! `GetMicrovmImage` takes an ARN and the service rejects a bare name; `GetCallerIdentity`
10//! answers the account for any identity and needs no permission to make.
11
12use futures_util::future::BoxFuture;
13
14use crate::error::Error;
15
16/// The seam `ensure_image` reaches STS and S3 through.
17pub trait BuildServices: Send + Sync {
18 /// The caller's twelve-digit account id.
19 fn caller_account(&self) -> BoxFuture<'_, Result<String, Error>>;
20
21 /// Puts `bytes` at `s3://<bucket>/<key>`.
22 fn put_object<'a>(
23 &'a self,
24 bucket: &'a str,
25 key: &'a str,
26 bytes: Vec<u8>,
27 ) -> BoxFuture<'a, Result<(), Error>>;
28}