Skip to content

Commit 95b2429

Browse files
author
awstools
committed
feat(client-secrets-manager): AWS Secrets Manager has released the BatchGetSecretValue API, which allows customers to fetch up to 20 Secrets with a single request using a list of secret names or filters.
1 parent 09743d7 commit 95b2429

File tree

12 files changed

+934
-139
lines changed

12 files changed

+934
-139
lines changed

clients/client-secrets-manager/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ see LICENSE for more information.
229229

230230
## Client Commands (Operations List)
231231

232+
<details>
233+
<summary>
234+
BatchGetSecretValue
235+
</summary>
236+
237+
[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/secrets-manager/command/BatchGetSecretValueCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-secrets-manager/Interface/BatchGetSecretValueCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-secrets-manager/Interface/BatchGetSecretValueCommandOutput/)
238+
239+
</details>
232240
<details>
233241
<summary>
234242
CancelRotateSecret

clients/client-secrets-manager/src/SecretsManager.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
import { createAggregatedClient } from "@smithy/smithy-client";
33
import { HttpHandlerOptions as __HttpHandlerOptions } from "@smithy/types";
44

5+
import {
6+
BatchGetSecretValueCommand,
7+
BatchGetSecretValueCommandInput,
8+
BatchGetSecretValueCommandOutput,
9+
} from "./commands/BatchGetSecretValueCommand";
510
import {
611
CancelRotateSecretCommand,
712
CancelRotateSecretCommandInput,
@@ -107,6 +112,7 @@ import {
107112
import { SecretsManagerClient, SecretsManagerClientConfig } from "./SecretsManagerClient";
108113

109114
const commands = {
115+
BatchGetSecretValueCommand,
110116
CancelRotateSecretCommand,
111117
CreateSecretCommand,
112118
DeleteResourcePolicyCommand,
@@ -132,6 +138,23 @@ const commands = {
132138
};
133139

134140
export interface SecretsManager {
141+
/**
142+
* @see {@link BatchGetSecretValueCommand}
143+
*/
144+
batchGetSecretValue(
145+
args: BatchGetSecretValueCommandInput,
146+
options?: __HttpHandlerOptions
147+
): Promise<BatchGetSecretValueCommandOutput>;
148+
batchGetSecretValue(
149+
args: BatchGetSecretValueCommandInput,
150+
cb: (err: any, data?: BatchGetSecretValueCommandOutput) => void
151+
): void;
152+
batchGetSecretValue(
153+
args: BatchGetSecretValueCommandInput,
154+
options: __HttpHandlerOptions,
155+
cb: (err: any, data?: BatchGetSecretValueCommandOutput) => void
156+
): void;
157+
135158
/**
136159
* @see {@link CancelRotateSecretCommand}
137160
*/

clients/client-secrets-manager/src/SecretsManagerClient.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ import {
5050
UserAgent as __UserAgent,
5151
} from "@smithy/types";
5252

53+
import {
54+
BatchGetSecretValueCommandInput,
55+
BatchGetSecretValueCommandOutput,
56+
} from "./commands/BatchGetSecretValueCommand";
5357
import { CancelRotateSecretCommandInput, CancelRotateSecretCommandOutput } from "./commands/CancelRotateSecretCommand";
5458
import { CreateSecretCommandInput, CreateSecretCommandOutput } from "./commands/CreateSecretCommand";
5559
import {
@@ -108,6 +112,7 @@ export { __Client };
108112
* @public
109113
*/
110114
export type ServiceInputTypes =
115+
| BatchGetSecretValueCommandInput
111116
| CancelRotateSecretCommandInput
112117
| CreateSecretCommandInput
113118
| DeleteResourcePolicyCommandInput
@@ -135,6 +140,7 @@ export type ServiceInputTypes =
135140
* @public
136141
*/
137142
export type ServiceOutputTypes =
143+
| BatchGetSecretValueCommandOutput
138144
| CancelRotateSecretCommandOutput
139145
| CreateSecretCommandOutput
140146
| DeleteResourcePolicyCommandOutput
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
// smithy-typescript generated code
2+
import { EndpointParameterInstructions, getEndpointPlugin } from "@smithy/middleware-endpoint";
3+
import { getSerdePlugin } from "@smithy/middleware-serde";
4+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http";
5+
import { Command as $Command } from "@smithy/smithy-client";
6+
import {
7+
FinalizeHandlerArguments,
8+
Handler,
9+
HandlerExecutionContext,
10+
HttpHandlerOptions as __HttpHandlerOptions,
11+
MetadataBearer as __MetadataBearer,
12+
MiddlewareStack,
13+
SerdeContext as __SerdeContext,
14+
SMITHY_CONTEXT_KEY,
15+
} from "@smithy/types";
16+
17+
import {
18+
BatchGetSecretValueRequest,
19+
BatchGetSecretValueResponse,
20+
BatchGetSecretValueResponseFilterSensitiveLog,
21+
} from "../models/models_0";
22+
import { de_BatchGetSecretValueCommand, se_BatchGetSecretValueCommand } from "../protocols/Aws_json1_1";
23+
import { SecretsManagerClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../SecretsManagerClient";
24+
25+
/**
26+
* @public
27+
*/
28+
export { __MetadataBearer, $Command };
29+
/**
30+
* @public
31+
*
32+
* The input for {@link BatchGetSecretValueCommand}.
33+
*/
34+
export interface BatchGetSecretValueCommandInput extends BatchGetSecretValueRequest {}
35+
/**
36+
* @public
37+
*
38+
* The output of {@link BatchGetSecretValueCommand}.
39+
*/
40+
export interface BatchGetSecretValueCommandOutput extends BatchGetSecretValueResponse, __MetadataBearer {}
41+
42+
/**
43+
* @public
44+
* <p>Retrieves the contents of the encrypted fields <code>SecretString</code> or <code>SecretBinary</code> for up to 20 secrets. To retrieve a single secret, call <a>GetSecretValue</a>. </p>
45+
* <p>To choose which secrets to retrieve, you can specify a list of secrets by name or ARN, or you can use filters. If Secrets Manager encounters errors such as <code>AccessDeniedException</code> while attempting to retrieve any of the secrets, you can see the errors in <code>Errors</code> in the response.</p>
46+
* <p>Secrets Manager generates CloudTrail <code>GetSecretValue</code> log entries for each secret you request when you call this action. Do not include sensitive information in request parameters because it might be logged. For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieve-ct-entries.html">Logging Secrets Manager events with CloudTrail</a>.</p>
47+
* <p>
48+
* <b>Required permissions: </b>
49+
* <code>secretsmanager:BatchGetSecretValue</code>, and you must have <code>secretsmanager:GetSecretValue</code> for each secret. If you use filters, you must also have <code>secretsmanager:ListSecrets</code>. If the secrets are encrypted using customer-managed keys instead of the Amazon Web Services managed key
50+
* <code>aws/secretsmanager</code>, then you also need <code>kms:Decrypt</code> permissions for the keys.
51+
* For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/reference_iam-permissions.html#reference_iam-permissions_actions">
52+
* IAM policy actions for Secrets Manager</a> and <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access.html">Authentication
53+
* and access control in Secrets Manager</a>. </p>
54+
* @example
55+
* Use a bare-bones client and the command you need to make an API call.
56+
* ```javascript
57+
* import { SecretsManagerClient, BatchGetSecretValueCommand } from "@aws-sdk/client-secrets-manager"; // ES Modules import
58+
* // const { SecretsManagerClient, BatchGetSecretValueCommand } = require("@aws-sdk/client-secrets-manager"); // CommonJS import
59+
* const client = new SecretsManagerClient(config);
60+
* const input = { // BatchGetSecretValueRequest
61+
* SecretIdList: [ // SecretIdListType
62+
* "STRING_VALUE",
63+
* ],
64+
* Filters: [ // FiltersListType
65+
* { // Filter
66+
* Key: "description" || "name" || "tag-key" || "tag-value" || "primary-region" || "owning-service" || "all",
67+
* Values: [ // FilterValuesStringList
68+
* "STRING_VALUE",
69+
* ],
70+
* },
71+
* ],
72+
* MaxResults: Number("int"),
73+
* NextToken: "STRING_VALUE",
74+
* };
75+
* const command = new BatchGetSecretValueCommand(input);
76+
* const response = await client.send(command);
77+
* // { // BatchGetSecretValueResponse
78+
* // SecretValues: [ // SecretValuesType
79+
* // { // SecretValueEntry
80+
* // ARN: "STRING_VALUE",
81+
* // Name: "STRING_VALUE",
82+
* // VersionId: "STRING_VALUE",
83+
* // SecretBinary: "BLOB_VALUE",
84+
* // SecretString: "STRING_VALUE",
85+
* // VersionStages: [ // SecretVersionStagesType
86+
* // "STRING_VALUE",
87+
* // ],
88+
* // CreatedDate: new Date("TIMESTAMP"),
89+
* // },
90+
* // ],
91+
* // NextToken: "STRING_VALUE",
92+
* // Errors: [ // APIErrorListType
93+
* // { // APIErrorType
94+
* // SecretId: "STRING_VALUE",
95+
* // ErrorCode: "STRING_VALUE",
96+
* // Message: "STRING_VALUE",
97+
* // },
98+
* // ],
99+
* // };
100+
*
101+
* ```
102+
*
103+
* @param BatchGetSecretValueCommandInput - {@link BatchGetSecretValueCommandInput}
104+
* @returns {@link BatchGetSecretValueCommandOutput}
105+
* @see {@link BatchGetSecretValueCommandInput} for command's `input` shape.
106+
* @see {@link BatchGetSecretValueCommandOutput} for command's `response` shape.
107+
* @see {@link SecretsManagerClientResolvedConfig | config} for SecretsManagerClient's `config` shape.
108+
*
109+
* @throws {@link DecryptionFailure} (client fault)
110+
* <p>Secrets Manager can't decrypt the protected secret text using the provided KMS key. </p>
111+
*
112+
* @throws {@link InternalServiceError} (server fault)
113+
* <p>An error occurred on the server side.</p>
114+
*
115+
* @throws {@link InvalidNextTokenException} (client fault)
116+
* <p>The <code>NextToken</code> value is invalid.</p>
117+
*
118+
* @throws {@link InvalidParameterException} (client fault)
119+
* <p>The parameter name or value is invalid.</p>
120+
*
121+
* @throws {@link InvalidRequestException} (client fault)
122+
* <p>A parameter value is not valid for the current state of the
123+
* resource.</p>
124+
* <p>Possible causes:</p>
125+
* <ul>
126+
* <li>
127+
* <p>The secret is scheduled for deletion.</p>
128+
* </li>
129+
* <li>
130+
* <p>You tried to enable rotation on a secret that doesn't already have a Lambda function
131+
* ARN configured and you didn't include such an ARN as a parameter in this call. </p>
132+
* </li>
133+
* <li>
134+
* <p>The secret is managed by another service, and you must use that service to update it.
135+
* For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/service-linked-secrets.html">Secrets managed by other Amazon Web Services services</a>.</p>
136+
* </li>
137+
* </ul>
138+
*
139+
* @throws {@link ResourceNotFoundException} (client fault)
140+
* <p>Secrets Manager can't find the resource that you asked for.</p>
141+
*
142+
* @throws {@link SecretsManagerServiceException}
143+
* <p>Base exception class for all service exceptions from SecretsManager service.</p>
144+
*
145+
*/
146+
export class BatchGetSecretValueCommand extends $Command<
147+
BatchGetSecretValueCommandInput,
148+
BatchGetSecretValueCommandOutput,
149+
SecretsManagerClientResolvedConfig
150+
> {
151+
public static getEndpointParameterInstructions(): EndpointParameterInstructions {
152+
return {
153+
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
154+
Endpoint: { type: "builtInParams", name: "endpoint" },
155+
Region: { type: "builtInParams", name: "region" },
156+
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
157+
};
158+
}
159+
160+
/**
161+
* @public
162+
*/
163+
constructor(readonly input: BatchGetSecretValueCommandInput) {
164+
super();
165+
}
166+
167+
/**
168+
* @internal
169+
*/
170+
resolveMiddleware(
171+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
172+
configuration: SecretsManagerClientResolvedConfig,
173+
options?: __HttpHandlerOptions
174+
): Handler<BatchGetSecretValueCommandInput, BatchGetSecretValueCommandOutput> {
175+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
176+
this.middlewareStack.use(
177+
getEndpointPlugin(configuration, BatchGetSecretValueCommand.getEndpointParameterInstructions())
178+
);
179+
180+
const stack = clientStack.concat(this.middlewareStack);
181+
182+
const { logger } = configuration;
183+
const clientName = "SecretsManagerClient";
184+
const commandName = "BatchGetSecretValueCommand";
185+
const handlerExecutionContext: HandlerExecutionContext = {
186+
logger,
187+
clientName,
188+
commandName,
189+
inputFilterSensitiveLog: (_: any) => _,
190+
outputFilterSensitiveLog: BatchGetSecretValueResponseFilterSensitiveLog,
191+
[SMITHY_CONTEXT_KEY]: {
192+
service: "secretsmanager",
193+
operation: "BatchGetSecretValue",
194+
},
195+
};
196+
const { requestHandler } = configuration;
197+
return stack.resolve(
198+
(request: FinalizeHandlerArguments<any>) =>
199+
requestHandler.handle(request.request as __HttpRequest, options || {}),
200+
handlerExecutionContext
201+
);
202+
}
203+
204+
/**
205+
* @internal
206+
*/
207+
private serialize(input: BatchGetSecretValueCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
208+
return se_BatchGetSecretValueCommand(input, context);
209+
}
210+
211+
/**
212+
* @internal
213+
*/
214+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<BatchGetSecretValueCommandOutput> {
215+
return de_BatchGetSecretValueCommand(output, context);
216+
}
217+
}

clients/client-secrets-manager/src/commands/GetSecretValueCommand.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface GetSecretValueCommandOutput extends GetSecretValueResponse, __M
4444
* <p>Retrieves the contents of the encrypted fields <code>SecretString</code> or
4545
* <code>SecretBinary</code> from the specified version of a secret, whichever contains
4646
* content.</p>
47+
* <p>To retrieve the values for a group of secrets, call <a>BatchGetSecretValue</a>.</p>
4748
* <p>We recommend that you cache your secret values by using client-side caching.
4849
* Caching secrets improves speed and reduces your costs. For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets.html">Cache secrets for
4950
* your applications</a>.</p>

clients/client-secrets-manager/src/commands/ListSecretsCommand.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ export interface ListSecretsCommandOutput extends ListSecretsResponse, __Metadat
4242
* <p>ListSecrets is eventually consistent, however it might not reflect changes from the last five minutes.
4343
* To get the latest information for a specific secret, use <a>DescribeSecret</a>.</p>
4444
* <p>To list the versions of a secret, use <a>ListSecretVersionIds</a>.</p>
45-
* <p>To get the secret value from <code>SecretString</code> or <code>SecretBinary</code>,
46-
* call <a>GetSecretValue</a>.</p>
45+
* <p>To retrieve the values for the secrets, call <a>BatchGetSecretValue</a> or <a>GetSecretValue</a>.</p>
4746
* <p>For information about finding secrets in the console, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_search-secret.html">Find secrets in Secrets Manager</a>.</p>
4847
* <p>Secrets Manager generates a CloudTrail log entry when you call this action. Do not include sensitive information in request parameters because it might be logged. For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieve-ct-entries.html">Logging Secrets Manager events with CloudTrail</a>.</p>
4948
* <p>

clients/client-secrets-manager/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// smithy-typescript generated code
2+
export * from "./BatchGetSecretValueCommand";
23
export * from "./CancelRotateSecretCommand";
34
export * from "./CreateSecretCommand";
45
export * from "./DeleteResourcePolicyCommand";

0 commit comments

Comments
 (0)