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.

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠