Skip to content

create_microvm_image

create_microvm_image(
    base_image_arn: NonBlankString,
    build_role_arn: RoleArn,
    code_artifact: CodeArtifact,
    name: ImageName,
    *,
    config_overrides: Optional[LambdaMicrovmsClientConfig] = None,
    base_image_version: Optional[Version] = None,
    description: Optional[str] = None,
    logging: Optional[Logging] = None,
    egress_network_connectors: Optional[NetworkConnectorList] = None,
    cpu_configurations: Optional[CpuConfigurationList] = None,
    resources: Optional[ResourcesList] = None,
    additional_os_capabilities: Optional[CapabilityList] = None,
    hooks: Optional[Hooks] = None,
    environment_variables: Optional[EnvironmentVariableMap] = None,
    tags: Optional[Tags] = None,
    client_token: Optional[str] = None,
) -> CreateMicrovmImageResponse

Creates a MicroVM image from the specified code artifact and base image. The build is asynchronous — the image transitions from CREATING to CREATED on success, or CREATE_FAILED on failure. Use GetMicrovmImage to poll for completion.

Parameters:

  • base_image_arn (NonBlankString) –

    The ARN of the Lambda-managed base MicroVM image to build upon. Use ListManagedMicrovmImages to discover available base images.

  • base_image_version (Optional[Version], default: None ) –

    The specific version of the base MicroVM image to use.

  • build_role_arn (RoleArn) –

    The ARN of the IAM role assumed during the image build process. This role must have permissions to access the code artifact and any required resources.

  • description (Optional[str], default: None ) –

    A description of the MicroVM image.

  • code_artifact (CodeArtifact) –

    The code artifact containing the application code and metadata for the MicroVM image.

  • logging (Optional[Logging], default: None ) –

    The logging configuration for build-time and runtime logs. Specify {"cloudWatch": {"logGroup": "..."}} to stream logs to a custom CloudWatch log group, or {"disabled": {}} to turn off logging.

  • egress_network_connectors (Optional[NetworkConnectorList], default: None ) –

    The list of egress network connectors available to the MicroVM at runtime.

  • cpu_configurations (Optional[CpuConfigurationList], default: None ) –

    The list of supported CPU configurations for the MicroVM.

  • resources (Optional[ResourcesList], default: None ) –

    The resource requirements for the MicroVM.

  • additional_os_capabilities (Optional[CapabilityList], default: None ) –

    Additional OS capabilities granted to the MicroVM runtime environment.

  • environment_variables (Optional[EnvironmentVariableMap], default: None ) –

    Environment variables set in the MicroVM runtime environment.

  • name (ImageName) –

    The name of the MicroVM image. Must be unique within the AWS account.

  • tags (Optional[Tags], default: None ) –

    A set of key-value pairs that you can attach to the resource. Use tags to categorize resources for cost allocation, access control (ABAC), and organization.

  • client_token (Optional[str], default: None ) –

    A unique, case-sensitive identifier you provide to ensure the idempotency of the request. If you retry a request that completed successfully using the same client token, the operation returns the successful response without performing any further actions.

Raises:

Source code in docs_src/capo_lambda_microvms/_services/lambda_microvms.py
def create_microvm_image(
    self,
    base_image_arn: "capo_lambda_microvms.types.non_blank_string.NonBlankString",
    build_role_arn: "capo_lambda_microvms.types.role_arn.RoleArn",
    code_artifact: "capo_lambda_microvms.types.code_artifact.CodeArtifact",
    name: "capo_lambda_microvms.types.image_name.ImageName",
    *,
    config_overrides: Optional[LambdaMicrovmsClientConfig] = None,
    base_image_version: Optional[
        "capo_lambda_microvms.types.version.Version"
    ] = None,
    description: Optional[str] = None,
    logging: Optional["capo_lambda_microvms.types.logging.Logging"] = None,
    egress_network_connectors: Optional[
        "capo_lambda_microvms.types.network_connector_list.NetworkConnectorList"
    ] = None,
    cpu_configurations: Optional[
        "capo_lambda_microvms.types.cpu_configuration_list.CpuConfigurationList"
    ] = None,
    resources: Optional[
        "capo_lambda_microvms.types.resources_list.ResourcesList"
    ] = None,
    additional_os_capabilities: Optional[
        "capo_lambda_microvms.types.capability_list.CapabilityList"
    ] = None,
    hooks: Optional["capo_lambda_microvms.types.hooks.Hooks"] = None,
    environment_variables: Optional[
        "capo_lambda_microvms.types.environment_variable_map.EnvironmentVariableMap"
    ] = None,
    tags: Optional["capo_lambda_microvms.types.tags.Tags"] = None,
    client_token: Optional[str] = None,
) -> "capo_lambda_microvms.types.create_microvm_image_response.CreateMicrovmImageResponse":
    """<p>Creates a MicroVM image from the specified code artifact and base image. The build is asynchronous — the image transitions from CREATING to CREATED on success, or CREATE_FAILED on failure. Use GetMicrovmImage to poll for completion.</p>

    Args:
        base_image_arn: <p>The ARN of the Lambda-managed base MicroVM image to build upon. Use ListManagedMicrovmImages to discover available base images.</p>
        base_image_version: <p>The specific version of the base MicroVM image to use.</p>
        build_role_arn: <p>The ARN of the IAM role assumed during the image build process. This role must have permissions to access the code artifact and any required resources.</p>
        description: <p>A description of the MicroVM image.</p>
        code_artifact: <p>The code artifact containing the application code and metadata for the MicroVM image.</p>
        logging: <p>The logging configuration for build-time and runtime logs. Specify {"cloudWatch": {"logGroup": "..."}} to stream logs to a custom CloudWatch log group, or {"disabled": {}} to turn off logging.</p>
        egress_network_connectors: <p>The list of egress network connectors available to the MicroVM at runtime.</p>
        cpu_configurations: <p>The list of supported CPU configurations for the MicroVM.</p>
        resources: <p>The resource requirements for the MicroVM.</p>
        additional_os_capabilities: <p>Additional OS capabilities granted to the MicroVM runtime environment.</p>
        environment_variables: <p>Environment variables set in the MicroVM runtime environment.</p>
        name: <p>The name of the MicroVM image. Must be unique within the AWS account.</p>
        tags: <p>A set of key-value pairs that you can attach to the resource. Use tags to categorize resources for cost allocation, access control (ABAC), and organization.</p>
        client_token: <p>A unique, case-sensitive identifier you provide to ensure the idempotency of the request. If you retry a request that completed successfully using the same client token, the operation returns the successful response without performing any further actions.</p>

    Raises:
        capo_lambda_microvms.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_lambda_microvms.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry the request later.</p>
        capo_lambda_microvms.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling. Retry the request later.</p>
        capo_lambda_microvms.errors.validation_exception.ValidationException: <p>The input does not satisfy the constraints specified by the service.</p>
        capo_lambda_microvms.errors.conflict_exception.ConflictException: <p>The request could not be completed due to a conflict with the current state of the resource.</p>
        capo_lambda_microvms.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_lambda_microvms.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You have exceeded a service quota for Lambda MicroVMs.</p>
        capo_lambda_microvms.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_lambda_microvms.types.create_microvm_image_request.CreateMicrovmImageRequest]",
    ) -> OperationResponse[
        "capo_lambda_microvms.types.create_microvm_image_response.CreateMicrovmImageResponse"
    ]:
        import capo_lambda_microvms._operations.lambda_microvms.create_microvm_image

        output, http_response = (
            capo_lambda_microvms._operations.lambda_microvms.create_microvm_image.create_microvm_image(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_lambda_microvms.types.create_microvm_image_request.CreateMicrovmImageRequest",
    ) -> dict[str, Any]:
        import capo_lambda_microvms.types.create_microvm_image_request

        return capo_lambda_microvms.types.create_microvm_image_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_lambda_microvms.types.create_microvm_image_response.CreateMicrovmImageResponse",
    ) -> dict[str, Any]:
        import capo_lambda_microvms.types.create_microvm_image_response

        return capo_lambda_microvms.types.create_microvm_image_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateMicrovmImage",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_lambda_microvms.types.create_microvm_image_request.CreateMicrovmImageRequest = {
        "base_image_arn": base_image_arn,
        "build_role_arn": build_role_arn,
        "code_artifact": code_artifact,
        "name": name,
    }
    if base_image_version is not None:
        input_["base_image_version"] = base_image_version
    if description is not None:
        input_["description"] = description
    if logging is not None:
        input_["logging"] = logging
    if egress_network_connectors is not None:
        input_["egress_network_connectors"] = egress_network_connectors
    if cpu_configurations is not None:
        input_["cpu_configurations"] = cpu_configurations
    if resources is not None:
        input_["resources"] = resources
    if additional_os_capabilities is not None:
        input_["additional_os_capabilities"] = additional_os_capabilities
    if hooks is not None:
        input_["hooks"] = hooks
    if environment_variables is not None:
        input_["environment_variables"] = environment_variables
    if tags is not None:
        input_["tags"] = tags
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output