Deletes the specified grant. You revoke a grant to terminate the permissions that the grant allows. For more information, see Retiring and revoking grants in the Key Management Service Developer Guide .
When you create, retire, or revoke a grant, there might be a brief delay, usually less than five minutes, until the grant is available throughout KMS. This state is known as eventual consistency. For details, see Eventual consistency in the Key Management Service Developer Guide .
For detailed information about grants, including grant terminology, see Grants in KMS in the Key Management Service Developer Guide . For examples of creating grants in several programming languages, see Use CreateGrant with an Amazon Web Services SDK or CLI.
Cross-account use: Yes. To perform this operation on a KMS key in a different Amazon Web Services account, specify the key ARN in the value of the KeyId parameter.
Required permissions: kms:RevokeGrant (key policy).
Related operations:
Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency.
Parameters:
-
key_id
(KeyIdType)
–
A unique identifier for the KMS key associated with the grant. To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.
Specify the key ID or key ARN of the KMS key. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN.
For example:
To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.
-
grant_id
(GrantIdType)
–
-
dry_run
(Optional[NullableBooleanType], default:
None
)
–
Checks if your request will succeed. DryRun is an optional parameter.
To learn more about how to use this parameter, see Testing your permissions in the Key Management Service Developer Guide.
Raises:
-
DependencyTimeoutException
–
The system timed out while trying to fulfill the request. You can retry the request.
-
DryRunOperationException
–
The request was rejected because the DryRun parameter was specified.
-
InvalidArnException
–
The request was rejected because a specified ARN, or an ARN in a key policy, is not valid.
-
InvalidGrantIdException
–
The request was rejected because the specified GrantId is not valid.
-
KMSInternalException
–
The request was rejected because an internal exception occurred. The request can be retried.
-
KMSInvalidStateException
–
The request was rejected because the state of the specified resource is not valid for this request.
This exceptions means one of the following:
-
The key state of the KMS key is not compatible with the operation.
To find the key state, use the DescribeKey operation. For more information about which key states are compatible with each KMS operation, see Key states of KMS keys in the Key Management Service Developer Guide .
-
For cryptographic operations on KMS keys in custom key stores, this exception represents a general failure with many possible causes. To identify the cause, see the error message that accompanies the exception.
-
NotFoundException
–
The request was rejected because the specified entity or resource could not be found.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
To revoke a grant
The following example revokes a grant.
>>> client.revoke_grant(key_id='1234abcd-12ab-34cd-56ef-1234567890ab', grant_id='0c237476b39f8bc44e45212e08498fbe3151305030726c0590dd8d3e9f3d6a60')
Source code in docs_src/capo_kms/_services/kms.py
| def revoke_grant(
self,
key_id: "capo_kms.types.key_id_type.KeyIdType",
grant_id: "capo_kms.types.grant_id_type.GrantIdType",
*,
config_overrides: Optional[KMSClientConfig] = None,
dry_run: Optional[
"capo_kms.types.nullable_boolean_type.NullableBooleanType"
] = None,
) -> None:
"""<p>Deletes the specified grant. You revoke a grant to terminate the permissions that the grant allows. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/grant-delete.html">Retiring and revoking grants</a> in the <i> <i>Key Management Service Developer Guide</i> </i>.</p> <p>When you create, retire, or revoke a grant, there might be a brief delay, usually less than five minutes, until the grant is available throughout KMS. This state is known as <i>eventual consistency</i>. For details, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#terms-eventual-consistency">Eventual consistency</a> in the <i> <i>Key Management Service Developer Guide</i> </i>. </p> <p>For detailed information about grants, including grant terminology, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/grants.html">Grants in KMS</a> in the <i> <i>Key Management Service Developer Guide</i> </i>. For examples of creating grants in several programming languages, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/example_kms_CreateGrant_section.html">Use CreateGrant with an Amazon Web Services SDK or CLI</a>. </p> <p> <b>Cross-account use</b>: Yes. To perform this operation on a KMS key in a different Amazon Web Services account, specify the key ARN in the value of the <code>KeyId</code> parameter.</p> <p> <b>Required permissions</b>: <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:RevokeGrant</a> (key policy).</p> <p> <b>Related operations:</b> </p> <ul> <li> <p> <a>CreateGrant</a> </p> </li> <li> <p> <a>ListGrants</a> </p> </li> <li> <p> <a>ListRetirableGrants</a> </p> </li> <li> <p> <a>RetireGrant</a> </p> </li> </ul> <p> <b>Eventual consistency</b>: The KMS API follows an eventual consistency model. For more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/accessing-kms.html#programming-eventual-consistency">KMS eventual consistency</a>.</p>
Args:
key_id: <p>A unique identifier for the KMS key associated with the grant. To get the key ID and key ARN for a KMS key, use <a>ListKeys</a> or <a>DescribeKey</a>.</p> <p>Specify the key ID or key ARN of the KMS key. To specify a KMS key in a different Amazon Web Services account, you must use the key ARN.</p> <p>For example:</p> <ul> <li> <p>Key ID: <code>1234abcd-12ab-34cd-56ef-1234567890ab</code> </p> </li> <li> <p>Key ARN: <code>arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab</code> </p> </li> </ul> <p>To get the key ID and key ARN for a KMS key, use <a>ListKeys</a> or <a>DescribeKey</a>.</p>
grant_id: <p>Identifies the grant to revoke. To get the grant ID, use <a>CreateGrant</a>, <a>ListGrants</a>, or <a>ListRetirableGrants</a>.</p>
dry_run: <p>Checks if your request will succeed. <code>DryRun</code> is an optional parameter. </p> <p>To learn more about how to use this parameter, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/testing-permissions.html">Testing your permissions</a> in the <i>Key Management Service Developer Guide</i>.</p>
Raises:
capo_kms.errors.dependency_timeout_exception.DependencyTimeoutException: <p>The system timed out while trying to fulfill the request. You can retry the request.</p>
capo_kms.errors.dry_run_operation_exception.DryRunOperationException: <p> The request was rejected because the DryRun parameter was specified. </p>
capo_kms.errors.invalid_arn_exception.InvalidArnException: <p>The request was rejected because a specified ARN, or an ARN in a key policy, is not valid.</p>
capo_kms.errors.invalid_grant_id_exception.InvalidGrantIdException: <p>The request was rejected because the specified <code>GrantId</code> is not valid.</p>
capo_kms.errors.kms_internal_exception.KMSInternalException: <p>The request was rejected because an internal exception occurred. The request can be retried.</p>
capo_kms.errors.kms_invalid_state_exception.KMSInvalidStateException: <p>The request was rejected because the state of the specified resource is not valid for this request.</p> <p>This exceptions means one of the following:</p> <ul> <li> <p>The key state of the KMS key is not compatible with the operation. </p> <p>To find the key state, use the <a>DescribeKey</a> operation. For more information about which key states are compatible with each KMS operation, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html">Key states of KMS keys</a> in the <i> <i>Key Management Service Developer Guide</i> </i>.</p> </li> <li> <p>For cryptographic operations on KMS keys in custom key stores, this exception represents a general failure with many possible causes. To identify the cause, see the error message that accompanies the exception.</p> </li> </ul>
capo_kms.errors.not_found_exception.NotFoundException: <p>The request was rejected because the specified entity or resource could not be found.</p>
capo_kms.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To revoke a grant
The following example revokes a grant.
>>> client.revoke_grant(key_id='1234abcd-12ab-34cd-56ef-1234567890ab', grant_id='0c237476b39f8bc44e45212e08498fbe3151305030726c0590dd8d3e9f3d6a60')
"""
def _handler(
req: "OperationRequest[capo_kms.types.revoke_grant_request.RevokeGrantRequest]",
) -> OperationResponse[None]:
import capo_kms._operations.trent_service.revoke_grant
output, http_response = (
capo_kms._operations.trent_service.revoke_grant.revoke_grant(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("RevokeGrant")
)
input_: capo_kms.types.revoke_grant_request.RevokeGrantRequest = {
"key_id": key_id,
"grant_id": grant_id,
}
if dry_run is not None:
input_["dry_run"] = dry_run
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|