Skip to content

copy_project_version

copy_project_version(
    source_project_arn: ProjectArn,
    source_project_version_arn: ProjectVersionArn,
    destination_project_arn: ProjectArn,
    version_name: VersionName,
    output_config: OutputConfig,
    *,
    config_overrides: Optional[RekognitionClientConfig] = None,
    tags: Optional[TagMap] = None,
    kms_key_id: Optional[KmsKeyId] = None,
) -> CopyProjectVersionResponse

This operation applies only to Amazon Rekognition Custom Labels.

Copies a version of an Amazon Rekognition Custom Labels model from a source project to a destination project. The source and destination projects can be in different AWS accounts but must be in the same AWS Region. You can't copy a model to another AWS service.

To copy a model version to a different AWS account, you need to create a resource-based policy known as a project policy. You attach the project policy to the source project by calling PutProjectPolicy. The project policy gives permission to copy the model version from a trusting AWS account to a trusted account.

For more information creating and attaching a project policy, see Attaching a project policy (SDK) in the Amazon Rekognition Custom Labels Developer Guide.

If you are copying a model version to a project in the same AWS account, you don't need to create a project policy.

Copying project versions is supported only for Custom Labels models.

To copy a model, the destination project, source project, and source model version must already exist.

Copying a model version takes a while to complete. To get the current status, call DescribeProjectVersions and check the value of Status in the ProjectVersionDescription object. The copy operation has finished when the value of Status is COPYING_COMPLETED.

This operation requires permissions to perform the rekognition:CopyProjectVersion action.

Parameters:

  • source_project_arn (ProjectArn) –

    The ARN of the source project in the trusting AWS account.

  • source_project_version_arn (ProjectVersionArn) –

    The ARN of the model version in the source project that you want to copy to a destination project.

  • destination_project_arn (ProjectArn) –

    The ARN of the project in the trusted AWS account that you want to copy the model version to.

  • version_name (VersionName) –

    A name for the version of the model that's copied to the destination project.

  • output_config (OutputConfig) –

    The S3 bucket and folder location where the training output for the source model version is placed.

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

    The key-value tags to assign to the model version.

  • kms_key_id (Optional[KmsKeyId], default: None ) –

    The identifier for your AWS Key Management Service key (AWS KMS key). You can supply the Amazon Resource Name (ARN) of your KMS key, the ID of your KMS key, an alias for your KMS key, or an alias ARN. The key is used to encrypt training results and manifest files written to the output Amazon S3 bucket (OutputConfig).

    If you choose to use your own KMS key, you need the following permissions on the KMS key.

    • kms:CreateGrant

    • kms:DescribeKey

    • kms:GenerateDataKey

    • kms:Decrypt

    If you don't specify a value for KmsKeyId, images copied into the service are encrypted using a key that AWS owns and manages.

Raises:

  • AccessDeniedException –

    You are not authorized to perform the action.

  • InternalServerError –

    Amazon Rekognition experienced a service issue. Try your call again.

  • InvalidParameterException –

    Input parameter violated a constraint. Validate your parameter before calling the API operation again.

  • LimitExceededException –

    An Amazon Rekognition service limit was exceeded. For example, if you start too many jobs concurrently, subsequent calls to start operations (ex: StartLabelDetection) will raise a LimitExceededException exception (HTTP status code: 400) until the number of concurrently running jobs is below the Amazon Rekognition service limit.

  • ProvisionedThroughputExceededException –

    The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.

  • ResourceInUseException –

    The specified resource is already being used.

  • ResourceNotFoundException –

    The resource specified in the request cannot be found.

  • ServiceQuotaExceededException –

    The size of the collection exceeds the allowed limit. For more information, see Guidelines and quotas in Amazon Rekognition in the Amazon Rekognition Developer Guide.

  • ThrottlingException –

    Amazon Rekognition is temporarily unable to process the request. Try your call again.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

CopyProjectVersion Copies a version of an Amazon Rekognition Custom Labels model from a source project to a destination project.

>>> client.copy_project_version(source_project_arn='arn:aws:rekognition:us-east-1:111122223333:project/SourceProject/16565123456', source_project_version_arn='arn:aws:rekognition:us-east-1:111122223333:project/SourceProject/version/model_1/1656611123456', destination_project_arn='arn:aws:rekognition:us-east-1:555555555555:project/DestinationProject/1656705098765', version_name='DestinationVersionName_cross_account', output_config={'S3Bucket': 'bucket-name', 'S3KeyPrefix': 'path_to_folder'}, tags={'key1': 'val1'}, kms_key_id='arn:1234abcd-12ab-34cd-56ef-1234567890ab')
Source code in docs_src/capo_rekognition/_services/rekognition.py
def copy_project_version(
    self,
    source_project_arn: "capo_rekognition.types.project_arn.ProjectArn",
    source_project_version_arn: "capo_rekognition.types.project_version_arn.ProjectVersionArn",
    destination_project_arn: "capo_rekognition.types.project_arn.ProjectArn",
    version_name: "capo_rekognition.types.version_name.VersionName",
    output_config: "capo_rekognition.types.output_config.OutputConfig",
    *,
    config_overrides: Optional[RekognitionClientConfig] = None,
    tags: Optional["capo_rekognition.types.tag_map.TagMap"] = None,
    kms_key_id: Optional["capo_rekognition.types.kms_key_id.KmsKeyId"] = None,
) -> "capo_rekognition.types.copy_project_version_response.CopyProjectVersionResponse":
    """<note> <p>This operation applies only to Amazon Rekognition Custom Labels.</p> </note> <p>Copies a version of an Amazon Rekognition Custom Labels model from a source project to a destination project. The source and destination projects can be in different AWS accounts but must be in the same AWS Region. You can't copy a model to another AWS service. </p> <p>To copy a model version to a different AWS account, you need to create a resource-based policy known as a <i>project policy</i>. You attach the project policy to the source project by calling <a>PutProjectPolicy</a>. The project policy gives permission to copy the model version from a trusting AWS account to a trusted account.</p> <p>For more information creating and attaching a project policy, see Attaching a project policy (SDK) in the <i>Amazon Rekognition Custom Labels Developer Guide</i>. </p> <p>If you are copying a model version to a project in the same AWS account, you don't need to create a project policy.</p> <note> <p>Copying project versions is supported only for Custom Labels models. </p> <p>To copy a model, the destination project, source project, and source model version must already exist.</p> </note> <p>Copying a model version takes a while to complete. To get the current status, call <a>DescribeProjectVersions</a> and check the value of <code>Status</code> in the <a>ProjectVersionDescription</a> object. The copy operation has finished when the value of <code>Status</code> is <code>COPYING_COMPLETED</code>.</p> <p>This operation requires permissions to perform the <code>rekognition:CopyProjectVersion</code> action.</p>

    Args:
        source_project_arn: <p>The ARN of the source project in the trusting AWS account.</p>
        source_project_version_arn: <p>The ARN of the model version in the source project that you want to copy to a destination project.</p>
        destination_project_arn: <p>The ARN of the project in the trusted AWS account that you want to copy the model version to. </p>
        version_name: <p>A name for the version of the model that's copied to the destination project.</p>
        output_config: <p>The S3 bucket and folder location where the training output for the source model version is placed.</p>
        tags: <p>The key-value tags to assign to the model version. </p>
        kms_key_id: <p>The identifier for your AWS Key Management Service key (AWS KMS key). You can supply the Amazon Resource Name (ARN) of your KMS key, the ID of your KMS key, an alias for your KMS key, or an alias ARN. The key is used to encrypt training results and manifest files written to the output Amazon S3 bucket (<code>OutputConfig</code>).</p> <p>If you choose to use your own KMS key, you need the following permissions on the KMS key.</p> <ul> <li> <p>kms:CreateGrant</p> </li> <li> <p>kms:DescribeKey</p> </li> <li> <p>kms:GenerateDataKey</p> </li> <li> <p>kms:Decrypt</p> </li> </ul> <p>If you don't specify a value for <code>KmsKeyId</code>, images copied into the service are encrypted using a key that AWS owns and manages.</p>

    Raises:
        capo_rekognition.errors.access_denied_exception.AccessDeniedException: <p>You are not authorized to perform the action.</p>
        capo_rekognition.errors.internal_server_error.InternalServerError: <p>Amazon Rekognition experienced a service issue. Try your call again.</p>
        capo_rekognition.errors.invalid_parameter_exception.InvalidParameterException: <p>Input parameter violated a constraint. Validate your parameter before calling the API operation again.</p>
        capo_rekognition.errors.limit_exceeded_exception.LimitExceededException: <p>An Amazon Rekognition service limit was exceeded. For example, if you start too many jobs concurrently, subsequent calls to start operations (ex: <code>StartLabelDetection</code>) will raise a <code>LimitExceededException</code> exception (HTTP status code: 400) until the number of concurrently running jobs is below the Amazon Rekognition service limit. </p>
        capo_rekognition.errors.provisioned_throughput_exceeded_exception.ProvisionedThroughputExceededException: <p>The number of requests exceeded your throughput limit. If you want to increase this limit, contact Amazon Rekognition.</p>
        capo_rekognition.errors.resource_in_use_exception.ResourceInUseException: <p>The specified resource is already being used.</p>
        capo_rekognition.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource specified in the request cannot be found.</p>
        capo_rekognition.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p></p> <p>The size of the collection exceeds the allowed limit. For more information, see Guidelines and quotas in Amazon Rekognition in the Amazon Rekognition Developer Guide. </p>
        capo_rekognition.errors.throttling_exception.ThrottlingException: <p>Amazon Rekognition is temporarily unable to process the request. Try your call again.</p>
        capo_rekognition.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        CopyProjectVersion
        Copies a version of an Amazon Rekognition Custom Labels model from a source project to a destination project.

        >>> client.copy_project_version(source_project_arn='arn:aws:rekognition:us-east-1:111122223333:project/SourceProject/16565123456', source_project_version_arn='arn:aws:rekognition:us-east-1:111122223333:project/SourceProject/version/model_1/1656611123456', destination_project_arn='arn:aws:rekognition:us-east-1:555555555555:project/DestinationProject/1656705098765', version_name='DestinationVersionName_cross_account', output_config={'S3Bucket': 'bucket-name', 'S3KeyPrefix': 'path_to_folder'}, tags={'key1': 'val1'}, kms_key_id='arn:1234abcd-12ab-34cd-56ef-1234567890ab')
    """

    def _handler(
        req: "OperationRequest[capo_rekognition.types.copy_project_version_request.CopyProjectVersionRequest]",
    ) -> OperationResponse[
        "capo_rekognition.types.copy_project_version_response.CopyProjectVersionResponse"
    ]:
        import capo_rekognition._operations.rekognition_service.copy_project_version

        output, http_response = (
            capo_rekognition._operations.rekognition_service.copy_project_version.copy_project_version(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CopyProjectVersion")
    )
    input_: capo_rekognition.types.copy_project_version_request.CopyProjectVersionRequest = {
        "source_project_arn": source_project_arn,
        "source_project_version_arn": source_project_version_arn,
        "destination_project_arn": destination_project_arn,
        "version_name": version_name,
        "output_config": output_config,
    }
    if tags is not None:
        input_["tags"] = tags
    if kms_key_id is not None:
        input_["kms_key_id"] = kms_key_id

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