建立及管理標記

本指南說明如何建立及管理 Secret Manager 密鑰的標記。您可以使用標記將相關的 Secret Manager 密鑰分組,並根據標記儲存這些資源的中繼資料。

關於代碼

標記是一種鍵/值組合,可附加至Google Cloud內的資源。您可以將資源是否具備特定標記設為條件,並按照這項條件允許或拒絕政策。舉例來說,您可以根據資源是否具備特定標記,有條件地授予 Identity and Access Management (IAM) 角色。詳情請參閱「標記總覽」。

如要將標記附加至資源,請建立標記繫結資源,將值連結至 Google Cloud 資源。

所需權限

如要取得管理標記所需的權限,請要求管理員授予您下列 IAM 角色:

  • 對標記附加的資源,具備標記檢視者 (roles/resourcemanager.tagViewer) 權限
  • 查看及管理組織層級的標記:組織的組織檢視者 (roles/resourcemanager.organizationViewer)
  • 建立、更新及刪除標記定義:在您要建立、更新或刪除標記的資源上,具備標記管理員 (roles/resourcemanager.tagAdmin) 角色
  • 在資源中附加及移除標記:標記值和您要附加或移除標記值的資源,必須具備標記使用者 (roles/resourcemanager.tagUser) 角色

如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

您或許也能透過自訂角色或其他預先定義的角色,取得必要權限。

如要將標記附加至 Secret Manager 密鑰,您必須具備 Secret Manager 管理員角色 (roles/secretmanager.admin)。

建立標記鍵和值

您必須先建立標記並設定其值,才能附加標記。詳情請參閱「建立標記」和「新增標記值」。

在建立資源時新增標記

您可以在建立 Secret 時新增標記。這樣一來,您就能為資源提供必要的中繼資料,並更妥善地整理、追蹤成本及自動套用政策。

控制台

  1. 前往 Google Cloud 控制台的「Secret Manager」頁面。
  2. 前往 Secret Manager

  3. 選取建立新密鑰的選項。
  4. 按一下 「Manage tags」(管理標記)。
  5. 如果「Manage tags」(管理標記) 面板中未顯示貴組織,請按一下「Select scope for tags」(選取標記範圍),然後選取貴組織或專案。
  6. 按一下「新增標記」。
  7. 從清單中選取標記鍵和標記值。您可以使用關鍵字篩選清單。
  8. 按一下 [儲存]。「Tags」(標記) 區段會更新為標記資訊。
  9. 建立密鑰。系統會使用提供的標記建立新密鑰。

gcloud

使用下列任何指令資料前,請先替換以下項目:

  • SECRET_ID:Secret 的專屬 ID。
  • TAG_KEY:附加標記鍵的永久 ID 或命名空間名稱,例如 tagKeys/567890123456。
  • TAG_VALUE:附加代碼值的永久 ID 或命名空間名稱,例如 tagValues/567890123456。

如要指定多個標記,請以半形逗號分隔,例如 TAGKEY1=TAGVALUE1,TAGKEY2=TAGVALUE2。

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud secrets create SECRET_ID --tags=TAG_KEY=TAG_VALUE

Windows (PowerShell)

gcloud secrets create SECRET_ID --tags=TAG_KEY=TAG_VALUE

Windows (cmd.exe)

gcloud secrets create SECRET_ID --tags=TAG_KEY=TAG_VALUE

REST

使用任何要求資料之前,請先修改下列項目的值:

  • PROJECT_ID:專案 ID
  • SECRET_ID:Secret 的專屬 ID
  • TAGKEY_NAME:附加標記鍵的永久 ID 或命名空間名稱,例如 tagKeys/567890123456。
  • TAGVALUE_NAME:附加代碼值的永久 ID 或命名空間名稱,例如 tagValues/567890123456。

HTTP 方法和網址:

POST https://secretmanager.googleapis.com/v1/projects/PROJECT_ID/secrets?secretId=SECRET_ID

JSON 要求內文:

{
  "replication": {
    "automatic": {}
  },
  "tags": {
    "TAGKEY_NAME": "TAGVALUE_NAME"
  }
}

如要傳送要求,請選擇以下其中一個選項:

curl

將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://secretmanager.googleapis.com/v1/projects/PROJECT_ID/secrets?secretId=SECRET_ID"

PowerShell

將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://secretmanager.googleapis.com/v1/projects/PROJECT_ID/secrets?secretId=SECRET_ID" | Select-Object -Expand Content

您應該會收到執行成功的狀態碼 (2xx) 和空白回應。

C#

如要執行這段程式碼,請先設定 C# 開發環境,並安裝 Secret Manager C# SDK。在 Compute Engine 或 GKE 上,您必須使用 cloud-platform 範圍進行驗證。


using Google.Api.Gax.ResourceNames;
using Google.Cloud.SecretManager.V1;
using System.Collections.Generic;

public class CreateSecretWithTagsSample
{
    public Secret CreateSecretWithTags(
      string projectId = "my-project", string secretId = "my-secret", string tagKeyName = "tagKey/value", string tagValueName = "tagValue/value")
    {
        // Create the client.
        SecretManagerServiceClient client = SecretManagerServiceClient.Create();

        // Build the parent resource name.
        ProjectName projectName = new ProjectName(projectId);

        // Build the secret.
        Secret secret = new Secret
        {
            Replication = new Replication
            {
                Automatic = new Replication.Types.Automatic(),
            },
            Tags =
            {
              { tagKeyName, tagValueName }
            },
        };

        // Call the API.
        Secret createdSecret = client.CreateSecret(projectName, secretId, secret);
        return createdSecret;
    }
}

Go

如要執行這段程式碼,請先設定 Go 開發環境,並安裝 Secret Manager Go SDK。在 Compute Engine 或 GKE 上,您必須使用 cloud-platform 範圍進行驗證。

import (
	"context"
	"fmt"
	"io"

	secretmanager "cloud.google.com/go/secretmanager/apiv1"
	"cloud.google.com/go/secretmanager/apiv1/secretmanagerpb"
)

// createSecretWithTags creates a new secret with the given name and tags.
func createSecretWithTags(w io.Writer, parent, id, tagKey, tagValue string) error {
	// parent := "projects/my-project"
	// id := "my-secret"

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

	// Build the request.
	req := &secretmanagerpb.CreateSecretRequest{
		Parent:   parent,
		SecretId: id,
		Secret: &secretmanagerpb.Secret{
			Replication: &secretmanagerpb.Replication{
				Replication: &secretmanagerpb.Replication_Automatic_{
					Automatic: &secretmanagerpb.Replication_Automatic{},
				},
			},
			Tags: map[string]string{
				tagKey: tagValue,
			},
		},
	}

	// Call the API.
	result, err := client.CreateSecret(ctx, req)
	if err != nil {
		return fmt.Errorf("failed to create secret: %w", err)
	}
	fmt.Fprintf(w, "Created secret with tags: %s\n", result.Name)
	return nil
}

Java

如要執行這段程式碼,請先設定 Java 開發環境,並安裝 Secret Manager Java SDK。在 Compute Engine 或 GKE 上,您必須使用 cloud-platform 範圍進行驗證。

import com.google.cloud.secretmanager.v1.ProjectName;
import com.google.cloud.secretmanager.v1.Replication;
import com.google.cloud.secretmanager.v1.Secret;
import com.google.cloud.secretmanager.v1.SecretManagerServiceClient;
import java.io.IOException;

public class CreateSecretWithTags {

  public static void createSecretWithTags() throws IOException {
    // TODO(developer): Replace these variables before running the sample.

    // This is the id of the GCP project
    String projectId = "your-project-id";
    // This is the id of the secret to act on
    String secretId = "your-secret-id";
    // This is the key of the tag to be added
    String tagKey = "your-tag-key";
    // This is the value of the tag to be added
    String tagValue = "your-tag-value";
    createSecretWithTags(projectId, secretId, tagKey, tagValue);
  }

  // Create a secret with tags.
  public static Secret createSecretWithTags(
       String projectId, String secretId, String tagKey, String tagValue) 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.
    try (SecretManagerServiceClient client = SecretManagerServiceClient.create()) {

      // Build the name.
      ProjectName projectName = ProjectName.of(projectId);

      // Build the secret to create with tags.
      Secret secret =
          Secret.newBuilder()
          .setReplication(
              Replication.newBuilder()
                  .setAutomatic(Replication.Automatic.newBuilder().build())
                  .build())
          .putTags(tagKey, tagValue)
          .build();

      // Create the secret.
      Secret createdSecret = client.createSecret(projectName, secretId, secret);
      System.out.printf("Created secret with Tags %s\n", createdSecret.getName());
      return createdSecret;
    }
  }
}

Node.js

如要執行這段程式碼,請先設定 Node.js 開發環境,並安裝 Secret Manager Node.js SDK。在 Compute Engine 或 GKE 上,您必須使用 cloud-platform 範圍進行驗證。

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'my-project';
// const secretId = 'my-secret';
// const tagKey = 'tagKeys/281475012216835';
// const tagValue = 'tagValues/281476592621530';
const parent = `projects/${projectId}`;

// Imports the library
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');

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

async function createSecretWithTags() {
  const [secret] = await client.createSecret({
    parent: parent,
    secretId: secretId,
    secret: {
      replication: {
        automatic: {},
      },
      tags: {
        [tagKey]: tagValue,
      },
    },
  });

  console.log(`Created secret ${secret.name}`);
}

createSecretWithTags();

PHP

如要執行這段程式碼,請先瞭解如何在 Google Cloud 上使用 PHP,並安裝 Secret Manager PHP SDK。在 Compute Engine 或 GKE 上,您必須使用 cloud-platform 範圍進行驗證。

// Import the Secret Manager client library.
use Google\Cloud\SecretManager\V1\CreateSecretRequest;
use Google\Cloud\SecretManager\V1\Replication;
use Google\Cloud\SecretManager\V1\Replication\Automatic;
use Google\Cloud\SecretManager\V1\Secret;
use Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient;

/**
 * @param string $projectId Your Google Cloud Project ID (e.g. 'my-project')
 * @param string $secretId  Your secret ID (e.g. 'my-secret')
 * @param string $tagKey    Your tag key (e.g. 'tagKeys/281475012216835')
 * @param string $tagValue  Your tag value (e.g. 'tagValues/281476592621530')
 */
function create_secret_with_tags(string $projectId, string $secretId, string $tagKey, string $tagValue): void
{
    // Create the Secret Manager client.
    $client = new SecretManagerServiceClient();

    // Build the resource name of the parent project.
    $parent = $client->projectName($projectId);

    $secret = new Secret([
        'replication' => new Replication([
            'automatic' => new Automatic(),
        ]),
    ]);

    // set the tags.
    $tags = [$tagKey => $tagValue];
    $secret->setTags($tags);

    // Build the request.
    $request = CreateSecretRequest::build($parent, $secretId, $secret);

    // Create the secret.
    $newSecret = $client->createSecret($request);

    // Print the new secret name.
    printf('Created secret %s with tag', $newSecret->getName());
}

Python

如要執行這段程式碼,請先設定 Python 開發環境,並安裝 Secret Manager Python SDK。在 Compute Engine 或 GKE 上,您必須使用 cloud-platform 範圍進行驗證。

import argparse

# Import the Secret Manager client library.
from google.cloud import secretmanager


def create_secret_with_tags(
    project_id: str,
    secret_id: str,
    tag_key: str,
    tag_value: str,
) -> secretmanager.Secret:
    """
    Create a new secret with the given name and associated tags. A secret is a
    logical wrapper around a collection of secret versions. Secret versions hold
    the actual secret material.
    """

    # Create the Secret Manager client.
    client = secretmanager.SecretManagerServiceClient()

    # Build the resource name of the parent project.
    parent = f"projects/{project_id}"

    # Create the secret.
    response = client.create_secret(
        request={
            "parent": parent,
            "secret_id": secret_id,
            "secret": {"replication": {"automatic": {}}, "tags": {tag_key: tag_value}},
        }
    )

    # Print the new secret name.
    print(f"Created secret: {response.name}")

    return response

Ruby

如要執行這段程式碼,請先設定 Ruby 開發環境,並安裝 Secret Manager Ruby SDK。在 Compute Engine 或 GKE 上,您必須使用 cloud-platform 範圍進行驗證。

require "google/cloud/secret_manager"

##
# Create a secret with tags.
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param secret_id [String] Your secret name (e.g. "my-secret")
# @param tag_key [String] Your tag key (e.g. "my-tag-key")
# @param tag_value [String] Your tag value (e.g. "my-tag-value")
#
def create_secret_with_tags project_id:, secret_id:, tag_key:, tag_value:
  # Create a Secret Manager client.
  client = Google::Cloud::SecretManager.secret_manager_service

  # Build the resource name of the parent project.
  parent = client.project_path project: project_id

  # Create the secret.
  secret = client.create_secret(
    parent:    parent,
    secret_id: secret_id,
    secret:    {
      replication: {
        automatic: {}
      },
      tags: {
        tag_key.name => tag_value.name
      }
    }
  )

  # Print the new secret name.
  puts "Created secret with tag: #{secret.name}"
end

為現有資源新增標記

如要為現有密鑰新增標記,請按照下列步驟操作:

控制台

  1. 前往 Google Cloud 控制台的「Secret Manager」頁面。
  2. 前往 Secret Manager

  3. 選取要附加標記的密鑰。
  4. 按一下 「Tags」(標記)。
  5. 如果「Tags」(標記) 面板中未顯示您的組織,請按一下「Select scope」(選取範圍)。選取您的組織,然後按一下「Open」(開啟)。
  6. 按一下「新增代碼」。
  7. 從清單中選取標記鍵和標記值。您可以使用關鍵字篩選清單。
  8. 按一下「儲存」。
  9. 在「Confirm」(確認) 對話方塊中,按一下「Confirm」(確認) 即可附加標記。
  10. 系統會顯示通知,確認標記已更新。

gcloud

如要將標記附加至 Secret,請使用 gcloud resource-manager tags bindings create 指令建立標記繫結資源:

使用下列任何指令資料前,請先替換以下項目:

  • TAGVALUE_NAME:附加標記值的永久 ID 或命名空間名稱,例如 tagValues/567890123456。
  • RESOURCE_ID 是資源的完整 ID,包括用於識別資源類型的 API 網域名稱 (//secretmanager.googleapis.com/)。舉例來說,如要將標記附加至 /projects/PROJECT_ID/secrets/SECRET_ID,完整 ID 為 //secretmanager.googleapis.com/projects/PROJECT_ID/secrets/SECRET_ID。

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud resource-manager tags bindings create \
    --tag-value=TAGVALUE_NAME \
    --parent=RESOURCE_ID

Windows (PowerShell)

gcloud resource-manager tags bindings create `
    --tag-value=TAGVALUE_NAME `
    --parent=RESOURCE_ID

Windows (cmd.exe)

gcloud resource-manager tags bindings create ^
    --tag-value=TAGVALUE_NAME ^
    --parent=RESOURCE_ID

Node.js

如要執行這段程式碼,請先設定 Node.js 開發環境,並安裝 Secret Manager Node.js SDK。在 Compute Engine 或 GKE 上,您必須使用 cloud-platform 範圍進行驗證。

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'my-project';
// const secretId = 'my-secret';
// const tagValue = 'tagValues/281476592621530';
const parent = `projects/${projectId}`;

// Imports the library
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager');
const {TagBindingsClient} = require('@google-cloud/resource-manager').v3;

// Instantiates a client
const client = new SecretManagerServiceClient();
const resourcemanagerClient = new TagBindingsClient();

async function bindTagsToSecret() {
  const [secret] = await client.createSecret({
    parent: parent,
    secretId: secretId,
    secret: {
      replication: {
        automatic: {},
      },
    },
  });

  console.log(`Created secret ${secret.name}`);

  const [operation] = await resourcemanagerClient.createTagBinding({
    tagBinding: {
      parent: `//secretmanager.googleapis.com/${secret.name}`,
      tagValue: tagValue,
    },
  });
  const [response] = await operation.promise();
  console.log('Created Tag Binding', response.name);
}

bindTagsToSecret();

PHP

如要執行這段程式碼,請先瞭解如何在 Google Cloud 上使用 PHP,並安裝 Secret Manager PHP SDK。在 Compute Engine 或 GKE 上,您必須使用 cloud-platform 範圍進行驗證。

// Import the Secret Manager client library.
use Google\Cloud\SecretManager\V1\CreateSecretRequest;
use Google\Cloud\SecretManager\V1\Replication;
use Google\Cloud\SecretManager\V1\Replication\Automatic;
use Google\Cloud\SecretManager\V1\Secret;
use Google\Cloud\SecretManager\V1\Client\SecretManagerServiceClient;
use Google\Cloud\ResourceManager\V3\Client\TagBindingsClient;
use Google\Cloud\ResourceManager\V3\CreateTagBindingRequest;
use Google\Cloud\ResourceManager\V3\TagBinding;

/**
 * @param string $projectId Your Google Cloud Project ID (e.g. 'my-project')
 * @param string $secretId  Your secret ID (e.g. 'my-secret')
 * @param string $tagValue  Your tag value (e.g. 'tagValues/281476592621530')
 */
function bind_tags_to_secret(string $projectId, string $secretId, string $tagValue): void
{
    // Create the Secret Manager client.
    $client = new SecretManagerServiceClient();

    // Build the resource name of the parent project.
    $parent = $client->projectName($projectId);

    $secret = new Secret([
        'replication' => new Replication([
            'automatic' => new Automatic(),
        ]),
    ]);

    // Build the request.
    $request = CreateSecretRequest::build($parent, $secretId, $secret);

    // Create the secret.
    $newSecret = $client->createSecret($request);

    // Print the new secret name.
    printf('Created secret %s' . PHP_EOL, $newSecret->getName());

    $tagBindingsClient = new TagBindingsClient();
    $tagBinding = (new TagBinding())
        ->setParent('//secretmanager.googleapis.com/' . $newSecret->getName())
        ->setTagValue($tagValue);

    // Build the binding request.
    $request = (new CreateTagBindingRequest())
        ->setTagBinding($tagBinding);

    // Create the tag binding.
    $operationResponse = $tagBindingsClient->createTagBinding($request);
    $operationResponse->pollUntilComplete();

    // Check if the operation succeeded.
    if ($operationResponse->operationSucceeded()) {
        printf('Tag binding created for secret %s with tag value %s' . PHP_EOL, $newSecret->getName(), $tagValue);
    } else {
        $error = $operationResponse->getError();
        printf('Error in creating tag binding: %s' . PHP_EOL, $error->getMessage());
    }
}

Python

如要執行這段程式碼,請先設定 Python 開發環境,並安裝 Secret Manager Python SDK。在 Compute Engine 或 GKE 上,您必須使用 cloud-platform 範圍進行驗證。

import argparse

# Import the Secret Manager and Resource Manager client library.
from google.cloud import resourcemanager_v3
from google.cloud import secretmanager


def bind_tags_to_secret(
    project_id: str,
    secret_id: str,
    tag_value: str,
) -> resourcemanager_v3.TagBinding:
    """
    Create a new secret with the given name, and then bind an existing tag to it.
    A secret is a logical wrapper around a collection of secret versions. Secret
    versions hold the actual secret material.
    """

    # Create the Secret Manager client.
    client = secretmanager.SecretManagerServiceClient()

    # Build the resource name of the parent project.
    parent = f"projects/{project_id}"

    # Create the secret.
    secret_response = client.create_secret(
        request={
            "parent": parent,
            "secret_id": secret_id,
            "secret": {
                "replication": {"automatic": {}},
            },
        }
    )

    # Print the new secret name.
    print(f"Created secret: {secret_response.name}")

    # Create the resource manager client
    resource_manager_client = resourcemanager_v3.TagBindingsClient()

    # Create the tag binding
    request = resourcemanager_v3.CreateTagBindingRequest(
        tag_binding=resourcemanager_v3.TagBinding(
            parent=f"//secretmanager.googleapis.com/{secret_response.name}",
            tag_value=f"{tag_value}",
        ),
    )

    # Create the tag binding
    operation = resource_manager_client.create_tag_binding(request=request)

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

    # Print the tag binding
    print(f"Created tag binding: {response.name}")

    return response

列出附加至資源的標記

您可以查看直接附加至 Secret 或由 Secret 繼承的標記繫結清單。

控制台

  1. 前往 Google Cloud 控制台的「Secret Manager」頁面。
  2. 前往 Secret Manager

  3. 標記會顯示在密鑰的「Tags」(標記) 欄。

gcloud

如要取得附加至資源的標記繫結清單,請使用 gcloud resource-manager tags bindings list 指令:

使用下列任何指令資料前,請先替換以下項目:

  • RESOURCE_ID 是資源的完整 ID,包括用於識別資源類型的 API 網域名稱 (//secretmanager.googleapis.com/)。舉例來說,如要將標記附加至 /projects/PROJECT_ID/secrets/SECRET_ID,完整 ID 為 //secretmanager.googleapis.com/projects/PROJECT_ID/secrets/SECRET_ID。

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud resource-manager tags bindings list \
    --parent=RESOURCE_ID

Windows (PowerShell)

gcloud resource-manager tags bindings list `
    --parent=RESOURCE_ID

Windows (cmd.exe)

gcloud resource-manager tags bindings list ^
    --parent=RESOURCE_ID

您應該會收到類似以下的回應:

  name: tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F7890123456/tagValues/567890123456
    tagValue: tagValues/567890123456
    resource: //secretmanager.googleapis.com/projects/project-abc/secrets/secret-xyz

卸離資源的標記

您可以卸除直接附加至 Secret 的標記。如要覆寫繼承的標記,請附加具有相同鍵和不同值的標記,但無法卸離。

控制台

  1. 前往 Google Cloud 控制台的「Secret Manager」頁面。
  2. 前往 Secret Manager

  3. 選取要移除標記的密鑰。
  4. 按一下 「Tags」(標記)。
  5. 在「Tags」(標記) 面板中,找出要卸載的標記,然後按一下旁邊的「Delete item」(刪除項目) 。
  6. 按一下「儲存」。
  7. 在「Confirm」(確認) 對話方塊中,按一下「Confirm」(確認) 即可卸離標記。

系統會顯示通知,確認標記已更新。

gcloud

如要刪除標記繫結,請使用 gcloud resource-manager tags bindings delete 指令:

使用下列任何指令資料前,請先替換以下項目:

  • TAGVALUE_NAME:附加標記值的永久 ID 或命名空間名稱,例如 tagValues/567890123456。
  • RESOURCE_ID 是資源的完整 ID,包括用於識別資源類型的 API 網域名稱 (//secretmanager.googleapis.com/)。舉例來說,如要將標記附加至 /projects/PROJECT_ID/secrets/SECRET_ID,完整 ID 為 //secretmanager.googleapis.com/projects/PROJECT_ID/secrets/SECRET_ID。

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud resource-manager tags bindings delete \
    --tag-value=TAGVALUE_NAME \
    --parent=RESOURCE_ID

Windows (PowerShell)

gcloud resource-manager tags bindings delete `
    --tag-value=TAGVALUE_NAME `
    --parent=RESOURCE_ID

Windows (cmd.exe)

gcloud resource-manager tags bindings delete ^
    --tag-value=TAGVALUE_NAME ^
    --parent=RESOURCE_ID

刪除標記鍵和值

移除標記鍵或值定義時,請確認標記已與密鑰解除連結。您必須先刪除現有的標記連結 (稱為標記繫結),才能刪除標記定義本身。詳情請參閱「刪除標記」。

Identity and Access Management 條件和標記

您可以使用標記和 IAM 條件,有條件地將角色繫結授予階層中的使用者。如果已套用具備條件式角色繫結的 IAM 政策,變更或刪除附加至資源的標記,可能會移除使用者對該資源的存取權。詳情請參閱「Identity and Access Management 條件和標記」。

後續步驟