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.

No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions