Cloud KMS 리소스 삭제

이 문서에서는 Cloud Key Management Service 키와 키 버전을 영구적으로 삭제하는 방법을 보여줍니다. 이 작업은 되돌릴 수 없습니다.

Cloud KMS에서 삭제와 삭제는 서로 다른 작업입니다.

  • 폐기: 지정된 폐기 기간이 지난 후 기본 키 자료를 되돌릴 수 없을 정도로 폐기하는 것을 포함하여 키 버전을 영구적으로 사용 중지합니다. DESTROYED 상태의 키 버전은 암호화 작업에 사용할 수 없으며 더 이상 청구되지 않습니다. 데이터 암호화에 사용된 키 버전을 폐기하여 영구적으로 복구할 수 없도록 하려는 데이터를 암호화 삭제할 수 있습니다. 삭제된 키 버전은 Cloud KMS 리소스 목록에 계속 포함됩니다.

  • 삭제: Google Cloud 콘솔, Google Cloud CLI, Cloud Key Management Service API, 클라이언트 라이브러리의 Cloud KMS 리소스 목록에서 키 또는 키 버전을 삭제합니다. 더 이상 활성 상태가 아닌 키 또는 키 버전이 많은 프로젝트의 경우 삭제하면 검색 및 목록 작업이 간소화됩니다. 삭제된 CryptoKey 이름은 재사용할 수 없습니다. retiredResources.list 메서드를 사용하여 재사용할 수 없는 삭제된 CryptoKey 이름 목록을 볼 수 있습니다.

시작하기 전에

Cloud KMS 리소스를 삭제하고 보는 데 필요한 권한을 얻으려면 관리자에게 키에 대한 Cloud KMS 관리자 (roles/cloudkms.admin) IAM 역할을 부여해 달라고 요청하세요. 역할 부여에 대한 자세한 내용은 프로젝트, 폴더, 조직에 대한 액세스 관리를 참조하세요.

이 사전 정의된 역할에는 Cloud KMS 리소스를 삭제하고 보는 데 필요한 권한이 포함되어 있습니다. 필요한 정확한 권한을 보려면 필수 권한 섹션을 펼치세요.

필수 권한

Cloud KMS 리소스를 삭제하고 보려면 다음 권한이 필요합니다.

  • 키 버전을 삭제하려면 다음 안내를 따르세요. cloudkms.cryptoKeyVersions.delete
  • 키를 삭제하려면 다음 단계를 따르세요. cloudkms.cryptoKeys.delete
  • 삭제된 리소스를 보려면 다음 단계를 따르세요.
    • cloudkms.retiredResources.get
    • cloudkms.retiredResources.list

커스텀 역할이나 다른 사전 정의된 역할을 사용하여 이 권한을 부여받을 수도 있습니다.

키 버전 삭제

키 버전이 DESTROYED, IMPORT_FAILED 또는 GENERATION_FAILED 상태인 경우 삭제할 수 있습니다. 키 버전을 가져온 경우 가져오기에 실패한 경우에만 삭제할 수 있습니다.

키 버전을 영구적으로 삭제하려면 다음 단계를 따르세요.

콘솔

  1. Google Cloud 콘솔에서 키 관리 페이지로 이동합니다.

    Key Management Service로 이동

  2. 삭제하려는 키와 키 버전이 포함된 키링의 이름을 클릭합니다.

  3. 삭제하려는 키 버전이 포함된 키를 클릭합니다.

  4. 버전 표에서 삭제할 키 버전을 찾은 다음 작업 더보기를 클릭합니다.

  5. 추가 작업 메뉴에서 삭제를 클릭합니다.

  6. 확인 메시지에서 키 이름을 입력한 다음 삭제를 클릭합니다.

gcloud

키 버전을 삭제하려면 다음 명령어를 실행합니다.

gcloud kms keys versions delete KEY_VERSION \
    --location=LOCATION \
    --keyring=KEY_RING \
    --key=KEY_NAME

다음을 바꿉니다.

  • KEY_VERSION: 영구적으로 삭제하려는 키 버전의 번호입니다. 표시된 키 버전은 DESTROYED, IMPORT_FAILED 또는 GENERATION_FAILED 상태여야 합니다.
  • LOCATION: 키링의 Cloud KMS 위치입니다.
  • KEY_RING: 키가 포함된 키링의 이름입니다.
  • KEY_NAME: 영구 삭제하려는 키 버전이 포함된 키의 이름입니다.

Go

Cloud KMS용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud KMS 클라이언트 라이브러리를 참조하세요.

Cloud KMS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import (
	"context"
	"fmt"
	"io"

	kms "cloud.google.com/go/kms/apiv1"
	"cloud.google.com/go/kms/apiv1/kmspb"
)

// deleteCryptoKeyVersion deletes a crypto key version. This action is permanent and cannot be undone. Once the key version is deleted, it will no longer exist.
func deleteCryptoKeyVersion(w io.Writer, name string) error {
	// name := "projects/my-project/locations/us-east1/keyRings/my-key-ring/cryptoKeys/my-key/cryptoKeyVersions/1"

	// Create the client.
	ctx := context.Background()
	client, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		return fmt.Errorf("failed to create kms client: %w", err)
	}
	defer client.Close()

	// Build the request.
	req := &kmspb.DeleteCryptoKeyVersionRequest{
		Name: name,
	}

	// Call the API.
	// Warning: This operation is permanent and cannot be undone.
	op, err := client.DeleteCryptoKeyVersion(ctx, req)
	if err != nil {
		return fmt.Errorf("failed to delete crypto key version: %w", err)
	}

	// Wait for the operation to complete.
	if err := op.Wait(ctx); err != nil {
		return fmt.Errorf("failed to wait for delete crypto key version operation: %w", err)
	}

	fmt.Fprintf(w, "Deleted crypto key version: %s\n", req.Name)
	return nil
}

Java

Cloud KMS용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud KMS 클라이언트 라이브러리를 참조하세요.

Cloud KMS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.cloud.kms.v1.CryptoKeyVersionName;
import com.google.cloud.kms.v1.KeyManagementServiceClient;
import java.io.IOException;

public class DeleteKeyVersion {

  public void deleteKeyVersion() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String locationId = "us-east1";
    String keyRingId = "my-key-ring";
    String keyId = "my-key";
    String keyVersionId = "123";
    deleteKeyVersion(projectId, locationId, keyRingId, keyId, keyVersionId);
  }

  // deleteKeyVersion deletes a key version. This action is permanent and cannot be undone. Once the
  // key version is deleted, it will no longer exist.
  public void deleteKeyVersion(
      String projectId, String locationId, String keyRingId, String keyId, String keyVersionId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only
    // needs to be created once, and can be reused for multiple requests. After
    // completing all of your requests, call the "close" method on the client to
    // safely clean up any remaining background resources.
    try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {
      // Build the key version name from the project, location, key ring, key,
      // and key version.
      CryptoKeyVersionName keyVersionName =
          CryptoKeyVersionName.of(projectId, locationId, keyRingId, keyId, keyVersionId);

      // Delete the key version.
      // Warning: This operation is permanent and cannot be undone.
      // Wait for the operation to complete.
      client.deleteCryptoKeyVersionAsync(keyVersionName).get();
      System.out.printf("Deleted key version: %s%n", keyVersionName.toString());
    } catch (Exception e) {
      System.err.printf("Failed to delete key version: %s%n", e.getMessage());
    }
  }
}

Python

Cloud KMS용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud KMS 클라이언트 라이브러리를 참조하세요.

Cloud KMS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import kms


def delete_key_version(
    project_id: str, location_id: str, key_ring_id: str, key_id: str, version_id: str
) -> None:
    """
    Delete the given key version. This action is permanent and cannot be undone.
    Once the key version is deleted, it will no longer exist.

    Args:
        project_id (str): Google Cloud project ID (e.g. 'my-project').
        location_id (str): Cloud KMS location (e.g. 'us-east1').
        key_ring_id (str): ID of the Cloud KMS key ring (e.g. 'my-key-ring').
        key_id (str): ID of the key to use (e.g. 'my-key').
        version_id (str): ID of the key version to delete (e.g. '1').

    Returns:
        None

    """

    # Create the client.
    client = kms.KeyManagementServiceClient()

    # Build the key version name.
    key_version_name = client.crypto_key_version_path(
        project_id, location_id, key_ring_id, key_id, version_id
    )

    # Call the API.
    # Note: delete_crypto_key_version returns a long-running operation.
    # Warning: This operation is permanent and cannot be undone.
    operation = client.delete_crypto_key_version(request={"name": key_version_name})

    # Wait for the operation to complete.
    operation.result()

    print(f"Deleted key version: {key_version_name}")

API

  1. 키 버전을 삭제하려면 cryptoKeyVersions.delete 메서드를 호출합니다. 이 메서드는 키 버전이 삭제되었는지 확인하기 위해 폴링할 수 있는 장기 실행 작업을 반환합니다.

    curl "https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME/cryptoKeyVersions/KEY_VERSION" \
    --request "DELETE" \
    --header "authorization: Bearer TOKEN"
    

    다음을 바꿉니다.

    • PROJECT_ID: 키링이 포함된 프로젝트의 ID입니다.
    • LOCATION: 키링의 Cloud KMS 위치입니다.
    • KEY_RING: 키가 포함된 키링의 이름입니다.
    • KEY_NAME: 영구 삭제하려는 키 버전이 포함된 키의 이름입니다.
    • KEY_VERSION: 영구적으로 삭제하려는 키 버전의 번호입니다. 표시된 키 버전은 DESTROYED, IMPORT_FAILED 또는 GENERATION_FAILED 상태여야 합니다.

    명령어의 출력은 Operation를 반환합니다. 다음 단계에는 작업의 name가 필요합니다.

  2. 키 버전이 삭제되었는지 확인하려면 operations.get 메서드를 호출하면 됩니다.

    curl "https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_NAME" \
        --request "GET" \
        --header "authorization: Bearer TOKEN"
    

    다음을 바꿉니다.

    • PROJECT_ID: 키링이 포함된 프로젝트의 ID입니다.
    • LOCATION: 키링의 Cloud KMS 위치입니다.
    • OPERATION_NAME: 이전 메서드에서 반환된 작업의 이름입니다.

    이 메서드의 출력에 donetrue로 표시되면 작업이 완료된 것입니다. error가 표시되지 않으면 키 버전이 영구적으로 삭제된 것입니다.

키 삭제

다음 조건을 충족하는 경우 키를 삭제할 수 있습니다.

  • 키에 아직 삭제되지 않은 키 버전이 포함되어 있지 않습니다.
  • 키에 자동 키 순환이 예약되어 있지 않습니다.
  • 키가 Cloud KMS Autokey로 생성되지 않았습니다.

키를 영구적으로 삭제하려면 다음 단계를 따르세요.

콘솔

  1. Google Cloud 콘솔에서 키 관리 페이지로 이동합니다.

    Key Management Service로 이동

  2. 삭제할 키가 포함된 키링의 이름을 클릭합니다.

  3. 다음 위치 중 하나에서 키를 삭제합니다.

    • 키 목록 페이지: 'KEY_RING' 키링의 키 표에서 삭제하려는 키를 찾아 키 작업을 클릭한 다음 삭제를 클릭합니다.
    • 키 세부정보 페이지: 삭제할 키의 이름을 클릭하여 키 세부정보 페이지를 엽니다. 페이지 상단에서 삭제를 클릭합니다.
  4. 확인 메시지에서 키 이름을 입력한 다음 삭제를 클릭합니다.

gcloud

키를 삭제하려면 다음 명령어를 실행합니다.

gcloud kms keys delete KEY_NAME \
    --location=LOCATION \
    --keyring=KEY_RING

다음을 바꿉니다.

  • KEY_NAME: 영구적으로 삭제하려는 키의 이름입니다. 키에 아직 삭제되지 않은 키 버전이 포함되어 있으면 안 되며, Autokey로 생성된 키여도 안 됩니다.
  • LOCATION: 키링의 Cloud KMS 위치입니다.
  • KEY_RING: 키가 포함된 키링의 이름입니다.

Go

Cloud KMS용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud KMS 클라이언트 라이브러리를 참조하세요.

Cloud KMS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import (
	"context"
	"fmt"
	"io"

	kms "cloud.google.com/go/kms/apiv1"
	"cloud.google.com/go/kms/apiv1/kmspb"
)

// deleteCryptoKey deletes a crypto key. This action is permanent and cannot be undone. Once the key is deleted, it will no longer exist.
func deleteCryptoKey(w io.Writer, name string) error {
	// name := "projects/my-project/locations/us-east1/keyRings/my-key-ring/cryptoKeys/my-key"

	// Create the client.
	ctx := context.Background()
	client, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		return fmt.Errorf("failed to create kms client: %w", err)
	}
	defer client.Close()

	// Build the request.
	req := &kmspb.DeleteCryptoKeyRequest{
		Name: name,
	}

	// Call the API.
	// Warning: This operation is permanent and cannot be undone.
	op, err := client.DeleteCryptoKey(ctx, req)
	if err != nil {
		return fmt.Errorf("failed to delete crypto key: %w", err)
	}

	// Wait for the operation to complete.
	if err := op.Wait(ctx); err != nil {
		return fmt.Errorf("failed to wait for delete crypto key operation: %w", err)
	}

	fmt.Fprintf(w, "Deleted crypto key: %s\n", req.Name)
	return nil
}

Java

Cloud KMS용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud KMS 클라이언트 라이브러리를 참조하세요.

Cloud KMS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.cloud.kms.v1.CryptoKeyName;
import com.google.cloud.kms.v1.DeleteCryptoKeyMetadata;
import com.google.cloud.kms.v1.KeyManagementServiceClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

public class DeleteKey {

  public void deleteKey() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String locationId = "us-east1";
    String keyRingId = "my-key-ring";
    String keyId = "my-key";
    deleteKey(projectId, locationId, keyRingId, keyId);
  }

  // deleteKey deletes a crypto key. This action is permanent and cannot be undone. Once the key
  // is deleted, it will no longer exist.
  public void deleteKey(String projectId, String locationId, String keyRingId, String keyId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only
    // needs to be created once, and can be reused for multiple requests. After
    // completing all of your requests, call the "close" method on the client to
    // safely clean up any remaining background resources.
    try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {
      // Build the key name from the project, location, key ring, and key.
      CryptoKeyName keyName = CryptoKeyName.of(projectId, locationId, keyRingId, keyId);

      // Delete the key.
      // Warning: This operation is permanent and cannot be undone.
      // Wait for the operation to complete.
      client.deleteCryptoKeyAsync(keyName).get();
      System.out.printf("Deleted key: %s%n", keyName.toString());
    } catch (Exception e) {
      System.err.printf("Failed to delete key: %s%n", e.getMessage());
    }
  }
}

Python

Cloud KMS용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud KMS 클라이언트 라이브러리를 참조하세요.

Cloud KMS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import kms


def delete_key(
    project_id: str, location_id: str, key_ring_id: str, key_id: str
) -> None:
    """
    Delete the given key. This action is permanent and cannot be undone. Once the
    key is deleted, it will no longer exist.

    Args:
        project_id (str): Google Cloud project ID (e.g. 'my-project').
        location_id (str): Cloud KMS location (e.g. 'us-east1').
        key_ring_id (str): ID of the Cloud KMS key ring (e.g. 'my-key-ring').
        key_id (str): ID of the key to use (e.g. 'my-key').

    Returns:
        None

    """

    # Create the client.
    client = kms.KeyManagementServiceClient()

    # Build the key name.
    key_name = client.crypto_key_path(project_id, location_id, key_ring_id, key_id)

    # Call the API.
    # Note: delete_crypto_key returns a long-running operation.
    # Warning: This operation is permanent and cannot be undone.
    operation = client.delete_crypto_key(request={"name": key_name})

    # Wait for the operation to complete.
    operation.result()

    print(f"Deleted key: {key_name}")

API

  1. 키를 삭제하려면 cryptoKey.delete 메서드를 호출합니다. 이 메서드는 키가 삭제되었는지 확인하기 위해 폴링할 수 있는 장기 실행 작업을 반환합니다.

    curl "https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/keyRings/KEY_RING/cryptoKeys/KEY_NAME" \
    --request "DELETE" \
    --header "authorization: Bearer TOKEN"
    

    다음을 바꿉니다.

    • PROJECT_ID: 키링이 포함된 프로젝트의 ID입니다.
    • LOCATION: 키링의 Cloud KMS 위치입니다.
    • KEY_RING: 키가 포함된 키링의 이름입니다.
    • KEY_NAME: 영구적으로 삭제하려는 키의 이름입니다. 키에 아직 삭제되지 않은 키 버전이 포함되어 있으면 안 되며, Autokey로 생성된 키여도 안 됩니다.

    명령어의 출력은 Operation를 반환합니다. 다음 단계에는 작업의 name가 필요합니다.

  2. 키가 삭제되었는지 확인하려면 operations.get 메서드를 호출하면 됩니다.

    curl "https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_NAME" \
        --request "GET" \
        --header "authorization: Bearer TOKEN"
    

    다음을 바꿉니다.

    • PROJECT_ID: 키링이 포함된 프로젝트의 ID입니다.
    • LOCATION: 키링의 Cloud KMS 위치입니다.
    • OPERATION_NAME: 이전 메서드에서 반환된 작업의 이름입니다.

    이 메서드의 출력에 donetrue로 표시되면 작업이 완료된 것입니다. error가 표시되지 않으면 키가 영구적으로 삭제된 것입니다.

지원 중단된 리소스의 이름 보기

삭제된 키의 이름은 동일한Google Cloud 프로젝트에서 재사용할 수 없습니다. 이렇게 하면 서로 다른 두 키가 동일한 리소스 식별자를 갖지 않습니다. 삭제된 키의 이름은 retiredResources 객체에 저장됩니다. retiredResources를 쿼리하여 새 Cloud KMS 리소스에 재사용할 수 없는 이름을 볼 수 있습니다.

지원 중단된 모든 리소스 목록을 보려면 다음 단계를 따르세요.

gcloud

다음 명령어를 실행합니다.

gcloud kms retired-resources list \
    --location=LOCATION

다음을 바꿉니다.

  • LOCATION: 지원이 종료된 리소스를 보려는 위치입니다.

Go

Cloud KMS용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud KMS 클라이언트 라이브러리를 참조하세요.

Cloud KMS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import (
	"context"
	"fmt"
	"io"

	kms "cloud.google.com/go/kms/apiv1"
	kmspb "cloud.google.com/go/kms/apiv1/kmspb"
	"google.golang.org/api/iterator"
)

// listRetiredResources lists retired resources.
func listRetiredResources(w io.Writer, parent string) error {
	// parent := "projects/my-project/locations/us-east1"

	ctx := context.Background()
	client, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		return fmt.Errorf("failed to create kms client: %w", err)
	}
	defer client.Close()

	// Build the request.
	req := &kmspb.ListRetiredResourcesRequest{
		Parent: parent,
	}

	// Call the API.
	it := client.ListRetiredResources(ctx, req)

	// Iterate over the results.
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("failed to list retired resources: %w", err)
		}

		fmt.Fprintf(w, "Retired resource: %s\n", resp.Name)
	}
	return nil
}

Java

Cloud KMS용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud KMS 클라이언트 라이브러리를 참조하세요.

Cloud KMS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.cloud.kms.v1.KeyManagementServiceClient;
import com.google.cloud.kms.v1.LocationName;
import com.google.cloud.kms.v1.RetiredResource;
import java.io.IOException;

public class ListRetiredResources {

  public void listRetiredResources() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String locationId = "us-east1";
    listRetiredResources(projectId, locationId);
  }

  // List retired resources in a specific project and location.
  public void listRetiredResources(String projectId, String locationId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only
    // needs to be created once, and can be reused for multiple requests. After
    // completing all of your requests, call the "close" method on the client to
    // safely clean up any remaining background resources.
    try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {
      // Build the location name from the project and location.
      LocationName locationName = LocationName.of(projectId, locationId);

      // List the retired resources.
      for (RetiredResource resource : client.listRetiredResources(locationName).iterateAll()) {
        System.out.printf("Retired resource: %s%n", resource.getName());
      }
    }
  }
}

Python

Cloud KMS용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud KMS 클라이언트 라이브러리를 참조하세요.

Cloud KMS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from typing import List

from google.cloud import kms


def list_retired_resources(project_id: str, location_id: str) -> List[kms.RetiredResource]:
    """
    List the retired resources in a location.

    Args:
        project_id (str): Google Cloud project ID (e.g. 'my-project').
        location_id (str): Cloud KMS location (e.g. 'us-east1').

    Returns:
        list[kms.RetiredResource]: The list of retired resources.
    """

    # Create the client.
    client = kms.KeyManagementServiceClient()

    # Build the parent location name.
    parent = client.common_location_path(project_id, location_id)

    # Call the API.
    # The API paginates, but the Python client library handles that for us.
    resources_list = list(client.list_retired_resources(request={"parent": parent}))

    # Iterate over the resources and print them.
    for resource in resources_list:
        print(f"Retired resource: {resource.name}")

    return resources_list

API

retiredResources.list 메서드를 사용합니다.

curl "https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/retiredResources/" \
    --request "GET" \
    --header "authorization: Bearer TOKEN"

다음을 바꿉니다.

  • PROJECT_ID: 지원이 종료된 리소스를 보려는 프로젝트의 식별자입니다.
  • LOCATION: 지원이 종료된 리소스를 보려는 위치입니다.

개별 지원 종료 리소스의 메타데이터를 보려면 다음 단계를 따르세요.

gcloud

다음 명령어를 실행합니다.

gcloud kms retired-resources describe RETIRED_RESOURCE \
    --location=LOCATION

다음을 바꿉니다.

  • RETIRED_RESOURCE: 보려는 리소스의 이름입니다.
  • LOCATION: 지원이 종료된 리소스를 보려는 위치입니다.

Go

Cloud KMS용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud KMS 클라이언트 라이브러리를 참조하세요.

Cloud KMS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import (
	"context"
	"fmt"
	"io"

	kms "cloud.google.com/go/kms/apiv1"
	kmspb "cloud.google.com/go/kms/apiv1/kmspb"
)

// getRetiredResource gets a retired resource.
func getRetiredResource(w io.Writer, name string) error {
	// name := "projects/my-project/locations/us-east1/retiredResources/my-retired-resource"

	ctx := context.Background()
	client, err := kms.NewKeyManagementClient(ctx)
	if err != nil {
		return fmt.Errorf("failed to create kms client: %w", err)
	}
	defer client.Close()

	// Build the request.
	req := &kmspb.GetRetiredResourceRequest{
		Name: name,
	}

	// Call the API.
	result, err := client.GetRetiredResource(ctx, req)
	if err != nil {
		return fmt.Errorf("failed to get retired resource: %w", err)
	}

	fmt.Fprintf(w, "Got retired resource: %s\n", result.Name)
	return nil
}

Java

Cloud KMS용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud KMS 클라이언트 라이브러리를 참조하세요.

Cloud KMS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.cloud.kms.v1.KeyManagementServiceClient;
import com.google.cloud.kms.v1.RetiredResource;
import com.google.cloud.kms.v1.RetiredResourceName;
import java.io.IOException;

public class GetRetiredResource {

  public void getRetiredResource() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String locationId = "us-east1";
    String retiredResourceId = "my-retired-resource-id";
    getRetiredResource(projectId, locationId, retiredResourceId);
  }

  // Get the retired resource.
  public void getRetiredResource(
      String projectId, String locationId, String retiredResourceId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only
    // needs to be created once, and can be reused for multiple requests. After
    // completing all of your requests, call the "close" method on the client to
    // safely clean up any remaining background resources.
    try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {
      // Build the retired resource name from the project, location, and retired resource id.
      RetiredResourceName name = RetiredResourceName.of(projectId, locationId, retiredResourceId);

      // Get the retired resource.
      RetiredResource response = client.getRetiredResource(name);
      System.out.printf("Retired resource: %s%n", response.getName());
    }
  }
}

Python

Cloud KMS용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Cloud KMS 클라이언트 라이브러리를 참조하세요.

Cloud KMS에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import kms


def get_retired_resource(
    project_id: str, location_id: str, retired_resource_id: str
) -> kms.RetiredResource:
    """
    Get the details of a retired resource.

    Args:
        project_id (str): Google Cloud project ID (e.g. 'my-project').
        location_id (str): Cloud KMS location (e.g. 'us-east1').
        resource_id (str): ID of the retired resource to get.

    Returns:
        kms.RetiredResource: The requested retired resource.

    """

    # Create the client.
    client = kms.KeyManagementServiceClient()

    # Build the retired resource name.
    # Note: Retired resources are tied to a Location, not a KeyRing.
    # The name is like projects/{project}/locations/{location}/retiredResources/{id}
    name = client.retired_resource_path(project_id, location_id, retired_resource_id)

    # Call the API.
    response = client.get_retired_resource(request={"name": name})

    print(f"Got retired resource: {response.name}")
    return response

API

retiredResources.get 메서드를 사용합니다.

curl "https://cloudkms.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/retiredResources/RETIRED_RESOURCE" \
    --request "GET" \
    --header "authorization: Bearer TOKEN"

다음을 바꿉니다.

  • PROJECT_ID: 지원이 종료된 리소스를 보려는 프로젝트의 식별자입니다.
  • LOCATION: 지원이 종료된 리소스를 보려는 위치입니다.
  • RETIRED_RESOURCE: 보려는 리소스의 이름입니다.

메서드의 출력에는 resourceType, deleteTime, 삭제된 리소스의 전체 리소스 식별자가 포함됩니다.

다음 단계