Skip to content

start_table_migration

start_table_migration(
    role_arn: RoleArn,
    destination_table: DestinationTable,
    source_type: MigrationSourceType,
    source: SourceConfiguration,
    migration_output: MigrationOutputConfiguration,
    *,
    config_overrides: Optional[S3TablesClientConfig] = None,
    data_migration: Optional[DataMigrationSettings] = None,
    review_migration_plan: Optional[bool] = None,
) -> StartTableMigrationResponse

Starts migrating an Amazon Web Services Glue Data Catalog table into a new table in a table bucket. The migration runs asynchronously: this operation returns the migration ID and its initial state, and you track progress with GetTableMigration.

The namespace must already exist. If a table with the specified name already exists, the request fails with a ConflictException. The request has no client token. If a request times out, call ListTableMigrations to check whether the migration started before you retry.

The migration creates the table during planning and commits data to it as it runs. Until you call CompleteTableMigration, you can read the table, but you can't write to it. If the migration fails or is cancelled, the table and the data already committed to it remain.

The migration first checks the source and the destination, and writes the table compatibility and object compatibility reports to the bucket that you specify in migrationOutput. If you set reviewMigrationPlan to true, the migration waits in the pendingReview state so that you can review the reports, and continues only when you call UpdateTableMigration with requestedState set to queued. Otherwise, it continues to migrate the data, and writes the object migration report when the migration ends. If planning fails, the migration writes no object migration report.

Permissions
  • You must have the s3tables:StartTableMigration permission to use this operation.

  • You must have the iam:PassRole permission on the role that you specify in roleARN, with a condition that allows passing it to migration.s3tables.amazonaws.com. Set the iam:AssociatedResourceArn condition key to the table bucket ARN.

  • If destinationTable specifies SSE-KMS encryption, you must have the kms:DescribeKey and kms:GenerateDataKey permissions on the KMS key. You must also grant the S3 Tables maintenance principal access to the key. For more information, see Permissions requirements for S3 Tables SSE-KMS encryption.

Parameters:

  • role_arn (RoleArn) –

    The Amazon Resource Name (ARN) of the IAM role that the migration uses to read the source table and its data and to write the destination table and the reports. The role must be in your account, and its trust policy must allow migration.s3tables.amazonaws.com to assume it. You can limit the trust policy to the destination table bucket with the aws:SourceArn and aws:SourceAccount condition keys.

  • destination_table (DestinationTable) –

    The table to create and migrate the source into.

  • source_type (MigrationSourceType) –

    The type of the source. It must match the member that you set in source.

  • source (SourceConfiguration) –

    The source table to migrate.

  • data_migration (Optional[DataMigrationSettings], default: None ) –

    The maintenance settings and migration policies for the destination table.

  • review_migration_plan (Optional[bool], default: None ) –

    Specifies whether the migration waits in the pendingReview state, so that you can review the compatibility reports before it migrates any data. Valid values:

    • true - The migration waits in pendingReview until you call UpdateTableMigration with requestedState set to queued. If you don't continue or cancel the migration within 30 days, the migration fails with internalError.

    • false - The migration continues without waiting for review. This is the default.

  • migration_output (MigrationOutputConfiguration) –

    The bucket and prefixes that the migration writes its reports to. The bucket must be a general purpose bucket in your account and in the same Region as the table bucket, and the migration role must be able to write objects to it. Otherwise, the migration fails when it writes its first report.

Raises:

  • AccessDeniedException –

    The action cannot be performed because you do not have the required permission.

  • BadRequestException –

    The request is invalid or malformed.

  • ConflictException –

    The request conflicts with the resource's current state, such as a previous write, an existing table, or a migration that's in progress or already in the requested state. If the conflict is with a concurrent write, you can retry the request.

  • ForbiddenException –

    The caller isn't authorized to make the request.

  • InternalServerErrorException –

    The request failed due to an internal server error.

  • NotFoundException –

    The request was rejected because the specified resource could not be found.

  • TooManyRequestsException –

    The limit on the number of requests per second was exceeded.

  • UnknownServiceError –

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

Source code in docs_src/capo_s3tables/_services/s3_tables.py
def start_table_migration(
    self,
    role_arn: "capo_s3tables.types.role_arn.RoleArn",
    destination_table: "capo_s3tables.types.destination_table.DestinationTable",
    source_type: "capo_s3tables.types.migration_source_type.MigrationSourceType",
    source: "capo_s3tables.types.source_configuration.SourceConfiguration",
    migration_output: "capo_s3tables.types.migration_output_configuration.MigrationOutputConfiguration",
    *,
    config_overrides: Optional[S3TablesClientConfig] = None,
    data_migration: Optional[
        "capo_s3tables.types.data_migration_settings.DataMigrationSettings"
    ] = None,
    review_migration_plan: Optional[bool] = None,
) -> (
    "capo_s3tables.types.start_table_migration_response.StartTableMigrationResponse"
):
    """<p>Starts migrating an Amazon Web Services Glue Data Catalog table into a new table in a table bucket. The migration runs asynchronously: this operation returns the migration ID and its initial state, and you track progress with <code>GetTableMigration</code>.</p> <p>The namespace must already exist. If a table with the specified name already exists, the request fails with a <code>ConflictException</code>. The request has no client token. If a request times out, call <code>ListTableMigrations</code> to check whether the migration started before you retry.</p> <p>The migration creates the table during planning and commits data to it as it runs. Until you call <code>CompleteTableMigration</code>, you can read the table, but you can't write to it. If the migration fails or is cancelled, the table and the data already committed to it remain.</p> <p>The migration first checks the source and the destination, and writes the table compatibility and object compatibility reports to the bucket that you specify in <code>migrationOutput</code>. If you set <code>reviewMigrationPlan</code> to <code>true</code>, the migration waits in the <code>pendingReview</code> state so that you can review the reports, and continues only when you call <code>UpdateTableMigration</code> with <code>requestedState</code> set to <code>queued</code>. Otherwise, it continues to migrate the data, and writes the object migration report when the migration ends. If planning fails, the migration writes no object migration report.</p> <dl> <dt>Permissions</dt> <dd> <ul> <li> <p>You must have the <code>s3tables:StartTableMigration</code> permission to use this operation.</p> </li> <li> <p>You must have the <code>iam:PassRole</code> permission on the role that you specify in <code>roleARN</code>, with a condition that allows passing it to <code>migration.s3tables.amazonaws.com</code>. Set the <code>iam:AssociatedResourceArn</code> condition key to the table bucket ARN.</p> </li> <li> <p>If <code>destinationTable</code> specifies SSE-KMS encryption, you must have the <code>kms:DescribeKey</code> and <code>kms:GenerateDataKey</code> permissions on the KMS key. You must also grant the S3 Tables maintenance principal access to the key. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-kms-permissions.html">Permissions requirements for S3 Tables SSE-KMS encryption</a>.</p> </li> </ul> </dd> </dl>

    Args:
        role_arn: <p>The Amazon Resource Name (ARN) of the IAM role that the migration uses to read the source table and its data and to write the destination table and the reports. The role must be in your account, and its trust policy must allow <code>migration.s3tables.amazonaws.com</code> to assume it. You can limit the trust policy to the destination table bucket with the <code>aws:SourceArn</code> and <code>aws:SourceAccount</code> condition keys.</p>
        destination_table: <p>The table to create and migrate the source into.</p>
        source_type: <p>The type of the source. It must match the member that you set in <code>source</code>.</p>
        source: <p>The source table to migrate.</p>
        data_migration: <p>The maintenance settings and migration policies for the destination table.</p>
        review_migration_plan: <p>Specifies whether the migration waits in the <code>pendingReview</code> state, so that you can review the compatibility reports before it migrates any data. Valid values:</p> <ul> <li> <p> <code>true</code> - The migration waits in <code>pendingReview</code> until you call <code>UpdateTableMigration</code> with <code>requestedState</code> set to <code>queued</code>. If you don't continue or cancel the migration within 30 days, the migration fails with <code>internalError</code>.</p> </li> <li> <p> <code>false</code> - The migration continues without waiting for review. This is the default.</p> </li> </ul>
        migration_output: <p>The bucket and prefixes that the migration writes its reports to. The bucket must be a general purpose bucket in your account and in the same Region as the table bucket, and the migration role must be able to write objects to it. Otherwise, the migration fails when it writes its first report.</p>

    Raises:
        capo_s3tables.errors.access_denied_exception.AccessDeniedException: <p>The action cannot be performed because you do not have the required permission.</p>
        capo_s3tables.errors.bad_request_exception.BadRequestException: <p>The request is invalid or malformed.</p>
        capo_s3tables.errors.conflict_exception.ConflictException: <p>The request conflicts with the resource's current state, such as a previous write, an existing table, or a migration that's in progress or already in the requested state. If the conflict is with a concurrent write, you can retry the request.</p>
        capo_s3tables.errors.forbidden_exception.ForbiddenException: <p>The caller isn't authorized to make the request.</p>
        capo_s3tables.errors.internal_server_error_exception.InternalServerErrorException: <p>The request failed due to an internal server error.</p>
        capo_s3tables.errors.not_found_exception.NotFoundException: <p>The request was rejected because the specified resource could not be found.</p>
        capo_s3tables.errors.too_many_requests_exception.TooManyRequestsException: <p>The limit on the number of requests per second was exceeded.</p>
        capo_s3tables.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_s3tables.types.start_table_migration_request.StartTableMigrationRequest]",
    ) -> OperationResponse[
        "capo_s3tables.types.start_table_migration_response.StartTableMigrationResponse"
    ]:
        import capo_s3tables._operations.s3_table_buckets.start_table_migration

        output, http_response = (
            capo_s3tables._operations.s3_table_buckets.start_table_migration.start_table_migration(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("StartTableMigration")
    )
    input_: capo_s3tables.types.start_table_migration_request.StartTableMigrationRequest = {
        "role_arn": role_arn,
        "destination_table": destination_table,
        "source_type": source_type,
        "source": source,
        "migration_output": migration_output,
    }
    if data_migration is not None:
        input_["data_migration"] = data_migration
    if review_migration_plan is not None:
        input_["review_migration_plan"] = review_migration_plan

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