AWS Lambda for Secrets Manager Password Rotation giving Errors for RDS(postgres) - aws-lambda

I have downloaded the python function from https://github.com/aws-samples/aws-secrets-manager-rotation-lambdas/blob/master/SecretsManagerRDSPostgreSQLRotationSingleUser/lambda_function.py. Also, I am using Terraform to deploy ( Python Runtime is 3.9 as suggested). However, After deployment I am getting the following errors in CloudWatch Logs
[ERROR] Runtime.ImportModuleError: Unable to import module 'function': No module named 'pg' Traceback (most recent call last):
I also tried to create a Lambda layer but it did not help.
Appreciate any help !!

That Lambda function is apparently dependent on the PyGreSQL library. I don't see anything in the documentation for that function about that, but that's obviously what it is using. I'm surprised those sample functions don't include a requirments.txt file for their dependencies. There are some open issues in that GitHub repository related to this.
You would have to package that function's code along with the PyGreSQL library and any other dependencies into a .zip file, and modify your Terraform code to deploy the .zip file to Lambda.

Related

Unable to import module 'lambda_function': No module named 'orjson.orjson'",

I'm trying to run a Python Lambda function (which ran successfully in 3.6, and I'm now trying to upgrade to a supported version). I'm getting this result:
Response
{
"errorMessage": "Unable to import module 'lambda_function': No module named 'orjson.orjson'",
"errorType": "Runtime.ImportModuleError",
"stackTrace": []
}
The orjson library is presumably a dependency of one of my dependencies, as I'm not importing it directly. I have tried to include all necessary dependencies as a layer, and I have experimented with a variety of ways to structure the zip file with the dependencies installed, but this issue persists.
Is there anything I might be overlooking when creating the zip file for the layer?
I have been struggling with the same issue, and found out today that it is because orjson is built on my Mac while AWS Lambda uses Amazon Linux, making the orjson's cpython artifact incompatible when deployed.
Try using --use-container option when running sam build. This builds the artifact on an Amazon Linux container, and has resolved the issue for me.
Hope this helps.

error: no such module 'Solana' in build archive section ( GitHub CICD )

I am using Solana Swift Package Dependency in my project and created the custom classes to use the features, imported the Solana module in those classes. But while running the CICD work flow ( GitHub actions ) in the build archive option getting the error error: no such module 'Solana' in the custom classes. I have also attached the screenshot regarding that. (It's working in manual archive from Xcode.)
I have also added clean and build command in the CICD workflow so can fetch this Package Dependency. I am fixing this error since many days but not getting success so please I would like your help.

How to package dependencies using #aws-cdk/pipelines module construct? Getting error TS2307

I've been experimenting with using the new AWS CDK pipelines construct (https://docs.aws.amazon.com/cdk/api/latest/docs/pipelines-readme.html), and have successfully setup a couple of projects, including following the blog post announcement here: https://aws.amazon.com/blogs/developer/cdk-pipelines-continuous-delivery-for-aws-cdk-applications/.
However, as soon as I try to add a dependency to my lambdas the build fails with a
lib/lambda/handler.ts(2,24): error TS2307: Cannot find module 'stripe' or its corresponding type declarations.
I have installed a package.json file and the node_modules in the directory with the lambdas, tried zipping the lambdas and node_modules, tried uploading the zip file with the console, and tried getting the 'buildCommand' during the 'synthAction' step to install the dependencies. Nothing works.
The asset appears to get created in the cdk.out directory, and code changes are being uploaded, but node_modules themselves never get packaged along with the lambda functions.
I am using the 'SimpleSynthAction.standardNpmSynth' action, along with an 'npm run build' command in the 'buildCommand' step.
I've looked at Lambda can't find modules from outer folders when deployed with CDK, How to install dependencies of lambda functions upon cdk build with AWS CDK and https://github.com/aws-samples/aws-cdk-examples/issues/110#issuecomment-550506116 without luck.
What am I missing?
Looks like the issue has to do with bundling. I abandoned the 'all-in on CDK approach' and went back to using a SAM/CDK hybrid, but this new blog post suggests bundling is the answer.
https://aws.amazon.com/blogs/devops/building-apps-with-aws-cdk/
Specifically, it references this construct, which likely would have helped in my situation: https://docs.aws.amazon.com/cdk/api/latest/docs/aws-lambda-nodejs-readme.html
Something to try in future.

Error due to "BuildRequires: maven-local" in spec file for Packaging Maven project

Issue : I am following the URL. https://docs.fedoraproject.org/en-US/java-packaging-howto/packaging_maven_project/ to create a spec file for the rpm package.
In the website "BuildRequires: maven-local" is mentioned in the spec file.
but when I tried to search 'maven-local' using yum search maven-local command, I could not find anything and as I was not able to install the component, I'm getting an error when I am trying to do rpmbuild.
Note: I even installed maven separately in my system but it did not help me to fix the issue.

Zipping GO packages for AWS Lambda

I'm the author of a foo.go package that my AWS Lambda function handler relies on. The package is not present on GitHub. How should the go files be zipped for AWS Lambda?
Consider these things when uploading your GO package to AWS Lambda via AWS Console:
The zip should contain not the .go files, but the compiled package. That means that any local packages you rely on can be anywhere you want.
When using AWS Console to upload the zipped package to AWS Lambda set the handler name to the binary package name. Do not follow the file-name.handler handler naming rule. If the package file name is foo, the zipped file name is foo.zip and the actual handler function name is bar, do not set it to foo.bar, set it to foo.
The zip file has to be compatible with linux. If you're working on a Windows machine, use the build-lambda-zip tool. More about the tool at: https://docs.aws.amazon.com/lambda/latest/dg/lambda-go-how-to-create-deployment-package.html

Resources