azure icon indicating copy to clipboard operation
azure copied to clipboard

Feature Proposal: Eventgrid Subscriptions

Open howardjones opened this issue 3 years ago • 2 comments

SUMMARY

(I'm partway through writing this - this is the pre-PR Issue as requested in your docs, and also a query)

azure_rm_eventgridsubscription module to allow for the management of Event subscriptions on various Azure objects that support them.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

azure_rm_eventgridsubscription

ADDITIONAL INFORMATION

Eventgrid subscriptions allow event-driven automation between Azure components, including Key Vaults, Storage Accounts, and also general create/delete/failure events from Resource Groups or Subscriptions. My initial-use case is to add expiry events to our key vaults as they are created, so that the vault will raise an event when it is time to renew certs, tokens etc. However, it would be very useful for any process using a storage account as a queue or a BLOB dropbox too.

There are several other destination types, but my initial need is for webhooks. I'm intending to make the task parameters take into account the extension for the other destination types though.


- name: Create an event subscription on the Key Vault
  azure_rm_eventgridsubscription:
    name: "event{{ rpfx }}"
    scope: "/subscriptions/{{azure_subscription_id}}/resourceGroups/{{ resource_group }}/providers/Microsoft.KeyVault/vaults/vault{{rpfx}}"
    state: present
    destination_type: webhook
    webhook_url: https://listener.contoso.local/events
    event_types:
      - Microsoft.KeyVault.SecretExpired
      - Microsoft.KeyVault.SecretNearExpiry

howardjones avatar Dec 03 '21 13:12 howardjones

The query that goes with this: I have written a test playbook, but you can't actually create a webhook event subscription without an active web application running - Azure calls out to the webhook and expects a correct response, not just 200, from the far end. What should I do to make a test that works? It wouldn't be so hard to make a really small container that answers these requests, but where would it go? The URL for it would need to be known to the test playbook.

howardjones avatar Dec 03 '21 13:12 howardjones

Any feedback on how the test could work?

howardjones avatar Apr 10 '23 09:04 howardjones