-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client-secrets-manager): AWS Secrets Manager has released the Ba…
…tchGetSecretValue API, which allows customers to fetch up to 20 Secrets with a single request using a list of secret names or filters.
- Loading branch information
awstools
committed
Nov 27, 2023
1 parent
09743d7
commit 95b2429
Showing
12 changed files
with
934 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
217 changes: 217 additions & 0 deletions
217
clients/client-secrets-manager/src/commands/BatchGetSecretValueCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,217 @@ | ||
// smithy-typescript generated code | ||
import { EndpointParameterInstructions, getEndpointPlugin } from "@smithy/middleware-endpoint"; | ||
import { getSerdePlugin } from "@smithy/middleware-serde"; | ||
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@smithy/protocol-http"; | ||
import { Command as $Command } from "@smithy/smithy-client"; | ||
import { | ||
FinalizeHandlerArguments, | ||
Handler, | ||
HandlerExecutionContext, | ||
HttpHandlerOptions as __HttpHandlerOptions, | ||
MetadataBearer as __MetadataBearer, | ||
MiddlewareStack, | ||
SerdeContext as __SerdeContext, | ||
SMITHY_CONTEXT_KEY, | ||
} from "@smithy/types"; | ||
|
||
import { | ||
BatchGetSecretValueRequest, | ||
BatchGetSecretValueResponse, | ||
BatchGetSecretValueResponseFilterSensitiveLog, | ||
} from "../models/models_0"; | ||
import { de_BatchGetSecretValueCommand, se_BatchGetSecretValueCommand } from "../protocols/Aws_json1_1"; | ||
import { SecretsManagerClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../SecretsManagerClient"; | ||
|
||
/** | ||
* @public | ||
*/ | ||
export { __MetadataBearer, $Command }; | ||
/** | ||
* @public | ||
* | ||
* The input for {@link BatchGetSecretValueCommand}. | ||
*/ | ||
export interface BatchGetSecretValueCommandInput extends BatchGetSecretValueRequest {} | ||
/** | ||
* @public | ||
* | ||
* The output of {@link BatchGetSecretValueCommand}. | ||
*/ | ||
export interface BatchGetSecretValueCommandOutput extends BatchGetSecretValueResponse, __MetadataBearer {} | ||
|
||
/** | ||
* @public | ||
* <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> | ||
* <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> | ||
* <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> | ||
* <p> | ||
* <b>Required permissions: </b> | ||
* <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 | ||
* <code>aws/secretsmanager</code>, then you also need <code>kms:Decrypt</code> permissions for the keys. | ||
* For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/reference_iam-permissions.html#reference_iam-permissions_actions"> | ||
* IAM policy actions for Secrets Manager</a> and <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access.html">Authentication | ||
* and access control in Secrets Manager</a>. </p> | ||
* @example | ||
* Use a bare-bones client and the command you need to make an API call. | ||
* ```javascript | ||
* import { SecretsManagerClient, BatchGetSecretValueCommand } from "@aws-sdk/client-secrets-manager"; // ES Modules import | ||
* // const { SecretsManagerClient, BatchGetSecretValueCommand } = require("@aws-sdk/client-secrets-manager"); // CommonJS import | ||
* const client = new SecretsManagerClient(config); | ||
* const input = { // BatchGetSecretValueRequest | ||
* SecretIdList: [ // SecretIdListType | ||
* "STRING_VALUE", | ||
* ], | ||
* Filters: [ // FiltersListType | ||
* { // Filter | ||
* Key: "description" || "name" || "tag-key" || "tag-value" || "primary-region" || "owning-service" || "all", | ||
* Values: [ // FilterValuesStringList | ||
* "STRING_VALUE", | ||
* ], | ||
* }, | ||
* ], | ||
* MaxResults: Number("int"), | ||
* NextToken: "STRING_VALUE", | ||
* }; | ||
* const command = new BatchGetSecretValueCommand(input); | ||
* const response = await client.send(command); | ||
* // { // BatchGetSecretValueResponse | ||
* // SecretValues: [ // SecretValuesType | ||
* // { // SecretValueEntry | ||
* // ARN: "STRING_VALUE", | ||
* // Name: "STRING_VALUE", | ||
* // VersionId: "STRING_VALUE", | ||
* // SecretBinary: "BLOB_VALUE", | ||
* // SecretString: "STRING_VALUE", | ||
* // VersionStages: [ // SecretVersionStagesType | ||
* // "STRING_VALUE", | ||
* // ], | ||
* // CreatedDate: new Date("TIMESTAMP"), | ||
* // }, | ||
* // ], | ||
* // NextToken: "STRING_VALUE", | ||
* // Errors: [ // APIErrorListType | ||
* // { // APIErrorType | ||
* // SecretId: "STRING_VALUE", | ||
* // ErrorCode: "STRING_VALUE", | ||
* // Message: "STRING_VALUE", | ||
* // }, | ||
* // ], | ||
* // }; | ||
* | ||
* ``` | ||
* | ||
* @param BatchGetSecretValueCommandInput - {@link BatchGetSecretValueCommandInput} | ||
* @returns {@link BatchGetSecretValueCommandOutput} | ||
* @see {@link BatchGetSecretValueCommandInput} for command's `input` shape. | ||
* @see {@link BatchGetSecretValueCommandOutput} for command's `response` shape. | ||
* @see {@link SecretsManagerClientResolvedConfig | config} for SecretsManagerClient's `config` shape. | ||
* | ||
* @throws {@link DecryptionFailure} (client fault) | ||
* <p>Secrets Manager can't decrypt the protected secret text using the provided KMS key. </p> | ||
* | ||
* @throws {@link InternalServiceError} (server fault) | ||
* <p>An error occurred on the server side.</p> | ||
* | ||
* @throws {@link InvalidNextTokenException} (client fault) | ||
* <p>The <code>NextToken</code> value is invalid.</p> | ||
* | ||
* @throws {@link InvalidParameterException} (client fault) | ||
* <p>The parameter name or value is invalid.</p> | ||
* | ||
* @throws {@link InvalidRequestException} (client fault) | ||
* <p>A parameter value is not valid for the current state of the | ||
* resource.</p> | ||
* <p>Possible causes:</p> | ||
* <ul> | ||
* <li> | ||
* <p>The secret is scheduled for deletion.</p> | ||
* </li> | ||
* <li> | ||
* <p>You tried to enable rotation on a secret that doesn't already have a Lambda function | ||
* ARN configured and you didn't include such an ARN as a parameter in this call. </p> | ||
* </li> | ||
* <li> | ||
* <p>The secret is managed by another service, and you must use that service to update it. | ||
* 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> | ||
* </li> | ||
* </ul> | ||
* | ||
* @throws {@link ResourceNotFoundException} (client fault) | ||
* <p>Secrets Manager can't find the resource that you asked for.</p> | ||
* | ||
* @throws {@link SecretsManagerServiceException} | ||
* <p>Base exception class for all service exceptions from SecretsManager service.</p> | ||
* | ||
*/ | ||
export class BatchGetSecretValueCommand extends $Command< | ||
BatchGetSecretValueCommandInput, | ||
BatchGetSecretValueCommandOutput, | ||
SecretsManagerClientResolvedConfig | ||
> { | ||
public static getEndpointParameterInstructions(): EndpointParameterInstructions { | ||
return { | ||
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" }, | ||
Endpoint: { type: "builtInParams", name: "endpoint" }, | ||
Region: { type: "builtInParams", name: "region" }, | ||
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }, | ||
}; | ||
} | ||
|
||
/** | ||
* @public | ||
*/ | ||
constructor(readonly input: BatchGetSecretValueCommandInput) { | ||
super(); | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
resolveMiddleware( | ||
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>, | ||
configuration: SecretsManagerClientResolvedConfig, | ||
options?: __HttpHandlerOptions | ||
): Handler<BatchGetSecretValueCommandInput, BatchGetSecretValueCommandOutput> { | ||
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); | ||
this.middlewareStack.use( | ||
getEndpointPlugin(configuration, BatchGetSecretValueCommand.getEndpointParameterInstructions()) | ||
); | ||
|
||
const stack = clientStack.concat(this.middlewareStack); | ||
|
||
const { logger } = configuration; | ||
const clientName = "SecretsManagerClient"; | ||
const commandName = "BatchGetSecretValueCommand"; | ||
const handlerExecutionContext: HandlerExecutionContext = { | ||
logger, | ||
clientName, | ||
commandName, | ||
inputFilterSensitiveLog: (_: any) => _, | ||
outputFilterSensitiveLog: BatchGetSecretValueResponseFilterSensitiveLog, | ||
[SMITHY_CONTEXT_KEY]: { | ||
service: "secretsmanager", | ||
operation: "BatchGetSecretValue", | ||
}, | ||
}; | ||
const { requestHandler } = configuration; | ||
return stack.resolve( | ||
(request: FinalizeHandlerArguments<any>) => | ||
requestHandler.handle(request.request as __HttpRequest, options || {}), | ||
handlerExecutionContext | ||
); | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
private serialize(input: BatchGetSecretValueCommandInput, context: __SerdeContext): Promise<__HttpRequest> { | ||
return se_BatchGetSecretValueCommand(input, context); | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<BatchGetSecretValueCommandOutput> { | ||
return de_BatchGetSecretValueCommand(output, context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.