ステップ 9 (オプション): リソースをクリーンアップする - Amazon Quantum 台帳データベース (Amazon QLDB)

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

ステップ 9 (オプション): リソースをクリーンアップする

重要

サポート終了通知: 既存のお客様は、07/31/2025 のサポート終了QLDBまで Amazon を使用できます。詳細については、「Amazon Ledger QLDB を Amazon Aurora Postgre に移行するSQL」を参照してください。

vehicle-registration 台帳は引き続き使用できます。ただし、不要になった場合は、削除することをお勧めします。

台帳を削除するには
  1. 次のプログラム (DeleteLedger.java) をコンパイルし実行して、vehicle-registration 台帳とその内容のすべてを削除します。

    /* * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: MIT-0 * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * software and associated documentation files (the "Software"), to deal in the Software * without restriction, including without limitation the rights to use, copy, modify, * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package software.amazon.qldb.tutorial; import com.amazonaws.services.qldb.AmazonQLDB; import com.amazonaws.services.qldb.model.DeleteLedgerRequest; import com.amazonaws.services.qldb.model.DeleteLedgerResult; import com.amazonaws.services.qldb.model.ResourceNotFoundException; import com.amazonaws.services.qldb.model.UpdateLedgerRequest; import com.amazonaws.services.qldb.model.UpdateLedgerResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Delete a ledger. * * This code expects that you have AWS credentials setup per: * http://docs.aws.amazon.com/java-sdk/latest/developer-guide/setup-credentials.html */ public final class DeleteLedger { public static final Logger log = LoggerFactory.getLogger(DeleteLedger.class); public static final Long LEDGER_DELETION_POLL_PERIOD_MS = 20_000L; public static AmazonQLDB client = CreateLedger.getClient(); private DeleteLedger() { } public static void main(String... args) throws Exception { try { setDeletionProtection(Constants.LEDGER_NAME, false); delete(Constants.LEDGER_NAME); waitForDeleted(Constants.LEDGER_NAME); } catch (Exception e) { log.error("Unable to delete the ledger.", e); throw e; } } /** * Send a request to the QLDB database to delete the specified ledger. * * @param ledgerName * Name of the ledger to be deleted. * @return DeleteLedgerResult. */ public static DeleteLedgerResult delete(final String ledgerName) { log.info("Attempting to delete the ledger with name: {}...", ledgerName); DeleteLedgerRequest request = new DeleteLedgerRequest().withName(ledgerName); DeleteLedgerResult result = client.deleteLedger(request); log.info("Success."); return result; } /** * Wait for the ledger to be deleted. * * @param ledgerName * Name of the ledger being deleted. * @throws InterruptedException if thread is being interrupted. */ public static void waitForDeleted(final String ledgerName) throws InterruptedException { log.info("Waiting for the ledger to be deleted..."); while (true) { try { DescribeLedger.describe(ledgerName); log.info("The ledger is still being deleted. Please wait..."); Thread.sleep(LEDGER_DELETION_POLL_PERIOD_MS); } catch (ResourceNotFoundException ex) { log.info("Success. The ledger is deleted."); break; } } } public static UpdateLedgerResult setDeletionProtection(String ledgerName, boolean deletionProtection) { log.info("Let's set deletionProtection to {} for the ledger with name {}", deletionProtection, ledgerName); UpdateLedgerRequest request = new UpdateLedgerRequest() .withName(ledgerName) .withDeletionProtection(deletionProtection); UpdateLedgerResult result = client.updateLedger(request); log.info("Success. Ledger updated: {}", result); return result; } }
    注記

    台帳の削除保護が有効になっている場合は、 を使用して台帳を削除する前に、まず台帳を無効にする必要がありますQLDBAPI。

  2. 前のステップでジャーナルデータをエクスポートした場合、不要になったら Simple Storage Service (Amazon S3) コンソールを使用して S3 バケットを削除します。

    で Amazon S3 コンソールを開きますhttps://console.aws.amazon.com/s3/