Skip to content

Instantly share code, notes, and snippets.

@chrisswanda
Created July 19, 2022 14:24
Show Gist options
  • Save chrisswanda/4770d59ac0c90fb403a9b6ad4f224174 to your computer and use it in GitHub Desktop.
Save chrisswanda/4770d59ac0c90fb403a9b6ad4f224174 to your computer and use it in GitHub Desktop.
Cloud Custodian (c7n) to Azure Teams Incoming Webhook
# Unfortunately we use Teams and I needed a way to deliver a payload to an incoming webhook via Lambda for
# various c7n things.
#
# Below is just an example.
policies:
- name: call-Azure-webhook
resource: ec2
description: |
Call webhook with list of resource groups
# mode:
# type: periodic
# role: arn:aws:iam::1234567890:role/c7n-role
# schedule: "rate(1 day)"
filters:
- or:
- "tag:Environment": absent
- "tag:Name": absent
- "tag:Business Unit": absent
- not:
- State.Name: terminated
actions:
- type: webhook
url: https://your_incoming_webhook.azure.com
batch: false
body: >
{
"@context": `https://schema.org/extensions`,
"@type": `MessageCard`,
"themeColor": `C75300`,
"title": join ('', ['Account: ' , account_id, 'Region: ', region, ' Test from Lambda to Teams Webhook']),
"text": join ('', [ 'The following instance is not tagged correctly - InstanceID: ' , resource.InstanceId]),
"potentialAction": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment