validateResourcePolicy method
Validates that a resource policy does not grant a wide range of principals access to your secret. A resource-based policy is optional for secrets.
The API performs three checks when validating the policy:
- Sends a call to Zelkova, an automated reasoning engine, to ensure your resource policy does not allow broad access to your secret, for example policies that use a wildcard for the principal.
- Checks for correct syntax in a policy.
- Verifies the policy does not lock out a caller.
Required permissions:
secretsmanager:ValidateResourcePolicy and
secretsmanager:PutResourcePolicy. For more information, see
IAM policy actions for Secrets Manager and Authentication
and access control in Secrets Manager.
May throw InternalServiceError.
May throw InvalidParameterException.
May throw InvalidRequestException.
May throw MalformedPolicyDocumentException.
May throw ResourceNotFoundException.
Parameter resourcePolicy :
A JSON-formatted string that contains an Amazon Web Services
resource-based policy. The policy in the string identifies who can access
or manage this secret and its versions. For example policies, see Permissions
policy examples.
Parameter secretId :
The ARN or name of the secret with the resource-based policy you want to
validate.
Implementation
Future<ValidateResourcePolicyResponse> validateResourcePolicy({
required String resourcePolicy,
String? secretId,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'secretsmanager.ValidateResourcePolicy'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'ResourcePolicy': resourcePolicy,
if (secretId != null) 'SecretId': secretId,
},
);
return ValidateResourcePolicyResponse.fromJson(jsonResponse.body);
}