describeSecret method

Future<DescribeSecretResponse> describeSecret({
  1. required String secretId,
})

Retrieves the details of a secret. It does not include the encrypted fields. Secrets Manager only returns fields populated with a value in the response.

Minimum permissions

To run this command, you must have the following permissions:

  • secretsmanager:DescribeSecret
Related operations

May throw ResourceNotFoundException. May throw InternalServiceError.

Parameter secretId : The identifier of the secret whose details you want to retrieve. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.

If you specify an incomplete ARN without the random suffix, and instead provide the 'friendly name', you must not include the random suffix. If you do include the random suffix added by Secrets Manager, you receive either a ResourceNotFoundException or an AccessDeniedException error, depending on your permissions.

Implementation

Future<DescribeSecretResponse> describeSecret({
  required String secretId,
}) async {
  ArgumentError.checkNotNull(secretId, 'secretId');
  _s.validateStringLength(
    'secretId',
    secretId,
    1,
    2048,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'secretsmanager.DescribeSecret'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'SecretId': secretId,
    },
  );

  return DescribeSecretResponse.fromJson(jsonResponse.body);
}