Skip to content

copy_workspace_image

copy_workspace_image(
    name: WorkspaceImageName,
    source_image_id: WorkspaceImageId,
    source_region: Region,
    *,
    config_overrides: Optional[WorkSpacesClientConfig] = None,
    description: Optional[WorkspaceImageDescription] = None,
    tags: Optional[TagList] = None,
) -> CopyWorkspaceImageResult

Copies the specified image from the specified Region to the current Region. For more information about copying images, see Copy a Custom WorkSpaces Image.

In the China (Ningxia) Region, you can copy images only within the same Region.

In Amazon Web Services GovCloud (US), to copy images to and from other Regions, contact Amazon Web Services Support.

Before copying a shared image, be sure to verify that it has been shared from the correct Amazon Web Services account. To determine if an image has been shared and to see the ID of the Amazon Web Services account that owns an image, use the DescribeWorkSpaceImages and DescribeWorkspaceImagePermissions API operations.

Parameters:

Raises:

Source code in docs_src/capo_workspaces/_services/work_spaces.py
def copy_workspace_image(
    self,
    name: "capo_workspaces.types.workspace_image_name.WorkspaceImageName",
    source_image_id: "capo_workspaces.types.workspace_image_id.WorkspaceImageId",
    source_region: "capo_workspaces.types.region.Region",
    *,
    config_overrides: Optional[WorkSpacesClientConfig] = None,
    description: Optional[
        "capo_workspaces.types.workspace_image_description.WorkspaceImageDescription"
    ] = None,
    tags: Optional["capo_workspaces.types.tag_list.TagList"] = None,
) -> "capo_workspaces.types.copy_workspace_image_result.CopyWorkspaceImageResult":
    """<p>Copies the specified image from the specified Region to the current Region. For more information about copying images, see <a href="https://docs.aws.amazon.com/workspaces/latest/adminguide/copy-custom-image.html"> Copy a Custom WorkSpaces Image</a>.</p> <p>In the China (Ningxia) Region, you can copy images only within the same Region.</p> <p>In Amazon Web Services GovCloud (US), to copy images to and from other Regions, contact Amazon Web Services Support.</p> <important> <p>Before copying a shared image, be sure to verify that it has been shared from the correct Amazon Web Services account. To determine if an image has been shared and to see the ID of the Amazon Web Services account that owns an image, use the <a href="https://docs.aws.amazon.com/workspaces/latest/api/API_DescribeWorkspaceImages.html">DescribeWorkSpaceImages</a> and <a href="https://docs.aws.amazon.com/workspaces/latest/api/API_DescribeWorkspaceImagePermissions.html">DescribeWorkspaceImagePermissions</a> API operations. </p> </important>

    Args:
        name: <p>The name of the image.</p>
        description: <p>A description of the image.</p>
        source_image_id: <p>The identifier of the source image.</p>
        source_region: <p>The identifier of the source Region.</p>
        tags: <p>The tags for the image.</p>

    Raises:
        capo_workspaces.errors.access_denied_exception.AccessDeniedException: <p>The user is not authorized to access a resource.</p>
        capo_workspaces.errors.invalid_parameter_values_exception.InvalidParameterValuesException: <p>One or more parameter values are not valid.</p>
        capo_workspaces.errors.operation_not_supported_exception.OperationNotSupportedException: <p>This operation is not supported.</p>
        capo_workspaces.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>The specified resource already exists.</p>
        capo_workspaces.errors.resource_limit_exceeded_exception.ResourceLimitExceededException: <p>Your resource limits have been exceeded.</p>
        capo_workspaces.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource could not be found.</p>
        capo_workspaces.errors.resource_unavailable_exception.ResourceUnavailableException: <p>The specified resource is not available.</p>
        capo_workspaces.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_workspaces.types.copy_workspace_image_request.CopyWorkspaceImageRequest]",
    ) -> OperationResponse[
        "capo_workspaces.types.copy_workspace_image_result.CopyWorkspaceImageResult"
    ]:
        import capo_workspaces._operations.workspaces_service.copy_workspace_image

        output, http_response = (
            capo_workspaces._operations.workspaces_service.copy_workspace_image.copy_workspace_image(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CopyWorkspaceImage")
    )
    input_: capo_workspaces.types.copy_workspace_image_request.CopyWorkspaceImageRequest = {
        "name": name,
        "source_image_id": source_image_id,
        "source_region": source_region,
    }
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags

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