If you deployed your app to AWS Lambda with scss, you most got an error saying the node-sass bindings are missing.
Missing binding /opt/nodejs/node_modules/node-sass/vendor/linux-x64-64/binding.node\nNode Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x\n\nFound bindings for the following environments:\n - OS X 64-bit with Node.js 12.x\n\nThis usually happens because your environment has changed since running
npm install
.\nRunnpm rebuild node-sass
to download the binding for your current environment.
AWS Lambda requires linux-x64-64_binding.node. If you're coding on macOs or Windows, you won't have it. So here's the command to include in your deployment script.
AWSTemplateFormatVersion: "2010-09-09" | |
Transform: AWS::Serverless-2016-10-31 | |
Globals: | |
Function: | |
Timeout: 60 | |
Parameters: | |
Stage: | |
Type: String |
This shows how to convert a basic REST ApiGateway template to its equivalent HTTP ApiGatewayV2.
The original code before refactoring to ApiGatewayV2 comes from this article
Replace MY_PROFILE
, MY_REGION
and MY_STACK_NAME
AWSTemplateFormatVersion: '2010-09-09' | |
Description: AWS API Gateway with a Lambda Integration | |
Parameters: | |
lambdaFunctionName: | |
Type: "String" | |
AllowedPattern: "^[a-zA-Z0-9]+[a-zA-Z0-9-]+[a-zA-Z0-9]+$" | |
Description: Lambda function name. (Recommend to keep default) | |
Default: "lambda-api" |
This is mainly for node.js but might apply to other environments. Unsure.
If you are running a AWS Lambda function that calls another AWS service and getting an error about invalid tokens or other access denied errors, do this:
The role assigned to your lambda function will need permission to perform the actions. Check IAM and make sure the role has all the permissions.