serverless-dotenv-plugin | Preload Environment Variables with Dotenv into Serverless | Serverless library
kandi X-RAY | serverless-dotenv-plugin Summary
kandi X-RAY | serverless-dotenv-plugin Summary
Preload Environment Variables with Dotenv into Serverless
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of serverless-dotenv-plugin
serverless-dotenv-plugin Key Features
serverless-dotenv-plugin Examples and Code Snippets
npm i -D serverless-dotenv-plugin
service: myService
plugins:
- serverless-dotenv-plugin
...
...
provider:
name: aws
runtime: nodejs6.10
stage: ${env:STAGE}
region: ${env:AWS_REGI
Community Discussions
Trending Discussions on serverless-dotenv-plugin
QUESTION
i have deployed a aws lambda app that uses dynamodb but when i run the lambda fuction i am getting following errors
...ANSWER
Answered 2021-Dec-20 at 06:48The role assumed by your lambda function does not have required permissions to access the Dynamo Db table. To solve this, you need to attach the appropriate policy to your lambda function role.
This page contains a policy that grants Read/Write access to your lambda function.
QUESTION
Currently I am facing an issue while trying to bind my serverless handlers to my vpc. My command to deploy is the following:
...ANSWER
Answered 2021-Dec-15 at 16:51After some research we were able to connect our lambda to our vpc using serverless. The solution was: Stop using serverless-vpc-plugin
.
It turns out that serverless-vpc-plugin
, automatically creates a AWS VPC, which is not what we were looking for. We already had our VPC created using terraform.
From serverless-vpc-plugin documentation
Automatically creates an AWS Virtual Private Cloud (VPC) using all available Availability Zones (AZ) in a region.
In other words, serverless-vpc-plugin
doesn't make sense when the target vpc already exists
QUESTION
I am failing to generate a bundle with serverless-bundle plugin.
tsconfig.json
...ANSWER
Answered 2021-Nov-13 at 09:27Looks like adding externals: all
to custom.bundle
in serverless.yml
fixed the issue.
QUESTION
I have the following steps configured in our bitbucket pipeline:
...ANSWER
Answered 2021-Apr-13 at 16:43The answer was pretty mundane. Serverless 2.32+ introduced some change that broke the pipeline. Reverting to version 2.31.0 resolved the issue.
QUESTION
Trigger warning : Beginner question.
I built an api using Express and Mongoose with a MongoDB Atlas DB.
Most of the time, it works normally, but often I get timeout errors. This seems to happen very randomly and concerns all routes, etc... Precisely, I get :
...ANSWER
Answered 2020-Mar-09 at 04:50Under your provider add timeout, maximum value of timeout in lambda is 900 seconds, place it according to your execution time like 30 seconds and see what happens
QUESTION
I'm new to Docker, and I've wanted try Dockerizing my node app.
I've tried following the directions on nodejs.org, but I've been getting errors on npm install
.
Here is my Dockerfile:
...ANSWER
Answered 2020-Feb-10 at 12:43I used to get this error due to low or intermittent internet bandwidth.
QUESTION
I have created a simple application that accepts a URL and converts it to a PDF. It stores the resultant PDF in an S3 bucket and returns the URL of the PDF. It uses Chrome (running headless) to convert the URL to a PDF. I used the serverless framework, AWS Lambda, and the chrome-aws-lambda npm package. When I execute this setup locally using serverless it all works great. I can use postman to make a request with a URL and it returns the URL of the resultant PDF. When I deploy this setup to AWS Lambda, it returns a 502 internal server error response. When I look at the AWS logs for my application I see the following:
...ANSWER
Answered 2020-Feb-07 at 01:36serverless-bundle
only includes the JS code that you use in your handler and strips everything else to minimize your bundle. That means the chrome binaries are excluded.
To include those binaries, add the following to your serverless.yml
:
QUESTION
I have a CodePipeline with GitHub as a source, set up. I am trying to, without a success, pass a single secret parameter( in this case a Stripe secret key, currently defined in an .env file -> explaination down below ) to a specific Lambda during a Deployment stage in CodePipeline's execution.
Deployment stage in my case is basically a CodeBuild project that runs the deployment.sh script:
#! /bin/bash
npm install -g serverless@1.60.4
serverless deploy --stage $env -v -r eu-central-1
Explanation:
I've tried doing this with serverless-dotenv-plugin, which serves the purpose when the deployment is done locally, but when it's done trough CodePipeline, it returns an error on lambda's execution, and with a reason:
Since CodePipeline's Source is set to GitHub (.env file is not commited), whenever a change is commited to a git repository, CodePipeline's execution is triggered. By the time it reaches deployment stage, all node modules are installed (serverless-dotenv-plugin along with them) and when serverless deploy --stage $env -v -r eu-central-1
command executes serverless-dotenv-plugin will search for .env file in which my secret is stored, won't find it since there's no .env file because we are out of "local" scope, and when lambda requiring this secret triggers it will throw an error looking like this:
So my question is, is it possible to do it with dotenv/serverless-dotenv-plugin, or should that approach be discarded? Should I maybe use SSM Parameter Store or Secrets Manager? If yes, could someone explain how? :)
...ANSWER
Answered 2020-Jan-16 at 01:47So, upon further investigation of this topic I think I have the solution. SSM Parameter Store vs Secrets Manager is an entirely different topic, but for my purpose, SSM Paremeter Store is a choice that I chose to go along with for this problem. And basically it can be done in 2 ways.
1. Use AWS Parameter Store
Simply by adding a secret in your AWS Parameter Store Console, then referencing the value in your serverless.yml
as a Lambda environement variable. Serverless Framework is able to fetch the value from your AWS Parameter Store account on deploy.
provider:
environement:
stripeSecretKey: ${ssm:stripeSecretKey}
Finally, you can reference it in your code just as before:
const stripe = Stripe(process.env.stripeSecretKey);
PROS: This can be used along with a local .env file for both local and remote usage while keeping your Lambda code the same, ie. process.env.stripeSecretKey
CONS: Since the secrets are decrypted and then set as Lambda environment variables on deploy, if you go to your Lambda console, you'll be able to see the secret values in plain text. (Which kinda indicates some security issues)
That brings me to the second way of doing this, which I find more secure and which I ultimately choose:
2. Store in AWS Parameter Store, and decrypt at runtime To avoid exposing the secrets in plain text in your AWS Lambda Console, you can decrypt them at runtime instead. Here is how:
Add the secrets in your AWS Parameter Store Console just as in the above step.
Change your Lambda code to call the Parameter Store directly and decrypt the value at runtime:
import stripePackage from 'stripe'; const aws = require('aws-sdk'); const ssm = new aws.SSM();
const stripeSecretKey = ssm.getParameter( {Name: 'stripeSecretKey', WithDecryption: true} ).promise(); const stripe = stripePackage(stripeSecretKey.Parameter.Value);
(Small tip: If your Lambda is defined as async function, make sure to use await keyword before ssm.getParameter(...).promise(); )
PROS: Your secrets are not exposed in plain text at any point.
CONS: Your Lambda code does get a bit more complicated, and there is an added latency since it needs to fetch the value from the store. (But considering it's only one parameter and it's free, it's a good trade-off I guess)
For the conclusion I just want to mention that all this in order to work will require you to tweak your lambda's policy so it can access Systems Manager and your secret that's stored in Parameter Store, but that's easily inspected trough CloudWatch.
Hopefully this helps someone out, happy coding :)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install serverless-dotenv-plugin
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page