Aws-sdk UpdateSecret doesn't work to update secrets

0

I have the following code to update a secret in Secrets Manager service. This code is inside a Lambda Function with the following permissions: UpdateSecret, PutSecretValue, UpdateSecretVersionStage and GetSecretValue. When I run the lambda function, I receive no errors, but still my secrets doesn't change. What is the problem? Can I work it around with API request? How?

  const { SecretsManager } = require('aws-sdk');

  // function to update secret
  const secrets = { API_KEY: newValue }
  SecretsClient = new SecretsManager({ region: REGION });
  const allSecrets = await getAllSecrets();
  const updatedSecretsJson = {
    ...allSecrets,
    ...secrets
  };
  const updatedSecrets = JSON.stringify(updatedSecretsJson);
  await SecretsClient.putSecretValue({ SecretId: SECRET_ID, SecretString: updatedSecrets })

Also tried: Also, I've tried giving my lambda function all Secrets Manager permission. The only ways I could update my secrets were by AWS Console and AWS CLI.

沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南