Steve Scoleri
03/19/2025, 3:18 PMShiraz Malik
03/21/2025, 1:26 PM[ERROR] KeyError: 'WorkspaceId'
Traceback (most recent call last):
File "/var/task/custodian_policy.py", line 4, in run
return handler.dispatch_event(event, context)
File "/var/task/c7n/handler.py", line 170, in dispatch_event
p.push(event, context)
File "/var/task/c7n/policy.py", line 1347, in push
return mode.run(event, lambda_ctx)
File "/var/task/c7n/policy.py", line 1030, in run
resources = super(ConfigRuleMode, self).run(event, lambda_context)
File "/var/task/c7n/policy.py", line 506, in run
resources = self.policy.resource_manager.filter_resources(
File "/var/task/c7n/manager.py", line 113, in filter_resources
resources = f.process(resources, event)
File "/var/task/c7n/filters/core.py", line 352, in process
return self.process_set(resources, event)
File "/var/task/c7n/filters/core.py", line 369, in process_set
resource_map = {r[rtype_id]: r for r in resources}
File "/var/task/c7n/filters/core.py", line 369, in <dictcomp>
resource_map = {r[rtype_id]: r for r in resources}
The "invokingEvent" I see before this error has "Id", "resourceId", and "resourceName" in the structure. So the error above is valid as the Lambda doesn't find "WorkspaceId" in the structure it gets from the Config.
I deployed the same policy without type "config-rule" from the terminal just to filter out the resources with missing tags. The run was successful and the result returned all the Workspaces which are complying to the rules defined in the "filter. So the issue seems to be only when Config gets involved.
Moreover, have seen similar error (KeyError) when using Config with other resources like: elasticbeanstalk-environment, secretsmanager-secrets-manager, stepfunctions-step-machine
Anyone has experienced the same when running policy through Config+Lambda?
Thanks.
-ShirazShrey
03/24/2025, 1:29 PMprasanna
03/24/2025, 4:15 PMprasanna
03/24/2025, 4:15 PMJacob
03/28/2025, 4:47 PMc7n-mailer
configuration for email for azure and aws. AWS has ses and i’ve configured that for c7n-mailer, but it looks like azure is rather limited here. So i’m wondering if it would be better to have a single smtp server with something like a postfix to handle aws and azure. But i don’t know if c7n-mailer when using postfix, would be able to use the function to retrieve the messages from aws sqs and azure aqs respectivelyRB
04/01/2025, 9:33 PM43976989
04/06/2025, 5:13 PM- or:
- type: ebs
key: Encrypted
value: false
- or:
- type: ebs
key: KmsKeyId
op: not-in
value: [list]
- not:
- and:
- type: event
key: account
op: in
value: [ list ]
- type: ebs
key: KmsKeyId
op: regex
value: 'regex'
That doesn't work the way I'd expect though - for some reason it matches a much wider range of accounts than intended, and I'm finding it extremely hard to pinpoint why as I don't know how to get c7n to show which specific filter caused the match.RB
04/08/2025, 6:36 PMset-continuous-backup
but it’s missing from the docs. Is this a bug in the automated documentation ?RB
04/09/2025, 6:03 AMChhavi
04/10/2025, 12:41 PMLuis Cosio
04/10/2025, 10:29 PMLuis Cosio
04/10/2025, 10:30 PM- name: vpcflow
resource: aws.vpc
description: |
Identify VPCs which don't have flow logs setup correctly.
filters:
- not:
- type: flow-logs
enabled: True
actions:
- type: notify
kind: Security
priority: HIGH
subject: "VPC flow logs are not enabled"
violation_desc: "VPC flow logs are not enabled"
action_desc: |
"Review and enable VPC flow logs for all your VPCs"
<<: *sqsSaving
Luis Cosio
04/10/2025, 10:30 PM(.venv) PS E:\Dropbox\Projects\Hypercube\policies> custodian validate aws/production.yml
2025-04-10 16:28:59,146: custodian.commands:WARNING deprecated usage found in policy
policy 's6t-cis-v140-aws-vpc-flow-log-reporting-pull' (production.yml:1428)
filters:
field 'flow-logs.enabled' has been deprecated (replaced by use list-item style attrs and set operators)
2025-04-10 16:28:59,147: custodian.commands:INFO Configuration valid: aws/production.yml
(.venv) PS E:\Dropbox\Projects\Hypercube\policies>
RB
04/11/2025, 12:54 AMlucas
04/11/2025, 4:54 AMPavanipriya
04/11/2025, 11:08 PMAlex
04/12/2025, 2:38 AMAlex
04/12/2025, 2:40 AMAlex
04/12/2025, 10:43 AMParth Joshi
04/15/2025, 11:22 PMpolicies:
- name: delete-unused-lambdas
resource: aws.lambda
description: Delete Lambda functions not executed in last 90 days
filters:
- type: value
key: "LastModified"
value_type: age
op: ge
value: 90
actions:
- type: delete
Version 2: Result, no resources given in the resources.json file after the dry run and I feel like Last Executed key may not be supported with lambda but perhaps with CloudWatch
policies:
- name: delete-unused-lambdas
resource: aws.lambda
description: Delete Lambda functions not executed in last 90 days
filters:
- type: value
key: "LastExecuted"
value_type: age
op: ge
value: 90
actions:
- type: delete
Version 3: Result, no resources given in the resources.json file after the dry run and statistic not expected
policies:
- name: delete-unused-lambdas
resource: aws.lambda
description: Delete Lambda functions not executed in last 90 days
filters:
- type: metrics
name: Invocations
statistic: Sum
days: 90
period: 86400 # Daily granularity
op: eq
value: 0
actions:
- type: delete
Version 4: Result, gives me an error about statistic being unexpected, tried to play around with it but it doesn't work
policies:
- name: delete-unused-lambdas
resource: aws.lambda
description: Delete Lambda functions not executed in last 90 days
filters:
- type: value
key: "Configuration.LastExecuted"
statistic: Sum
days: 90
period: 86400 # Daily granularity
op: eq
value: 0
actions:
- type: delete
Could someone help me with creating a working script to delete AWS Lambda functions that haven’t been invoked in the last 90 days?
I’m struggling to get it working and I’m not sure if such an automation is even feasible. I’ve successfully built similar cleanup automations for other resources, but this one’s proving to be tricky.Soumya
04/17/2025, 3:29 AMmirani
04/21/2025, 8:33 PMAfif Mohd-Amir
04/22/2025, 5:21 PMRB
04/23/2025, 4:34 AMSoumya
04/23/2025, 9:45 AMJulian
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 PM