Julian
04/23/2025, 7:04 PMpolicies:
# policy to copy tags from RDS clusters to RDS instances
- name: rds-copy-tags-from-cluster-to-instances
resource: rds
actions:
- type: copy-related-tag
resource: rds-cluster
skip_missing: True
key: DBClusterIdentifier
tags: "*"
Error:
2025-04-23 14:30:45,805: custodian.policy:INFO policy:rds-copy-tags-from-cluster-to-instances resource:rds region:us-east-1 count:264 time:0.01
2025-04-23 14:30:46,304: custodian.resources.rdscluster:WARNING event ids not resolved: [<redacted, 206 cluster ids>] error:An error occurred (InvalidParameterCombination) when calling the DescribeDBClusters operation: Only up to 100 unique filter DB Cluster Identifiers may be specified per filter.
2025-04-23 14:30:46,312: custodian.actions:INFO Tagged 0 resources from related, missing-skipped 264 unchanged 0
2025-04-23 14:30:46,313: custodian.policy:INFO policy:rds-copy-tags-from-cluster-to-instances action:copyrelatedresourcetag resources:264 execution_time:0.49
I managed to put together a fix by updating CopyRelatedResourceTag.get_resource_tag_map, and confirmed that it worked. Is this something that I could create a PR for? Thanks in advance!kapilt
04/24/2025, 2:13 PMRB
04/29/2025, 5:09 AMkapilt
04/30/2025, 3:37 PMKiran
05/03/2025, 10:40 PMactions:
- type: notify
template: default
subject: "[C7N] Auto-Tagging Alert **"
to:
- resource-owner
transport:
type: sns
topic: arn:aws:sns:us-west-2:xxx:cloud-custodian-slack-topic
json: true
import os
import json
import gzip
import base64
import urllib.request
from io import BytesIO
def lambda_handler(event, context):
print("Received event:", json.dumps(event))
webhook_url = os.environ['SLACK_WEBHOOK_URL']
for record in event['Records']:
sns_message = record['Sns']['Message']
print("SNS message raw:", sns_message)
try:
# Step 1: Extract and parse JSON wrapper
wrapper = json.loads(sns_message)
encoded_text = wrapper.get('text')
if not encoded_text:
raise ValueError("Missing 'text' field in SNS message")
print("Base64-encoded string length:", len(encoded_text))
# Step 2: Base64 decode
compressed_bytes = base64.b64decode(encoded_text)
print("Decoded base64 length:", len(compressed_bytes))
# Step 3: Gzip decompress
with gzip.GzipFile(fileobj=BytesIO(compressed_bytes)) as f:
decompressed_bytes = f.read()
message = json.loads(decompressed_bytes)
print("Decompressed message:", message)
slack_text = f"[Cloud Custodian Notification]\n```{json.dumps(message, indent=2)}```"
except Exception as e:
print("Decompression/decoding failed:", str(e))
slack_text = f"(raw fallback) {sns_message}"
# Send to Slack
payload = {"text": slack_text}
req = urllib.request.Request(
webhook_url,
data=json.dumps(payload).encode('utf-8'),
headers={'Content-Type': 'application/json'}
)
try:
with urllib.request.urlopen(req) as response:
print("Slack response:", response.read().decode())
except Exception as e:
print("Failed to send to Slack:", str(e))
return {"status": "done"}
RB
05/07/2025, 3:45 AMc7n-org report
feature ?mayuri
05/07/2025, 10:53 PM# Fetch allowed service tag values from dynamodb and validate against the resource's service tag
- type: value
key: tag:service
op: not-in
value_from:
url: dynamodb
query: select id from "service_tag_extract"
expr: '[*].id.S'
RB
05/08/2025, 1:38 AMRB
05/08/2025, 1:39 AMAse
05/08/2025, 5:12 AMrk
05/09/2025, 1:29 PMRB
05/12/2025, 2:55 PMs3:GetBucketPolicy
and custodian’s iam role happens to NOT be on that list.
That means there are a number of s3 buckets with policies that custodian cannot access. Is there a way to craft a policy to detect all of these s3 buckets ?Ed
05/13/2025, 11:11 PM- name: elb-no-instances
resource: elb
description: |
Find any ELB with no instances
filters:
- Instances: []
But running cloud custodian would only get me the classic
lbs with no instances. Is there a way to get all elbs/albs with no instances?
I tried:
- name: elb-no-instances-v2
resource: app-elb
description: |
Find any ELB with no instances
filters:
- Instances: []
to no avail.
I appreciate the help. Thank you!Henry Finucane
05/14/2025, 10:53 PMpolicies:
- name: clean-test-vpcs
resource: aws.vpc
filters:
- "tag:environment": "ci"
actions:
- mark-for-op
- name: clean-leaked-enis
resource: aws.eni
filters:
- type: vpc
# and uh, value is in the list of things matched by `clean-test-vpcs`
actions:
- delete
Jacob
05/15/2025, 8:14 PMexternalId
? To prevent confused deputy. I have my cross account roles setup fine, just want to know if i can lock it down further with an externalId
. I’m not sure if that would be set in the accounts.yaml for c7n-org.Steven Lott
05/19/2025, 12:40 PMRB
05/20/2025, 8:25 PMAWS_MAX_ATTEMPTS=10
. I hope that helps others too.Gonzalo Gentile
05/21/2025, 10:47 AMpolicies:
- name: check-eks
resource: eks
filters:
- not:
- type: value
key: "logging.clusterLogging[].types[]"
op: contains
value:
- audit
the resource json schema looks like this:
"logging": {
"clusterLogging": [
{
"types": [
"api",
"audit",
"authenticator",
"controllerManager",
"scheduler"
],
"enabled": true
}
]
}
Any ideas? thanks in advance!kapilt
05/30/2025, 3:47 PMRB
05/30/2025, 7:21 PMus-east-1
by default ?
This would save us from adding this to all of our iam cloud custodian policies
conditions:
- region: us-east-1
RB
06/01/2025, 2:08 PMpolicies:
- name: super-users
resource: aws.iam-user
filters:
- type: check-permissions
match: allowed
actions:
- iam:*
kapilt
06/02/2025, 8:25 PMTom Nguyen
06/05/2025, 2:30 AMnotify
type within an ec2 off-hours-policy with Slack delivery via the mailer, using the following snippet:
- type: notify
slack_template: slack-alert
slack_msg_color: warning
subject: "EC2 Instance(s) Stopped for Off-Hours"
violation_desc: "Your EC2 instance(s) have been automatically stopped as part of off-hours management."
action_desc: "..."
to:
- <slack://tag/Owner>
transport:
type: sqs
queue: <https://X>
The issue I'm hitting is that when multiple instances match the filter, they get bundled into a single message payload, which means the mailer Lambda sends all of them to one Owner
tag recipient — usually just the first one found.
What I'd like is for each resource to be sent to its respective Owner
, ideally as separate messages or otherwise handled individually in the mailer.
Should I be using a different to:
value than <slack://tag/Owner>
? Or is there a way to split/group the message per Owner
so the mailer sends them separately?
Appreciate any pointers — thanks! 🙏EJ Santos
06/10/2025, 12:30 AMSanjeewa Dasanayaka
06/11/2025, 7:33 AMactions:
- type: set-instance-profile
when trying to push this policy to our git repo, I'm getting a error like "Exception: Invalid action type found for phase: set-instance-profile"
but i was able to push this policy to one f our AWS account manually using the command "custodian run -s /home/ubuntu/logs /home/ubuntu/ec2.yml" and its working fine by creating a lambda also.
what action can be used here? why the error comes when using pipeline to push GitHub repo but not when deploying manually ?corey
06/12/2025, 4:28 PMpython3.9
from when it was the default. I’d like to bump them to the new default python3.11
.
I’m using c7n-org if it makes a difference.Fernando Toledo
06/12/2025, 6:07 PMFernando Toledo
06/12/2025, 6:08 PMAlistair
06/17/2025, 5:35 PMOreoluwa
06/19/2025, 6:57 PM