I'm trying to create a custom policy and action using Cloud Custodian to automate some tasks on my cloud provider (e.g., AWS, GCP, etc.). Specifically, I need to scan for resources that lack an "Owner" tag, and if such resources are found, send a Slack message to a designated channel.
This is my YAML file so far:
policies:
- name: gcp-list-instances-without-owner
resource: gcp.instance
description: This policy returns all GCP instances with no owner tag
filters:
- "tag:Owner": absent
actions:
- type: webhook
url: https://slack.com/api/chat.postMessage
method: POST
query-params:
channel: C04MT6JFT6U
as_user: dannyp
text: Missing
pretty: '1'
headers:
Authorization: Bearer <AUTH>
But I keep getting this error message: is not valid under any of the given schemas
A few points:
- The policy without the action works fine and lists my untagged resources
- I validated in a curl command that the slack url and bearer authorization works
Any ideas what is wrong here?
was trying to create a custom policy and action using Cloud Custodian to automate some tasks on their cloud provider. Specifically, they had a dataset with some specific requirements and wanted to use that data to create a policy that can filter resources based on those requirements and an action that can take some actions on the filtered resources. The specific requirement was to scan for owner tags and if it is absent, send a slack message in a channel.