Rahul bora
Rahul bora

Reputation: 33

How to use secret environmental variables through aws-sdk/client-secrets-manager in Next.js 14?

I'm trying to use environment variables stored in AWS Secrets Manager in my Next.js application, but I'm having trouble accessing them correctly. I'm using Next.js 14.

// utils/aws.js
import AWS from "aws-sdk";

const client = new AWS.SecretsManager({
    region: "ap-south-1",
});

export async function getSecret() {
    const { SecretString } = await client
        .getSecretValue({
            SecretId: "my-secret",
        })
        .promise();

    return SecretString;
}

However, when I try to run the application, I get an error

UnhandledPromiseRejectionWarning: Missing credentials in config.

Upvotes: 0

Views: 234

Answers (0)

Related Questions