最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Get a secret from AWS Secrets Manager in Nextjs (serverside) - Stack Overflow

programmeradmin3浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论