Repository navigation
Description
Description
AWS::Serverless::MicrovmImage's CodeUri is documented as Required: Yes with no default, and only accepts an S3 URI (docs: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-microvmimage.html — every example uses s3://bucket/key directly). Unlike AWS::Serverless::Function's CodeUri, it is not in SAM's local-file auto-upload path — a local directory path is passed through unchanged rather than zipped and uploaded.
This creates a real bootstrap problem for any template where the MicroVM image's code artifact needs an input that the same stack creates (a common pattern — e.g. baking a filesystem id, role ARN, or other stack output into the image's environment/config at build time). On a brand-new account with no prior deploy, there is no existing S3 object to reference, so MicrovmCodeUri has nothing valid to pass. A bare sam deploy on such a template fails CloudFormation's changeset validation (missing required parameter value) before creating any resources — including the very S3 bucket the artifact would need to be uploaded to. The stack is left in REVIEW_IN_PROGRESS with zero resources created, and CloudFormation does not populate Outputs for any IN_PROGRESS stack status, so there's no way to read back partial state either.
We hit this in a public sample project (https://github.com/singledigit/microvm-dev-environment) — a user tried deploying on a fresh account, hit exactly this dead end, and had to hand-roll a workaround (manually zip+upload a placeholder artifact to SAM's own auto-resolved bucket, deploy once with that as CodeUri, then redeploy for real). We've since automated that same workaround inside our own deploy.sh, but it shouldn't be necessary — this is the same class of problem AWS::Serverless::Function's local-file CodeUri upload already solves for a different resource type.
Steps to reproduce
- Create a minimal template with an
AWS::Serverless::MicrovmImageresource whoseCodeUriis a required Parameter with no default (a realistic case: the artifact needs a value from a stack output, e.g. an EFS/filesystem id, that doesn't exist until the same stack creates it). - On a fresh account/region with no prior
sam deployhistory (so no SAM-managed S3 bucket exists yet either), run:without passingsam build sam deploy--parameter-overrides CodeUri=....
Observed result
sam deploy fails changeset creation with a missing-required-parameter error. The stack is left in REVIEW_IN_PROGRESS. No resources — including any S3 bucket — are created. aws cloudformation describe-stacks returns no Outputs for the stack (expected CloudFormation behavior for an IN_PROGRESS-family status, but it means there is no way to inspect any state to unblock the situation). The only way forward is manually staging a placeholder S3 object completely outside the template/SAM's own tooling.
Expected result
Either:
CodeUrionAWS::Serverless::MicrovmImagesupports a local file/directory path the same wayAWS::Serverless::Function'sCodeUridoes —sam build/sam deployzip and upload it automatically (to SAM's own managed bucket, same as today for Functions), removing the need for the artifact to already exist in S3 before the stack can be created at all. This is the fix we'd most want — it makesMicrovmImageconsistent with the rest of the SAM resource model's "just point me at local code" ergonomics.- Failing that, at minimum: some documented, SAM-native way to bootstrap a stack containing a
MicrovmImageresource whoseCodeUridepends on the stack's own outputs, without requiring users to hand-roll a two-phase deploy against SAM's undocumented internal managed-bucket behavior.
Additional environment details
- OS: macOS
sam --version: SAM CLI, version 1.161.0- AWS region: us-east-1 (reproducible in any region with MicroVM image support)
Activity
vicheey commentedon Nov 13, 2026
Thanks @singledigit for the detailed write-up and the sample repo, it made this easy to follow.
The fix for this is on the SAM CLI side, and it's out now: starting with SAM CLI 1.172.1,
sam buildandsam package/sam deployaccept a local directory (or a .zip) forAWS::Serverless::MicrovmImageCodeUri. They zip it, upload it to the deployment bucket with a content-hashed key, and rewriteCodeUrito the S3 URI (aws/aws-sam-cli#9357, aws/aws-sam-cli#9399). So you can pointCodeUriat the image source in the template, for exampleCodeUri: ./image, and drop the required parameter. Withsam deploy --resolve-s3or--guidedon a fresh account, nothing has to be staged in S3 first.The transform only ever sees the packaged S3 URI, the same as
Function.CodeUri, so no change is needed in this repo. For values that come from the same stack, such as a filesystem id,EnvironmentVariableson the image accepts!Ref/!GetAttand may let you avoid baking them into the artifact.Could you try 1.172.1 with the sample and let us know if it unblocks the fresh-account deploy? If it does, we'll close this out.