createMicrovmImage method

Future<CreateMicrovmImageResponse> createMicrovmImage({
  1. required String baseImageArn,
  2. required String buildRoleArn,
  3. required CodeArtifact codeArtifact,
  4. required String name,
  5. List<Capability>? additionalOsCapabilities,
  6. String? baseImageVersion,
  7. String? clientToken,
  8. List<CpuConfiguration>? cpuConfigurations,
  9. String? description,
  10. List<String>? egressNetworkConnectors,
  11. Map<String, String>? environmentVariables,
  12. Hooks? hooks,
  13. Logging? logging,
  14. List<Resources>? resources,
  15. Map<String, String>? tags,
})

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.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

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

Parameter buildRoleArn : 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.

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

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

Parameter additionalOsCapabilities : Additional OS capabilities granted to the MicroVM runtime environment.

Parameter baseImageVersion : The specific version of the base MicroVM image to use.

Parameter clientToken : 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.

Parameter cpuConfigurations : The list of supported CPU configurations for the MicroVM.

Parameter description : A description of the MicroVM image.

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

Parameter environmentVariables : Environment variables set in the MicroVM runtime environment.

Parameter logging : 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.

Parameter resources : The resource requirements for the MicroVM.

Parameter tags : 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.

Implementation

Future<CreateMicrovmImageResponse> createMicrovmImage({
  required String baseImageArn,
  required String buildRoleArn,
  required CodeArtifact codeArtifact,
  required String name,
  List<Capability>? additionalOsCapabilities,
  String? baseImageVersion,
  String? clientToken,
  List<CpuConfiguration>? cpuConfigurations,
  String? description,
  List<String>? egressNetworkConnectors,
  Map<String, String>? environmentVariables,
  Hooks? hooks,
  Logging? logging,
  List<Resources>? resources,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'baseImageArn': baseImageArn,
    'buildRoleArn': buildRoleArn,
    'codeArtifact': codeArtifact,
    'name': name,
    if (additionalOsCapabilities != null)
      'additionalOsCapabilities':
          additionalOsCapabilities.map((e) => e.value).toList(),
    if (baseImageVersion != null) 'baseImageVersion': baseImageVersion,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (cpuConfigurations != null) 'cpuConfigurations': cpuConfigurations,
    if (description != null) 'description': description,
    if (egressNetworkConnectors != null)
      'egressNetworkConnectors': egressNetworkConnectors,
    if (environmentVariables != null)
      'environmentVariables': environmentVariables,
    if (hooks != null) 'hooks': hooks,
    if (logging != null) 'logging': logging,
    if (resources != null) 'resources': resources,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/2025-09-09/microvm-images',
    exceptionFnMap: _exceptionFns,
  );
  return CreateMicrovmImageResponse.fromJson(response);
}