question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

lambda policies need a virtualenv installation.

See original GitHub issue

Getting the following error in the cloudwatch log stream associated with the lambda function provisioned after running a policy:

Unable to import module ‘custodian_policy’: No module named pkg_resources

using the policy below and invoking it with custodian run -c policy.yml -s out --log-group=/cloud-custodian/dev-account/us-west-2 --region us-west-2 -m

Is there something I’m missing that is causing the mu to not create the lambda function zip file correctly?

policies:
- name: ec2-require-non-public-and-encrypted-volumes
  resource: ec2
  description: |
   Provision a lambda and cloud watch event target
   that looks at all new instances not in an autoscale group
   and terminates those with unencrypted volumes.
  mode:
   type: cloudtrail
   role: arn:aws:iam::XXXXXXXXXXXX:role/custodianRole
   events:
  - RunInstances
    filters:
  - "tag:aws:autoscaling:groupName": absent
  - type: ebs
    key: Encrypted
    value: false
    actions:
  - terminate
- name: tag-compliance
  resource: ec2
  description:
   Schedule a resource that does not meet tag compliance policies
   to be stopped in four days.
  filters:
  - State.Name: running
  - "tag:Environment": absent
  - "tag:AppId": absent
  - or:
    - "tag:OwnerContact": absent
    - "tag:DeptID": absent
      actions:
  - type: mark-for-op
    op: stop
    days: 4

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:35 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
kapiltcommented, Feb 23, 2017

@whit537 could you have a look at this one.

0reactions
kapiltcommented, Mar 17, 2017

awesome

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploy Python Lambda functions with .zip file archives
Activate the virtual environment. For example: · Install libraries with pip. (myvenv) ~/my-function$ pip install requests · Deactivate the virtual environment.
Read more >
AWS Lambda with Python 3 and virtualenv failed to install ...
In this build process, I create two virtualenv, install my dependencies into them and then I zip my lambda deployment packages composed by:...
Read more >
Using Virtual Environments with Lambda Stack - DeepTalk
Use Lambda Stack as an easy way to install your Drivers, CUDA, CuDNN, etc. ... you'll simply install Lambda Stack and then create...
Read more >
Serverless Framework — Package Your Lambda Functions ...
AWS Lambda is one of the powerful service for running serverless workloads ... If you don't have virtualenv installed you can install it...
Read more >
How to Install Python Packages for AWS Lambda Layers
1. Build ... Hopefully, you have Docker set up but if you don't then be sure to do that first. The first thing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found