Skip to content

AWS::Serverless::MicrovmImage.CodeUri has no default and no local-file support, making a required-parameter bootstrap deploy impossible #3995

Open

Description

@singledigit

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

  1. Create a minimal template with an AWS::Serverless::MicrovmImage resource whose CodeUri is 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).
  2. On a fresh account/region with no prior sam deploy history (so no SAM-managed S3 bucket exists yet either), run:
    sam build
    sam deploy
    
    without passing --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:

  1. CodeUri on AWS::Serverless::MicrovmImage supports a local file/directory path the same way AWS::Serverless::Function's CodeUri does — sam build/sam deploy zip 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 makes MicrovmImage consistent with the rest of the SAM resource model's "just point me at local code" ergonomics.
  2. Failing that, at minimum: some documented, SAM-native way to bootstrap a stack containing a MicrovmImage resource whose CodeUri depends 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

  1. OS: macOS
  2. sam --version: SAM CLI, version 1.161.0
  3. AWS region: us-east-1 (reproducible in any region with MicroVM image support)

Activity

  1. vicheey commented on Nov 13, 2026

    @vicheey
    Contributor

    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 build and sam package/sam deploy accept a local directory (or a .zip) for AWS::Serverless::MicrovmImage CodeUri. They zip it, upload it to the deployment bucket with a content-hashed key, and rewrite CodeUri to the S3 URI (aws/aws-sam-cli#9357, aws/aws-sam-cli#9399). So you can point CodeUri at the image source in the template, for example CodeUri: ./image, and drop the required parameter. With sam deploy --resolve-s3 or --guided on 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, EnvironmentVariables on the image accepts !Ref/!GetAtt and 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions