getResourcePolicy method
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
- To attach a resource policy to a secret, use PutResourcePolicy.
- To delete the resource-based policy attached to a secret, use DeleteResourcePolicy.
- To list all of the currently available secrets, use ListSecrets.
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);
}