Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws - filters - "missing" filter throw an error running on lambda function #5829

Closed
TanguyCme opened this issue Jun 3, 2020 · 2 comments · Fixed by #5832
Closed

aws - filters - "missing" filter throw an error running on lambda function #5829

TanguyCme opened this issue Jun 3, 2020 · 2 comments · Fixed by #5832
Labels

Comments

@TanguyCme
Copy link
Contributor

TanguyCme commented Jun 3, 2020

Describe the bug
While updating from 0.8 to 0.9 I faced an issue with some of my rules. When I use a missing filter in a policy deployed on a lambda function.

To Reproduce
Deploy the Lambda function and create an ACM certificate, then delete it
you can find the error of the lambda function in cloudwatch

Expected behavior
The lambda function has a correct execution.

Background (please complete the following information):

  • OS: AWS Lambda
  • Python Version: 3.7
  • Custodian Version: 0.9.2
  • Tool Version: 0.9.2
  • Cloud Provider: aws
  • Policy:
policies: 
  - name: certificate-deleted
    resource: account
    filters:
      - type: missing
        policy:
            resource: acm-certificate
            filters:
              - type: value
                key: certificateArn
                op: eq
                value: "detail.requestParameters.certificateArn"
    mode:
      function-prefix: "SEC-c7n-"
      type: cloudtrail
      role: YOURROLE
      events:
        - source: acm.amazonaws.com
          event: DeleteCertificate
          ids: requestParameters.certificateArn
    actions:
      - type: post-finding
        severity_normalized: 1
        types:
          - "Unusual Behaviors/SEC"
        compliance_status: WARNING
        recommendation: "SEC"
  • Traceback:
[ERROR] RuntimeError: missing jsonschema dependency
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 175, in dispatch_event
    p.validate()
  File "/var/task/c7n/policy.py", line 1047, in validate
    f.validate()
  File "/var/task/c7n/filters/missing.py", line 49, in validate
    collection = PolicyLoader(
  File "/var/task/c7n/loader.py", line 136, in load_data
    errors = self.validator.validate(policy_data, tuple(rtypes))
  File "/var/task/c7n/loader.py", line 47, in validate
    self.gen_schema(tuple(sorted(resource_types)))
  File "/var/task/c7n/loader.py", line 74, in gen_schema
    self.validator = v = self._gen_schema(resource_types)
  File "/var/task/c7n/loader.py", line 82, in _gen_schema
    raise RuntimeError("missing jsonschema dependency")
@TanguyCme
Copy link
Contributor Author

This error seems to occur only running on lambda function, due to a missing library : jsonschema, but was working properly in c7n==0.8.45

@TanguyCme TanguyCme reopened this Jun 3, 2020
@kapilt
Copy link
Collaborator

kapilt commented Jun 3, 2020

thanks for reporting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants