기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
8단계(선택 사항): 리소스 정리
중요
지원 종료 알림: 기존 고객은 2025년 7월 31일 지원이 종료될 QLDB 때까지 Amazon을 사용할 수 있습니다. 자세한 내용은 아마존 QLDB 원장을 Amazon Aurora SQL Postgre로 마이그레이션을
vehicle-registration
원장을 계속 사용할 수 있습니다. 그러나 더 이상 필요하지 않은 경우 삭제해야 합니다.
원장을 삭제하려면
-
다음 프로그램(
DeleteLedger.ts
)을 사용하여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. */ import { isResourceNotFoundException } from "amazon-qldb-driver-nodejs"; import { AWSError, QLDB } from "aws-sdk"; import { DeleteLedgerRequest, DescribeLedgerRequest } from "aws-sdk/clients/qldb"; import { setDeletionProtection } from "./DeletionProtection"; import { LEDGER_NAME } from "./qldb/Constants"; import { error, log } from "./qldb/LogUtil"; import { sleep } from "./qldb/Util"; const LEDGER_DELETION_POLL_PERIOD_MS = 20000; /** * Send a request to QLDB to delete the specified ledger. * @param ledgerName Name of the ledger to be deleted. * @param qldbClient The QLDB control plane client to use. * @returns Promise which fulfills with void. */ export async function deleteLedger(ledgerName: string, qldbClient: QLDB): Promise<void> { log(`Attempting to delete the ledger with name: ${ledgerName}`); const request: DeleteLedgerRequest = { Name: ledgerName }; await qldbClient.deleteLedger(request).promise(); log("Success."); } /** * Wait for the ledger to be deleted. * @param ledgerName Name of the ledger to be deleted. * @param qldbClient The QLDB control plane client to use. * @returns Promise which fulfills with void. */ export async function waitForDeleted(ledgerName: string, qldbClient: QLDB): Promise<void> { log("Waiting for the ledger to be deleted..."); const request: DescribeLedgerRequest = { Name: ledgerName }; let isDeleted: boolean = false; while (true) { await qldbClient.describeLedger(request).promise().catch((error: AWSError) => { if (isResourceNotFoundException(error)) { isDeleted = true; log("Success. Ledger is deleted."); } }); if (isDeleted) { break; } log("The ledger is still being deleted. Please wait..."); await sleep(LEDGER_DELETION_POLL_PERIOD_MS); } } /** * Delete a ledger. * @returns Promise which fulfills with void. */ const main = async function(): Promise<void> { try { const qldbClient: QLDB = new QLDB(); await setDeletionProtection(LEDGER_NAME, qldbClient, false); await deleteLedger(LEDGER_NAME, qldbClient); await waitForDeleted(LEDGER_NAME, qldbClient); } catch (e) { error(`Unable to delete the ledger: ${e}`); } } if (require.main === module) { main(); }
참고
원장에 삭제 방지가 활성화되어 있는 경우 를 사용하여 원장을 삭제하려면 먼저 이를 비활성화해야 합니다. QLDB API
-
트랜스파일된 프로그램을 실행하려면 다음 명령을 입력합니다.
node dist/DeleteLedger.js