HI, I recently updated our Cloud Custodian deploym...
# development
d
HI, I recently updated our Cloud Custodian deployment on AWS to Lambda Runtime 3.12. After doing so the following error is being produced.
Copy code
Unable to import module 'periodic': No module named 'chardet'
I'm having difficulty finding any information on why chardet isn't getting included in the lambda package .zip file. Can anyone suggest where I might find some info on how to fix this?
k
Did you use python 3.12 to deploy it as well?
We create the zip and dependencies from the local python installation, so it’s best practice to use a a runtime that matches the cli python version
Do you have the full trace back?
d
Ah, so the /bin directory needs a matching python binary?
k
Ideally yes, we don’t typically have dependencies on c extensions so it generally works across versions, but there are exceptions. That said I don’t recall any chardet direct usage, so it’s likely an indirect dependency. But also in a meeting for a few hrs so can’t dig in into it. If you have a full trace back that would be useful.
d
I have the errors the lambda produced, but I don't think those are what you're looking for.
They are just the generic errors and the line I posted earlier.
Copy code
[WARNING]	2025-10-22T13:30:05.088Z		LAMBDA_WARNING: Unhandled exception. The most likely cause is an issue in the function code. However, in rare cases, a Lambda runtime update can cause unexpected function behavior. For functions using managed runtimes, runtime updates can be triggered by a function change, or can be applied automatically. To determine if the runtime has been updated, check the runtime version in the INIT_START log entry. If this error correlates with a change in the runtime version, you may be able to mitigate this error by temporarily rolling back to the previous runtime version. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-update.html
Copy code
[ERROR] Runtime.ImportModuleError: Unable to import module 'periodic': No module named 'chardet' Traceback (most recent call last):
k
Did the runtime update happen via policy change or via lambda console?
d
Basically I searched for python3.9 and changed it every where I found it it our repo.
the mailer.yaml aka mailer config file contains the runtime
I'm looking at our repository and there is no /bin directory. We are deploying using a github action.
in one of our make files we have
Copy code
mailer-deploy:
	python3 ./scripts/transform_mailer.py -e $(env)
	c7n-mailer -c ./policies/$(env)_transformed_mailer.yaml -t templates --update-lambda
you mentioned that you don't re-build the lambda package on update?
I've also created a lambda layer and attached it to the lambda with the chardet module in it, but still get the missing module error.
k
Copy code
❯ uv tree --invert --package chardet
Resolved 288 packages in 7ms
what version of custodian is this?
there isn't any chardet in latest releases even among transitive deps
d
I'm not sure how to tell. My assumption is that we are pulling the latest when we deploy. I'll dig through the actions to see if I can find where we clone the repo.
I have these in a requirements.txt file in the base of the repo.
Copy code
c7n>=0.9.18
c7n-mailer
c7n-org
c7n_gcp
My assumption would be that this would pull in the latest version.
I updated the github actions, adding "custodian version" and am getting 0.9.47
I wonder if this is it. The docker image being used to deploy is running Python 3.10.12
looks like the most recent version of Ubuntu image also runs 3.10 so that's not likely it either.
I changed this "c7n>=0.9.18" to "c7n==0.9.44" in the requirements file where custodian is installed and the error is gone.
Thanks for taking time to look at this with me.
@kapilt ^^