createImportedImage method

Future<CreateImportedImageResult> createImportedImage({
  1. required String name,
  2. AgentSoftwareVersion? agentSoftwareVersion,
  3. List<ApplicationConfig>? appCatalogConfig,
  4. String? description,
  5. String? displayName,
  6. bool? dryRun,
  7. String? iamRoleArn,
  8. RuntimeValidationConfig? runtimeValidationConfig,
  9. String? sourceAmiId,
  10. Map<String, String>? tags,
  11. String? workspaceImageId,
})

Creates a custom WorkSpaces Applications image by importing an EC2 AMI. This allows you to use your own customized AMI to create WorkSpaces Applications images that support additional instance types beyond the standard stream.* instances.

May throw DryRunOperationException. May throw IncompatibleImageException. May throw InvalidAccountStatusException. May throw InvalidParameterCombinationException. May throw InvalidRoleException. May throw LimitExceededException. May throw OperationNotPermittedException. May throw ResourceAlreadyExistsException. May throw ResourceNotFoundException.

Parameter name : A unique name for the imported image. The name must be between 1 and 100 characters and can contain letters, numbers, underscores, periods, and hyphens.

Parameter agentSoftwareVersion : The version of the WorkSpaces Applications agent to use for the imported image. Choose CURRENT_LATEST to use the agent version available at the time of import, or ALWAYS_LATEST to automatically update to the latest agent version when new versions are released.

Parameter appCatalogConfig : Configuration for the application catalog of the imported image. This allows you to specify applications available for streaming, including their paths, icons, and launch parameters. This field contains sensitive data.

Parameter description : An optional description for the imported image. The description must match approved regex patterns and can be up to 256 characters.

Parameter displayName : An optional display name for the imported image. The display name must match approved regex patterns and can be up to 100 characters.

Parameter dryRun : When set to true, performs validation checks without actually creating the imported image. Use this to verify your configuration before executing the actual import operation.

Parameter iamRoleArn : The ARN of the IAM role that allows WorkSpaces Applications to access your AMI. The role must have permissions to modify image attributes and describe images, with a trust relationship allowing appstream.amazonaws.com to assume the role.

Parameter runtimeValidationConfig : Configuration for runtime validation of the imported image. When specified, WorkSpaces Applications provisions an instance to test streaming functionality, which helps ensure the image is suitable for use.

Parameter sourceAmiId : The ID of the EC2 AMI to import.

Parameter tags : The tags to apply to the imported image. Tags help you organize and manage your WorkSpaces Applications resources.

Parameter workspaceImageId : The ID of the Workspaces Image to import.

Implementation

Future<CreateImportedImageResult> createImportedImage({
  required String name,
  AgentSoftwareVersion? agentSoftwareVersion,
  List<ApplicationConfig>? appCatalogConfig,
  String? description,
  String? displayName,
  bool? dryRun,
  String? iamRoleArn,
  RuntimeValidationConfig? runtimeValidationConfig,
  String? sourceAmiId,
  Map<String, String>? tags,
  String? workspaceImageId,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'PhotonAdminProxyService.CreateImportedImage'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      if (agentSoftwareVersion != null)
        'AgentSoftwareVersion': agentSoftwareVersion.value,
      if (appCatalogConfig != null) 'AppCatalogConfig': appCatalogConfig,
      if (description != null) 'Description': description,
      if (displayName != null) 'DisplayName': displayName,
      if (dryRun != null) 'DryRun': dryRun,
      if (iamRoleArn != null) 'IamRoleArn': iamRoleArn,
      if (runtimeValidationConfig != null)
        'RuntimeValidationConfig': runtimeValidationConfig,
      if (sourceAmiId != null) 'SourceAmiId': sourceAmiId,
      if (tags != null) 'Tags': tags,
      if (workspaceImageId != null) 'WorkspaceImageId': workspaceImageId,
    },
  );

  return CreateImportedImageResult.fromJson(jsonResponse.body);
}