Serverless Lambda deployment in node8.10 not uploading any code - amazon-web-services

I have a lambda function deployed with Serverless. It was deployed with node6.10 runtime, so I decided to redeploy the service with the node8.10 runtime instead.
However after making this redeploy I faced a strange issue where I could not invoke the function and could no longer deploy updates to the function as the filesize was too large (60mb+). I was able to resolve this by uninstalling and reinstalling serverless-plugin-optimize.
This solved the file size issue (now it's about 2mb) but I still cannot invoke the function. Attempting to invoke it yields the following log in CloudWatch:
Unable to import module 'lambda/index': Error
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
My expectation then was that the file path in my serverless.yml for the function was wrong, or that it was not exporting correctly.
./serverless.yml
functions:
funcOne:
handler: lambda/index.handler
./lambda/index.js
exports.handler = function (event, context) {
// execution code
};
However this does not appear to be the case, I know this because setting debug: true for the serverless-plugin-optimize leaves behind the _optimize folder with my minified code in. However somehow despite it being present locally it seems it is not making the upload to Lambda.
Viewing this in the AWS console I get the following:
2.6mb upload listed in Lambda directory:
Error in Lambda console code editor
60mb file still listed in S3 deployment bucket
I can't explain why I am getting this issue or what about switching to node8.10 would cause it. Outside of the serverless.yml file none of the code has been changed from the working node6.10 version. Has anyone encountered this issue before or knows of anything that might fix it?

I have now successfully resolved this issue. I don't know why this was the case, but the problem seemed to be with deploying to node8.10 using an older version of Serverless (1.27.2). Upgrading to the latest version of Serverless (1.32.0) fixed it immediately.

Related

Exec-wrapper.sh: does not exist

I'm currently using lambda function which is invoked using Aws Lex. It was working normally and I didn't modify any of its configuration and out of nowhere it stopped working and I keep getting this error.
/opt/sls-sdk-node/exec-wrapper.sh: does not exist
Can anyone please explain what is an exec-wrapper.sh and how is it possible for it to suddenly disappear? And how can I solve this problem?
This looks to be an error stemming from the Serverless framework rather than an issue with Lex itself. Did you perhaps upgrade any of the SLS dependencies?
It turned out that after removing the serverless framework, there were some configurations (exec-wrapper.sh) that were not removed and needed to be removed manually from lambda using the aws console

AWS Codepipeline deploy step with no relevant changes fails to execute with "Update to resource type AWS::CodeDeploy::Application is not supported"

I have a CDK based CodePipeline with a 'Deploy' Step for a Lambda function that started to fail recently, but succeeded already multiple times for this branch in the past. The odd thing about it, compared to the deploying fine production branch:
the code changes are minimal and passing ci the unit test and all other steps (2 loc)
the only other change is a changed version number of the deployed application in npm's package.json file
The CDK Stack did not see changes recently.
The failing step is the one where the CI pipeline tries to deploy the lambda based application via cloudformation. When review the error in cloudformation, the Error 'Update to resource type AWS::CodeDeploy::Application is not supported' pops up for the ressource type 'AWS::CodeDeploy::Application which is deployed by a 'CodePipelineAction.S3DeployAction'.
The error seems to be regarding the created deploy stack and not a resource in it.
Update: I got a answer from AWS Support
This is a known issue which you can track on the GitHub CDK issues. I encourage you to add your voice and experience to this issue. The more input we have, the more visibility we have to improve the service. Please see the link below:
https://github.com/aws/aws-cdk/issues/15947
If you are updating this resource's tags, there is a CDK workaround. You can add the Exclude Resources Types within your construct. Below is a sample of how this would look:
const tagOptions = {
excludeResourceTypes: ['AWS::CodeDeploy::Application'],
};
cdk.Tags.of(deployment).add('Name', `buffer-${props.environment}`, tagOptions);
The reason why it broke may be: It seems that this resource type didn't support tags before, and now it does, leading to the issue.

Running into the "cannot find module" with AWS lambda... sometimes

Been working on some lambdas and all of a sudden I started running into this error. The strange thing is that everything was working fine until a certain point in time, at which point all get requests to that endpoint returned an internal server error. I looked in cloud watch to find the "Runtime.ImportModuleError" error type. "Cannont find module 'yadda yadda' \n require stack....."
I have tried several things. I tried using 7zip instead of compress-archive (just made it a different module that couldn't be found). I tried removing aws-sdk from the package.json and this is the part that really makes me feel insane. After removing that, rezipping, and reuploading this made it work. I thought it was solved so I resumed working on the lambda, but when I zipped and uploaded again it was back to the same error. At this point I took a break, looked some stuff up, and came back. The same lambda that was previously not working now worked perfectly fine with no changes from me. Tried zipping and uploading again, back to module cannot be found error. I'm at my wits end here, what the heck could be happening?
From the error you get from the cloudwatch its clear that some of the module that your lambda function needs is not present in the node_module directory and removing it from the package.json doesn't affect the lambda function because the lambda doesn't use the package.json to install the dependencies, this has been done manually.
For dependencies Lambda completely relies on the modules that you attached to your zipped( or s3:// bucket) file.
There are few things you can check to analyze
Re-align your package.json file with required dependencies and run the npm install
It could be possible that your lambda function using lambda layers for dependencies and that layers weren't included in the configuration.

AWS Serverless Image Handler - Lambda Error

My Serverless image handler was working fine till now and now i'm getting the following error.
start_thumbor error: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (nss)
This looks like a problem with the version of pycurl.
Please help me resolve it.
Tried changing the pythong version to 3.6 in ServerlessImageHandler lambda function configuration.
I found a discussion about that issue on https://forums.aws.amazon.com/thread.jspa?messageID=909444, which sent me to https://github.com/awslabs/serverless-image-handler/issues/127#issuecomment-514757029.
Github user timkelty has the solution:
go to my CloudFormation Stack
click Update
"replace template"
paste in https://cf-templates-nestrom.s3-eu-west-1.amazonaws.com/serverless-image-handler/1.0/serverless-image-handler.template
so far has worked for me in us-east-1 and us-west-1
AWS has released a new version of Serverless Image Handler this is why everybody suffers now because Thumbor functionalities fail in the new version.
In the new version, SharpJS is used instead of Thumbor API calls.
You can check the new version and download it from here.
Even though you are able to construct urls in old style, images in subfolders are not possible to access anymore without encoding the url.
Old way:
abcdef.cloudfront.net/team/team1.png
New way:
abcdef.cloudfront.net/{base64encodedPath}
Note 1: If your images are in the root directory of the bucket, you are still able to access them old style like this:
abcdef.cloudfront.net/team1.png
Note 2: If you update your existing CloudFormation stack, you will have your old cloudfront domain (which is a good part).
You can also follow the current fixes from here.

Unable to upload java jar in lambda function

Unable to upload jar file in aws lambda function it says The deployment package of your Lambda function "helloAlexa" is too large to enable inline code editing. However, you can still invoke your function.
There's nothing wrong with the deployment itself.
The only thing you are unable to do is edit the code online via AWS's console. You will have to use your own IDE/Text editor to do so.