How to configure AWS IAM user credentials in node js

0

So I need help with configuring user credentials in node js. I have used fromEnv() method but it still doesn't work. I am using AWS in netlify functions and it doesn't work when i am deploying it. I will share the code

  const awsClient = new KMSClient({
    credentials: fromEnv(),
    region:'us-east-1'
  });

I have provided the access key id and the secret access key in env

Armaan
asked 3 months ago260 views
1 Answer
2

const AWS = require('aws-sdk');

exports.handler = async (event) => { // Configure AWS SDK const kms = new AWS.KMS({ accessKeyId: process.env.AWS_ACCESS_KEY_ID, secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, region: 'us-east-1' // Set your region });

Please create the configuration.env as file and mention the variable on that file like AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Hope this work for you

profile picture
Jagan
answered 3 months ago
  • That code contains aws sdk for JS v2. I am using v3 sdk. specifically this is the package that i am using @aws-sdk/client-kms. Could you please share how to do this in aws sdk v3

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions