admin管理员组

文章数量:1406060

I'd need to get a secret from AWS Secrets Manager in a Nextjs (Nextjs here is irrelevant, it could be Nodejs). Specifically, I want it to work locally too (as well as on AWS). The problem I guess it is I'd like to avoid the hassle of starting an SSO session locally every time, to get the aws_session_token (that is my understanding). Obviously this code per se won't work, because I don't provide the token.

import { SecretsManagerClient, GetSecretValueCommand } from "@aws-sdk/client-secrets-manager";
    
const client = new SecretsManagerClient({
    region: "region",    
});
let response;
try {
    response = await client.send(
        new GetSecretValueCommand({
            SecretId: "secret_name"
        })
    );
    console.log(response)
} catch (error) {
    throw error;
}

I have a task Role already set up to to have read access to the secret, I think I have to assume that role via STS, but for running an AssumeRole command I still need a session token.

本文标签: javascriptGet a secret from AWS Secrets Manager in Nextjs (serverside)Stack Overflow