wuno
wuno

Reputation: 9865

Requesting 2 secrets from AWS Secrets Manager in One API Call with JavaScript

Background

I am using AWS Secrets Manager to store a few different passwords and secret values in AWS. The first entry is specifically for AWS RDS information.

To enter arbitrary secret data in Secrets Manager you must select a different entry than RDS.

enter image description here

I did this and then created a few key value pairs to be stored. Now that I have done this I have 2 sets of SecretIds. The SecretIds is what is used to return the correct secret from Secrets Manager. I have 2 different SecretIds and need to return 2 different sets of secrets. I am hoping I can do this without having to make 2 separate API calls.

Example

Originally this was the secretId for returning the RDS username and password.

const secretRds = 'some/thing/something';

I was able to return this data like this,

client.getSecretValue({ SecretId: secretRds }, {...}

Question

Now that I have a second secretId I have 2 sets that look like this,

const secretRds = 'some/thing/something';
const secretConfigs = 'some/thing/sopmethingElse';

Since the original secretId was passed into the SecretId key as the value in the getSecretValue params, how do I pass a second secretId in?

Looking at the documentation here, I can not seem to find anything explaining this.

Something like this is what I am trying to accomplish,

Obviously this wont work because the key is named twice. I need to understand how to pass 2 secretIds in to the same secretId.

const secretRds = 'some/thing/something';
const secretConfigs = 'some/thing/sopmethingElse';

client.getSecretValue({ SecretId: secretRds: SecretId: secretConfigs }, {...}

Upvotes: 2

Views: 2897

Answers (2)

JoeB
JoeB

Reputation: 1623

UPDATE: Secrets Manager now supports BatchGetSecretValue

What are these values you are storing? If they are related, like the DB username, password, and connection string, you can just store them all in the same JSON blob in the secret. You could go back to the console and edit the secret to combine everything.

If they are not all related, you probably want to keep them in separate secrets so that you can manage the permissions to them separately.

Upvotes: 1

spg
spg

Reputation: 9827

Unfortunately, the Secrets Manager API does not support passing multiple SecretId's in a single GetSecretValue call.

There does not seem to be any way to retrieve more than 1 secret value in a single API call. You will have to issue 2 different API calls to GetSecretValue.

Upvotes: 5

Related Questions