DEV Community

Cover image for How to use secrets manager in AWS Lambda( Node JS )

How to use secrets manager in AWS Lambda( Node JS )

Avinash Dalvi on September 24, 2021

I am going to explain how to use the AWS secrets manager in AWS Lambda under Node JS container. This blog can be helpful for general Javascript pro...
Collapse
 
innocentdevii profile image
Dipesh Raichana

Can't we use access manager without importing it from sdk ?

Collapse
 
avinashdalvi_ profile image
Avinash Dalvi

To connect any AWS resource need SDK.

Collapse
 
innocentdevii profile image
Dipesh Raichana

thanks. I am thinking in a way that lambda is a part of aws and we are calling another resource from the lambda, so there may be any a way of doing without importing aws sdk.

Thread Thread
 
avinashdalvi_ profile image
Avinash Dalvi

Any resource you use in Lambda code you need SDK or library which called as programmatic way to talk to each other. But Lambda source and destination way can just listen or publish data to particular service which listed as source and destination.

Collapse
 
ajinkyax profile image
Ajinkya Borade

Really well written, Avinash.

Collapse
 
avinashdalvi_ profile image
Avinash Dalvi

Thanks Ajinkya.

Collapse
 
razorsharpshady profile image
Abhishek kandari

Thank you Avinash for the code snippet and explanation

Collapse
 
avinashdalvi_ profile image
Avinash Dalvi

I hope it will help you. You can reach out to me if any query.

Collapse
 
carlosdiazs profile image
carlosdiazs

Hello Avinash,

I am trying to test your code from Lambda test tab and I'm getting undefined as result on console.log(apiValue);

Maybe you could help me.

Thank you!

Collapse
 
avinashdalvi_ profile image
Avinash Dalvi • Edited

Drop message on twitter handle @avinashdalvi_ will checkout code.

Collapse
 
nivohayon profile image
Niv Ohayon

You probably copy pasted the code snippet.
your config object should be something like this:
const config = {
region: region,
credentials: {
accessKeyId: process.env.ACCESS_KEY_ID,
secretAccessKey: process.env.SECRET_ACCESS_KEY,
},
}

Collapse
 
movingelectrons profile image
Jerome Stonebridge

?Really? We have to use a secret to get access to the secrets manager? Does that not nullify the entire point of using the secrets manager in the first place??...