gcp create_notification_channel creates a duplicate channel

Viewed 38

GCP Python client method to Create Monitoring Notification channel is not idempotent.
Duplicate Channels under same Project are getting created.

Is there a way to avoid duplication?

create_notification_channel

1 Answers

According the documentation it's not possible to handle duplicates directly but you can solve your issue with the following actions :

  • List the existing notification channels in GCP via the list_notification_channels
  • Loop on the actual notifications channels (maybe configured in your code), if the element exist in GCP (check from the list retrieved previously), update it via update_notification_channel function, otherwise create it with create_notification_channel function.
Related