deleteResourcePolicy method

Future<DeleteResourcePolicyResponse> deleteResourcePolicy({
  1. required String secretId,
})

Deletes the resource-based permission policy attached to the secret.

Minimum permissions

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

  • secretsmanager:DeleteResourcePolicy
Related operations
  • To attach a resource policy to a secret, use PutResourcePolicy.
  • To retrieve the current resource-based policy that's attached to a secret, use GetResourcePolicy.
  • 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 delete 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<DeleteResourcePolicyResponse> deleteResourcePolicy({
  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.DeleteResourcePolicy'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'SecretId': secretId,
    },
  );

  return DeleteResourcePolicyResponse.fromJson(jsonResponse.body);
}