Retrieves the contents of the encrypted fields SecretString or SecretBinary for up to 20 secrets. To retrieve a single secret, call GetSecretValue.
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 AccessDeniedException while attempting to retrieve any of the secrets, you can see the errors in Errors in the response.
Secrets Manager generates CloudTrail GetSecretValue 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 Logging Secrets Manager events with CloudTrail.
Required permissions: secretsmanager:BatchGetSecretValue, and you must have secretsmanager:GetSecretValue for each secret. If you use filters, you must also have secretsmanager:ListSecrets. If the secrets are encrypted using customer-managed keys instead of the Amazon Web Services managed key aws/secretsmanager, then you also need kms:Decrypt permissions for the keys. For more information, see IAM policy actions for Secrets Manager and Authentication and access control in Secrets Manager.
Parameters:
-
secret_id_list
(Optional[SecretIdListType], default:
None
)
–
The ARN or names of the secrets to retrieve. You must include Filters or SecretIdList, but not both.
-
filters
(Optional[FiltersListType], default:
None
)
–
The filters to choose which secrets to retrieve. You must include Filters or SecretIdList, but not both.
-
max_results
(Optional[MaxResultsBatchType], default:
None
)
–
The number of results to include in the response.
If there are more results available, in the response, Secrets Manager includes NextToken. To get the next results, call BatchGetSecretValue again with the value from NextToken. To use this parameter, you must also use the Filters parameter.
-
next_token
(Optional[NextTokenType], default:
None
)
–
A token that indicates where the output should continue from, if a previous call did not show all results. To get the next results, call BatchGetSecretValue again with this value.
Raises:
Examples:
To retrieve the secret values for a group of secrets listed by name
The following example gets the values for three secrets.
>>> client.batch_get_secret_value(secret_id_list=['MySecret1', 'MySecret2', 'MySecret3'])
Source code in docs_src/capo_secrets_manager/_services/secrets_manager.py
| def batch_get_secret_value(
self,
*,
config_overrides: Optional[SecretsManagerClientConfig] = None,
secret_id_list: Optional[
"capo_secrets_manager.types.secret_id_list_type.SecretIdListType"
] = None,
filters: Optional[
"capo_secrets_manager.types.filters_list_type.FiltersListType"
] = None,
max_results: Optional[
"capo_secrets_manager.types.max_results_batch_type.MaxResultsBatchType"
] = None,
next_token: Optional[
"capo_secrets_manager.types.next_token_type.NextTokenType"
] = None,
) -> "capo_secrets_manager.types.batch_get_secret_value_response.BatchGetSecretValueResponse":
"""<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>
Args:
secret_id_list: <p>The ARN or names of the secrets to retrieve. You must include <code>Filters</code> or <code>SecretIdList</code>, but not both.</p>
filters: <p>The filters to choose which secrets to retrieve. You must include <code>Filters</code> or <code>SecretIdList</code>, but not both.</p>
max_results: <p>The number of results to include in the response.</p> <p>If there are more results available, in the response, Secrets Manager includes <code>NextToken</code>. To get the next results, call <code>BatchGetSecretValue</code> again with the value from <code>NextToken</code>. To use this parameter, you must also use the <code>Filters</code> parameter.</p>
next_token: <p>A token that indicates where the output should continue from, if a previous call did not show all results. To get the next results, call <code>BatchGetSecretValue</code> again with this value.</p>
Raises:
capo_secrets_manager.errors.decryption_failure.DecryptionFailure: <p>Secrets Manager can't decrypt the protected secret text using the provided KMS key. </p>
capo_secrets_manager.errors.internal_service_error.InternalServiceError: <p>An error occurred on the server side.</p>
capo_secrets_manager.errors.invalid_next_token_exception.InvalidNextTokenException: <p>The <code>NextToken</code> value is invalid.</p>
capo_secrets_manager.errors.invalid_parameter_exception.InvalidParameterException: <p>The parameter name or value is invalid.</p>
capo_secrets_manager.errors.invalid_request_exception.InvalidRequestException: <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>
capo_secrets_manager.errors.resource_not_found_exception.ResourceNotFoundException: <p>Secrets Manager can't find the resource that you asked for.</p>
capo_secrets_manager.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To retrieve the secret values for a group of secrets listed by name
The following example gets the values for three secrets.
>>> client.batch_get_secret_value(secret_id_list=['MySecret1', 'MySecret2', 'MySecret3'])
"""
def _handler(
req: "OperationRequest[capo_secrets_manager.types.batch_get_secret_value_request.BatchGetSecretValueRequest]",
) -> OperationResponse[
"capo_secrets_manager.types.batch_get_secret_value_response.BatchGetSecretValueResponse"
]:
import capo_secrets_manager._operations.secretsmanager.batch_get_secret_value
output, http_response = (
capo_secrets_manager._operations.secretsmanager.batch_get_secret_value.batch_get_secret_value(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
def _redact_output(
output: "capo_secrets_manager.types.batch_get_secret_value_response.BatchGetSecretValueResponse",
) -> dict[str, Any]:
import capo_secrets_manager.types.batch_get_secret_value_response
return capo_secrets_manager.types.batch_get_secret_value_response.redact_sensitive(
output
)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging("BatchGetSecretValue", redact_output=_redact_output),
)
input_: capo_secrets_manager.types.batch_get_secret_value_request.BatchGetSecretValueRequest = {}
if secret_id_list is not None:
input_["secret_id_list"] = secret_id_list
if filters is not None:
input_["filters"] = filters
if max_results is not None:
input_["max_results"] = max_results
if next_token is not None:
input_["next_token"] = next_token
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|