[ Web Proxy ]
URL:
Viewing: https://cloud.google.com/kms/docs/monitor-state-changes [Back]  [Original]

Monitor state changes using Pub/Sub  |  Cloud Key Management Service  |  Google Cloud Documentation Skip to main content
Google Cloud Documentation [Google Cloud Documentation]
Send feedback

Monitor state changes using Pub/Sub Stay organized with collections Save and categorize content based on your preferences.

This page shows you how to use Pub/Sub to create notifications on state changes for Cloud KMS resources.

Before you begin

To enable APIs, grant required permissions, and create a Pub/Sub topic, follow the instructions in Before you begin in "Monitoring asset changes".

Configure a feed

Configure a feed that monitors the type of changes and resources that you are interested in.

Notify on all resource changes

To create a feed, use the gcloud asset feeds create command.

gcloud asset feeds create FEED_NAME \
  --project=PROJECT_ID  \
  --asset-types="RESOURCE_TYPE" \
  --pubsub-topic="PUBSUB_TOPIC"

Replace the following:

This creates a notification when resources of the indicated type are created or updated. The notification indicates that the resource has been updated, but does not include detailed information about the update. For example, an update notification for a CryptoKeyVersion might mean the version was made primary or that the version was scheduled for destruction. When you receive a notification that a resource has been updated, you should check the resource to find its current state.

Note: Cloud KMS does not support resource deletion. Key rings, keys, and key versions can't be deleted. The only way to fully delete Cloud KMS resources is to delete the project that contains them. Scheduling a CryptoKeyVersion for destruction and destruction of CryptoKeyVersion resources are update operations.

Notify on specific resource changes

To create a feed with a condition, use the gcloud asset feeds create command with the --condition-expression flag.

gcloud asset feeds create FEED_NAME \
  --project=PROJECT_ID  \
  --asset-types="RESOURCE_TYPE" \
  --pubsub-topic="PUBSUB_TOPIC" \
  --condition-expression="CONDITION_EXPRESSION"

Replace the following:

This creates a notification when resources of the indicated type that match the specified condition expression are created, deleted, or updated.

Send feedback

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-08-11 UTC.

Need to tell us more? [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-11 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page