키 버전 폐기 및 복원

이 페이지에서는 Cloud Key Management Service 키 버전을 영구 폐기하도록 예약하는 방법을 보여줍니다. Cloud KMS에서 데이터를 암호화, 복호화, 서명, 확인하는 데 사용하는 암호화 키 자료는 하나의 키 버전에 저장됩니다. 키에는 0개 이상의 키 버전이 있습니다. 키를 순환할 때는 새 키 버전을 생성하세요.

키 버전을 폐기하면 키 자료가 영구적으로 삭제됩니다. 키 버전을 폐기해도 키 이름 및 키 버전 번호와 같은 다른 세부정보는 삭제되지 않습니다. 키가 폐기되면 해당 키 버전으로 암호화된 데이터를 복호화할 수 없습니다.

키 폐기는 되돌릴 수 없으므로 Cloud KMS는 키 버전을 즉시 폐기할 수 없습니다. 대신 키 버전 폐기를 예약합니다. 키 버전은 구성 가능한 시간 동안 폐기 예약됨 상태로 유지됩니다. 폐기 예약 기간 중에 키 버전을 복원하여 폐기를 취소할 수 있습니다.

기본 폐기 예약 기간은 24시간입니다. 키 생성 중에 키에 커스텀 폐기 예약 기간을 설정할 수 있습니다. 조직에서는 조직 정책에 키당 최소 폐기 예약 기간 제약조건을 설정하여 최소 폐기 예약 기간을 적용할 수 있습니다.

Identity and Access Management(IAM)를 사용하여 키에 대한 액세스를 관리할 수도 있습니다. IAM 작업은 수초 범위 내에서 일관성을 갖습니다. 자세한 내용은 IAM 사용을 참조하세요.

또한 일시적으로 키 버전을 사용 중지할 수도 있습니다. 키를 안전하게 폐기할 수 있도록 키 버전의 폐기를 예약하기 전에 사용 중지하는 절차를 확립하는 것이 좋습니다. 조직 정책에 따라서는 키 버전 폐기를 예약하기 전에 사용 중지해야 할 수 있습니다. 조직 정책을 사용하여 키 버전 폐기를 제어하는 방법에 대한 자세한 내용은 키 버전 폐기 제어를 참조하세요.

이 주제의 나머지 부분에서는 비록 즉시 폐기는 아니지만 폐기를 위해 키를 예약하는 것을 키 폐기라고 지칭합니다.

시작하기 전에

위험 이해

키 버전 폐기는 영구적인 작업입니다. 여전히 필요한 키 버전을 폐기하면 다음과 같은 위험이 있습니다.

  • 서비스 중단: 컨테이너 또는 인스턴스를 시작하는 데 필요한 키를 폐기하면 서비스 또는 애플리케이션을 사용할 수 없게 됩니다.

  • 영구적인 데이터 손실: 데이터를 암호화하는 데 사용된 키를 폐기하면 데이터를 사용할 수 없게 됩니다. 폐기된 키로 암호화된 데이터는 암호화 파쇄로 간주됩니다. 경우에 따라 키를 폐기하면 암호화된 리소스가 영구적으로 삭제될 수 있습니다.

  • 규제 또는 규정 준수 문제: 보관 기간이 완료되기 전에 보관 기간이 적용되는 데이터에 액세스하는 데 필요한 키를 폐기하면 규제 또는 규정 준수 요건을 위반할 수 있습니다.

필요한 역할

키 버전을 폐기하고 복원하는 데 필요한 권한을 얻으려면 관리자에게 키에 대한 Cloud KMS 관리자(roles/cloudkms.admin) IAM 역할을 부여해 달라고 요청하세요. 역할 부여에 대한 자세한 내용은 액세스 관리를 참조하세요.

커스텀 역할이나 다른 사전 정의된 역할을 통해 필요한 권한을 얻을 수도 있습니다.

키 버전이 사용 중인지 확인

키 버전을 폐기하기 전에 다음 단계를 완료하여 키 버전이 사용 중인지 확인하세요.

  1. 키의 키 사용량 추적 세부정보 보기 폐기하려는 키 버전으로 리소스가 보호되는 경우 다른 키 버전으로 다시 암호화합니다.

  2. 해당 키 버전을 사용할 가능성이 있는 모든 서비스나 애플리케이션의 로그를 사용 설정합니다.

  3. 해당 키가 포함된 Cloud KMS 프로젝트에서 로그를 사용 설정합니다.

  4. 키 버전을 사용 중지합니다. 키 버전을 사용 중지하면 해당 키 버전이 사용되지 않습니다. 키 버전을 사용 중지하면 해당 키 버전 사용 시도가 실패합니다.

  5. 사용 중지한 키 버전이 여전히 애플리케이션 또는 서비스에서 사용되지 않는지 확인할 때까지 로그를 모니터링합니다. 키 버전 액세스 실패를 나타내는 오류가 발생하면 다른 키 버전을 사용하도록 애플리케이션 또는 리소스를 구성하세요.

    키 버전을 폐기하기 전 로그를 모니터링하는 데 걸리는 시간은 키 유형, 사용 패턴, 민감도 수준에 따라 다릅니다. 예를 들어 분기별로 실행되는 프로세스에 사용되는 키 버전을 폐기하기 전에 해당 프로세스가 완료될 때까지 키 버전을 사용 중지된 상태로 유지합니다.

  6. 관련 규정 준수 요구사항에 따라 키 사용을 확인합니다. 예를 들어 키 버전과 이 키로 암호화된 데이터에 데이터 보관 기간이 적용될 수 있습니다.

이 단계는 키가 여전히 필요한지 여부를 식별하는 데 도움이 됩니다. 그러나 키 버전이 더 이상 필요하지 않을 것이라고 보장할 수는 없습니다. 조직에서 키 버전 폐기로 인해 부정적인 영향이 발생하지 않도록 절차와 가이드라인을 구현해야 합니다.

키 버전 폐기

사용 또는 사용 중지된 키 버전을 폐기할 수 있습니다.

콘솔

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

    키 관리로 이동

  2. 폐기 예약할 키 버전 옆의 체크박스를 선택합니다.

  3. 헤더에서 폐기를 클릭합니다.

  4. 확인 대화상자에서 키 이름을 입력한 다음 폐기 예약을 클릭합니다.

gcloud

명령줄에서 Cloud KMS를 사용하려면 먼저 최신 버전의 Google Cloud CLI로 설치 또는 업그레이드하세요.

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

다음을 바꿉니다.

  • KEY_VERSION: 폐기하려는 키 버전의 버전 번호입니다.
  • KEY_NAME: 키 버전을 폐기하려는 키의 이름입니다.
  • KEY_RING: 키가 포함된 키링의 이름입니다.
  • LOCATION: 키링의 Cloud KMS 위치입니다.

모든 플래그 및 가능한 값에 대한 정보를 보려면 --help 플래그와 함께 명령어를 실행하세요.

C#

이 코드를 실행하려면 먼저 C# 개발 환경을 설정하고 Cloud KMS C# SDK를 설치합니다.


using Google.Cloud.Kms.V1;

public class DestroyKeyVersionSample
{
    public CryptoKeyVersion DestroyKeyVersion(
      string projectId = "my-project", string locationId = "us-east1", string keyRingId = "my-key-ring", string keyId = "my-key", string keyVersionId = "123")
    {
        // Create the client.
        KeyManagementServiceClient client = KeyManagementServiceClient.Create();

        // Build the key version name.
        CryptoKeyVersionName keyVersionName = new CryptoKeyVersionName(projectId, locationId, keyRingId, keyId, keyVersionId);

        // Call the API.
        CryptoKeyVersion result = client.DestroyCryptoKeyVersion(keyVersionName);

        // Return the result.
        return result;
    }
}

Go

이 코드를 실행하려면 먼저 Go 개발 환경을 설정하고 Cloud KMS Go SDK를 설치합니다.

import (
	"context"
	"fmt"
	"io"

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

// destroyKeyVersion marks a specified key version for deletion. The key can be
// restored if requested within 24 hours.
func destroyKeyVersion(w io.Writer, name string) error {
	// name := "projects/my-project/locations/us-east1/keyRings/my-key-ring/cryptoKeys/my-key/cryptoKeyVersions/123"

	// 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.DestroyCryptoKeyVersionRequest{
		Name: name,
	}

	// Call the API.
	result, err := client.DestroyCryptoKeyVersion(ctx, req)
	if err != nil {
		return fmt.Errorf("failed to destroy key version: %w", err)
	}
	fmt.Fprintf(w, "Destroyed key version: %s\n", result)
	return nil
}

Java

이 코드를 실행하려면 먼저 자바 개발 환경을 설정하고 Cloud KMS 자바 SDK를 설치합니다.

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

public class DestroyKeyVersion {

  public void destroyKeyVersion() 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";
    destroyKeyVersion(projectId, locationId, keyRingId, keyId, keyVersionId);
  }

  // Schedule destruction of the given key version.
  public void destroyKeyVersion(
      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);

      // Destroy the key version.
      CryptoKeyVersion response = client.destroyCryptoKeyVersion(keyVersionName);
      System.out.printf("Destroyed key version: %s%n", response.getName());
    }
  }
}

Node.js

이 코드를 실행하려면 먼저 Node.js 개발 환경을 설정하고 Cloud KMS Node.js SDK를 설치합니다.

//
// TODO(developer): Uncomment these variables before running the sample.
//
// const projectId = 'my-project';
// const locationId = 'us-east1';
// const keyRingId = 'my-key-ring';
// const keyId = 'my-key';
// const versionId = '123';

// Imports the Cloud KMS library
const {KeyManagementServiceClient} = require('@google-cloud/kms');

// Instantiates a client
const client = new KeyManagementServiceClient();

// Build the key version name
const versionName = client.cryptoKeyVersionPath(
  projectId,
  locationId,
  keyRingId,
  keyId,
  versionId
);

async function destroyKeyVersion() {
  const [version] = await client.destroyCryptoKeyVersion({
    name: versionName,
  });

  console.log(`Destroyed key version: ${version.name}`);
  return version;
}

return destroyKeyVersion();

PHP

이 코드를 실행하려면 먼저 Google Cloud에서 PHP 사용에 관해 알아보고 Cloud KMS PHP SDK 설치하세요.

use Google\Cloud\Kms\V1\KeyManagementServiceClient;

function destroy_key_version(
    string $projectId = 'my-project',
    string $locationId = 'us-east1',
    string $keyRingId = 'my-key-ring',
    string $keyId = 'my-key',
    string $versionId = '123'
) {
    // Create the Cloud KMS client.
    $client = new KeyManagementServiceClient();

    // Build the key version name.
    $keyVersionName = $client->cryptoKeyVersionName($projectId, $locationId, $keyRingId, $keyId, $versionId);

    // Call the API.
    $destroyedVersion = $client->destroyCryptoKeyVersion($keyVersionName);
    printf('Destroyed key version: %s' . PHP_EOL, $destroyedVersion->getName());

    return $destroyedVersion;
}

Python

이 코드를 실행하려면 먼저 Python 개발 환경을 설정하고 Cloud KMS Python SDK를 설치합니다.

from google.cloud import kms

def destroy_key_version(
    project_id: str, location_id: str, key_ring_id: str, key_id: str, version_id: str
) -> kms.CryptoKeyVersion:
    """
    Schedule destruction of the given key version.

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

    Returns:
        CryptoKeyVersion: The version.

    """

    # 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.
    destroyed_version = client.destroy_crypto_key_version(
        request={"name": key_version_name}
    )
    print(f"Destroyed key version: {destroyed_version.name}")
    return destroyed_version

Ruby

이 코드를 실행하려면 먼저 Ruby 개발 환경을 설정하고 Cloud KMS Ruby SDK를 설치합니다.

# TODO(developer): uncomment these values before running the sample.
# project_id  = "my-project"
# location_id = "us-east1"
# key_ring_id = "my-key-ring"
# key_id      = "my-key"
# version_id  = "123"

# Require the library.
require "google/cloud/kms"

# Create the client.
client = Google::Cloud::Kms.key_management_service

# Build the key version name.
key_version_name = client.crypto_key_version_path project:            project_id,
                                                  location:           location_id,
                                                  key_ring:           key_ring_id,
                                                  crypto_key:         key_id,
                                                  crypto_key_version: version_id

# Call the API.
destroyed_version = client.destroy_crypto_key_version name: key_version_name
puts "Destroyed key version: #{destroyed_version.name}"

API

이 예시에서는 curl을 HTTP 클라이언트로 사용하여 API 사용을 보여줍니다. 액세스 제어에 대한 자세한 내용은 Cloud KMS API 액세스를 참조하세요.

CryptoKeyVersions.destroy 메서드를 호출하여 키 버전을 폐기합니다.

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

키 버전을 폐기할 수 없는 경우 조직에서 키 버전을 폐기하기 전에 사용 중지해야 할 수 있습니다. 키 버전을 사용 중지한 후에 폐기해 보세요.

폐기 요청을 제출하면 키 버전 상태는 폐기 예약됨 상태가 됩니다. 키의 구성된 폐기 예약 기간이 지나면 키 버전의 상태가 폐기됨 상태가 됩니다. 즉, 활성 시스템에서 키 자료의 논리적 삭제가 시작되었으며 고객이 키 자료를 복구할 수 없습니다. 키 자료는 예약된 삭제 시점으로부터 최대 45일까지 Google 시스템에 유지될 수 있습니다.

키 버전 폐기를 예약했을 때 알림을 받으려면 Cloud KMS에서 Cloud Monitoring 사용을 참조하세요.

폐기된 키 버전은 청구 대상 리소스가 아닙니다.

외부 키 폐기

Cloud EKM 키와 외부 키 간의 연결을 영구 삭제하려면 키 버전을 폐기하면 됩니다. 폐기 예약 기간이 지나면 키가 폐기됩니다. 키 버전이 폐기되면 Cloud EKM 키 버전으로 암호화된 데이터를 더 이상 암호화하거나 복호화할 수 없습니다.

Cloud KMS에서 수동으로 관리되는 키 버전을 폐기해도 외부 키 관리자에서 키가 수정되지 않습니다. 먼저 Google Cloud에서 키 또는 키 버전을 폐기하는 것이 좋습니다. Cloud EKM 키 버전이 폐기되면 외부 키 관리자에서 키 자료를 폐기할 수 있습니다.

Cloud KMS에서 조정된 외부 키 버전을 폐기하면 먼저 Google Cloud에서 키 버전을 폐기한 다음 EKM에 폐기 요청을 전송하여 외부 키 자료를 폐기합니다.

키 버전 복원

키 버전 상태가 폐기되도록 예약된 기간 동안 복원 요청을 제출하여 키 버전을 복원할 수 있습니다.

콘솔

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

    키 관리 페이지로 이동

  2. 키 버전을 복원할 키가 포함된 키링의 이름을 클릭합니다.

  3. 복원할 키 버전의 키를 클릭합니다.

  4. 복원하려는 키 버전 옆의 체크박스를 선택합니다.

  5. 헤더에서 복원을 클릭합니다.

  6. 확인 대화상자에서 복원을 클릭합니다.

gcloud

명령줄에서 Cloud KMS를 사용하려면 먼저 최신 버전의 Google Cloud CLI로 설치 또는 업그레이드하세요.

gcloud kms keys versions restore key-version \
    --key key \
    --keyring key-ring \
    --location location

key-version을 복원할 키 버전으로 바꿉니다. key를 키 이름으로 바꿉니다. key-ring을 키가 배치된 키링의 이름으로 바꿉니다. location을 키링의 Cloud KMS 위치로 바꿉니다.

모든 플래그 및 가능한 값에 대한 정보를 보려면 --help 플래그와 함께 명령어를 실행하세요.

C#

이 코드를 실행하려면 먼저 C# 개발 환경을 설정하고 Cloud KMS C# SDK를 설치합니다.


using Google.Cloud.Kms.V1;

public class RestoreKeyVersionSample
{
    public CryptoKeyVersion RestoreKeyVersion(string projectId = "my-project", string locationId = "us-east1", string keyRingId = "my-key-ring", string keyId = "my-key", string keyVersionId = "123")
    {
        // Create the client.
        KeyManagementServiceClient client = KeyManagementServiceClient.Create();

        // Build the key version name.
        CryptoKeyVersionName cryptoKeyVersionName = new CryptoKeyVersionName(projectId, locationId, keyRingId, keyId, keyVersionId);

        // Call the API.
        CryptoKeyVersion result = client.RestoreCryptoKeyVersion(cryptoKeyVersionName);

        // Return the result.
        return result;
    }
}

Go

이 코드를 실행하려면 먼저 Go 개발 환경을 설정하고 Cloud KMS Go SDK를 설치합니다.

import (
	"context"
	"fmt"
	"io"

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

// restoreKeyVersion attempts to recover a key that has been marked for
// destruction in the past 24h.
func restoreKeyVersion(w io.Writer, name string) error {
	// name := "projects/my-project/locations/us-east1/keyRings/my-key-ring/cryptoKeys/my-key/cryptoKeyVersions/123"

	// 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.RestoreCryptoKeyVersionRequest{
		Name: name,
	}

	// Call the API.
	result, err := client.RestoreCryptoKeyVersion(ctx, req)
	if err != nil {
		return fmt.Errorf("failed to restore key version: %w", err)
	}
	fmt.Fprintf(w, "Restored key version: %s\n", result)
	return nil
}

Java

이 코드를 실행하려면 먼저 자바 개발 환경을 설정하고 Cloud KMS 자바 SDK를 설치합니다.

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

public class RestoreKeyVersion {

  public void restoreKeyVersion() 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";
    restoreKeyVersion(projectId, locationId, keyRingId, keyId, keyVersionId);
  }

  // Schedule destruction of the given key version.
  public void restoreKeyVersion(
      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);

      // Restore the key version.
      CryptoKeyVersion response = client.restoreCryptoKeyVersion(keyVersionName);
      System.out.printf("Restored key version: %s%n", response.getName());
    }
  }
}

Node.js

이 코드를 실행하려면 먼저 Node.js 개발 환경을 설정하고 Cloud KMS Node.js SDK를 설치합니다.

//
// TODO(developer): Uncomment these variables before running the sample.
//
// const projectId = 'my-project';
// const locationId = 'us-east1';
// const keyRingId = 'my-key-ring';
// const keyId = 'my-key';
// const versionId = '123';

// Imports the Cloud KMS library
const {KeyManagementServiceClient} = require('@google-cloud/kms');

// Instantiates a client
const client = new KeyManagementServiceClient();

// Build the key version name
const versionName = client.cryptoKeyVersionPath(
  projectId,
  locationId,
  keyRingId,
  keyId,
  versionId
);

async function restoreKeyVersion() {
  const [version] = await client.restoreCryptoKeyVersion({
    name: versionName,
  });

  console.log(`Restored key version: ${version.name}`);
  return version;
}

return restoreKeyVersion();

PHP

이 코드를 실행하려면 먼저 Google Cloud에서 PHP 사용에 관해 알아보고 Cloud KMS PHP SDK 설치하세요.

use Google\Cloud\Kms\V1\KeyManagementServiceClient;

function restore_key_version(
    string $projectId = 'my-project',
    string $locationId = 'us-east1',
    string $keyRingId = 'my-key-ring',
    string $keyId = 'my-key',
    string $versionId = '123'
) {
    // Create the Cloud KMS client.
    $client = new KeyManagementServiceClient();

    // Build the key version name.
    $keyVersionName = $client->cryptoKeyVersionName($projectId, $locationId, $keyRingId, $keyId, $versionId);

    // Call the API.
    $restoredVersion = $client->restoreCryptoKeyVersion($keyVersionName);
    printf('Restored key version: %s' . PHP_EOL, $restoredVersion->getName());

    return $restoredVersion;
}

Python

이 코드를 실행하려면 먼저 Python 개발 환경을 설정하고 Cloud KMS Python SDK를 설치합니다.

from google.cloud import kms

def restore_key_version(
    project_id: str, location_id: str, key_ring_id: str, key_id: str, version_id: str
) -> kms.CryptoKeyVersion:
    """
    Restore a key version scheduled for destruction.

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

    Returns:
        CryptoKeyVersion: Restored Cloud KMS key version.

    """

    # 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.
    restored_version = client.restore_crypto_key_version(
        request={"name": key_version_name}
    )
    print(f"Restored key version: {restored_version.name}")
    return restored_version

Ruby

이 코드를 실행하려면 먼저 Ruby 개발 환경을 설정하고 Cloud KMS Ruby SDK를 설치합니다.

# TODO(developer): uncomment these values before running the sample.
# project_id  = "my-project"
# location_id = "us-east1"
# key_ring_id = "my-key-ring"
# key_id      = "my-key"
# version_id  = "123"

# Require the library.
require "google/cloud/kms"

# Create the client.
client = Google::Cloud::Kms.key_management_service

# Build the key version name.
key_version_name = client.crypto_key_version_path project:            project_id,
                                                  location:           location_id,
                                                  key_ring:           key_ring_id,
                                                  crypto_key:         key_id,
                                                  crypto_key_version: version_id

# Call the API.
restored_version = client.restore_crypto_key_version name: key_version_name
puts "Restored key version: #{restored_version.name}"

API

이 예시에서는 curl을 HTTP 클라이언트로 사용하여 API 사용을 보여줍니다. 액세스 제어에 대한 자세한 내용은 Cloud KMS API 액세스를 참조하세요.

CryptoKeyVersions.restore 메서드를 호출하여 키 버전을 복원합니다.

curl "https://cloudkms.googleapis.com/v1/projects/project-id/locations/location-id/keyRings/key-ring-id/cryptoKeys/crypto-key-id/cryptoKeyVersions/version-id:restore" \
    --request "POST" \
    --header "authorization: Bearer token"

복원 요청이 완료되면 키 버전의 상태가 사용 중지됨으로 바뀝니다. 키를 사용하려면 먼저 키를 사용 설정해야 합니다.

필수 IAM 권한

키 버전을 폐기하려면 호출자는 키, 키링 또는 프로젝트, 폴더 또는 조직에 대한 cloudkms.cryptoKeyVersions.destroy IAM 권한이 필요합니다.

키 버전을 복원하려면 호출자에게 cloudkms.cryptoKeyVersions.restore 권한이 필요합니다.

이 두 권한은 모두 Cloud KMS 관리자 역할(roles/cloudkms.admin)에 부여됩니다.

삭제 타임라인

Cloud KMS는 예약된 삭제 시간에서 45일 이내에 모든 Google 인프라에서 고객 키 자료를 삭제합니다. 여기에는 활성 시스템 및 데이터 센터 백업의 데이터 삭제도 포함됩니다. 다른 고객 데이터에는 표준 Google Cloud 삭제 타임라인인 180일이 적용됩니다.