getResourcePolicy method

Future<GetResourcePolicyResponse> getResourcePolicy({
  1. required String secretId,
})

Retrieves the JSON text of the resource-based policy document attached to the specified secret. The JSON request string input and response output displays formatted code with white space and line breaks for better readability. Submit your input as a single line JSON string.

Minimum permissions

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

  • secretsmanager:GetResourcePolicy
Related operations

May throw ResourceNotFoundException. May throw InternalServiceError. May throw InvalidRequestException.

Parameter secretId : Specifies the secret that you want to retrieve the attached resource-based policy for. 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<GetResourcePolicyResponse> getResourcePolicy({
  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.GetResourcePolicy'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'SecretId': secretId,
    },
  );

  return GetResourcePolicyResponse.fromJson(jsonResponse.body);
}