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.

Nessuna risposta

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande