Returns information about all grants in the Amazon Web Services account and Region that have the specified retiring principal or retiring service principal.
You can specify any principal in your Amazon Web Services account. The grants that are returned include grants for KMS keys in your Amazon Web Services account and other Amazon Web Services accounts. You might use this operation to determine which grants you may retire. To retire a grant, use the RetireGrant operation.
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: You must specify a principal in your Amazon Web Services account. This operation returns a list of grants where the retiring principal specified in the ListRetirableGrants request is the same retiring principal on the grant. This can include grants on KMS keys owned by other Amazon Web Services accounts, but you do not need kms:ListRetirableGrants permission (or any other additional permission) in any Amazon Web Services account other than your own.
Required permissions: kms:ListRetirableGrants (IAM policy) in your Amazon Web Services account.
When listing retirable grants by RetiringPrincipal, KMS authorizes ListRetirableGrants requests by evaluating the caller account's kms:ListRetirableGrants permissions. The authorized resource in ListRetirableGrants calls is the retiring principal specified in the request. KMS does not evaluate the caller's permissions to verify their access to any KMS keys or grants that might be returned by the ListRetirableGrants call.
The RetiringServicePrincipal filter is only usable by callers in a service principal.
Related operations:
Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency.
Parameters:
-
limit
(Optional[LimitType], default:
None
)
–
Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer.
This value is optional. If you include a value, it must be between 1 and 100, inclusive. If you do not include a value, it defaults to 50.
-
marker
(Optional[MarkerType], default:
None
)
–
Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of NextMarker from the truncated response you just received.
-
retiring_principal
(Optional[PrincipalIdType], default:
None
)
–
The retiring principal for which to list grants. Enter a principal in your Amazon Web Services account.
To specify the retiring principal, use the Amazon Resource Name (ARN) of an Amazon Web Services principal. Valid principals include Amazon Web Services accounts, IAM users, IAM roles, federated users, and assumed role users. For help with the ARN syntax for a principal, see IAM ARNs in the Identity and Access Management User Guide .
You must specify either RetiringPrincipal or RetiringServicePrincipal, but not both.
-
retiring_service_principal
(Optional[ServicePrincipalType], default:
None
)
–
The retiring service principal for which to list grants. This filter is only usable by callers in a service principal.
You must specify either RetiringPrincipal or RetiringServicePrincipal, but not both.
Raises:
-
DependencyTimeoutException
–
The system timed out while trying to fulfill the request. You can retry the request.
-
InvalidArnException
–
The request was rejected because a specified ARN, or an ARN in a key policy, is not valid.
-
InvalidMarkerException
–
The request was rejected because the marker that specifies where pagination should next begin is not valid.
-
KMSInternalException
–
The request was rejected because an internal exception occurred. The request can be retried.
-
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.
Source code in docs_src/capo_kms/_services/async_kms.py
| async def list_retirable_grants(
self,
*,
config_overrides: Optional[AsyncKMSClientConfig] = None,
limit: Optional["capo_kms.types.limit_type.LimitType"] = None,
marker: Optional["capo_kms.types.marker_type.MarkerType"] = None,
retiring_principal: Optional[
"capo_kms.types.principal_id_type.PrincipalIdType"
] = None,
retiring_service_principal: Optional[
"capo_kms.types.service_principal_type.ServicePrincipalType"
] = None,
) -> "capo_kms.types.list_grants_response.ListGrantsResponse":
"""<p>Returns information about all grants in the Amazon Web Services account and Region that have the specified retiring principal or retiring service principal. </p> <p>You can specify any principal in your Amazon Web Services account. The grants that are returned include grants for KMS keys in your Amazon Web Services account and other Amazon Web Services accounts. You might use this operation to determine which grants you may retire. To retire a grant, use the <a>RetireGrant</a> operation.</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>: You must specify a principal in your Amazon Web Services account. This operation returns a list of grants where the retiring principal specified in the <code>ListRetirableGrants</code> request is the same retiring principal on the grant. This can include grants on KMS keys owned by other Amazon Web Services accounts, but you do not need <code>kms:ListRetirableGrants</code> permission (or any other additional permission) in any Amazon Web Services account other than your own.</p> <p> <b>Required permissions</b>: <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:ListRetirableGrants</a> (IAM policy) in your Amazon Web Services account.</p> <note> <p>When listing retirable grants by <code>RetiringPrincipal</code>, KMS authorizes <code>ListRetirableGrants</code> requests by evaluating the caller account's kms:ListRetirableGrants permissions. The authorized resource in <code>ListRetirableGrants</code> calls is the retiring principal specified in the request. KMS does not evaluate the caller's permissions to verify their access to any KMS keys or grants that might be returned by the <code>ListRetirableGrants</code> call.</p> <p>The <code>RetiringServicePrincipal</code> filter is only usable by callers in a service principal.</p> </note> <p> <b>Related operations:</b> </p> <ul> <li> <p> <a>CreateGrant</a> </p> </li> <li> <p> <a>ListGrants</a> </p> </li> <li> <p> <a>RetireGrant</a> </p> </li> <li> <p> <a>RevokeGrant</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:
limit: <p>Use this parameter to specify the maximum number of items to return. When this value is present, KMS does not return more than the specified number of items, but it might return fewer.</p> <p>This value is optional. If you include a value, it must be between 1 and 100, inclusive. If you do not include a value, it defaults to 50.</p>
marker: <p>Use this parameter in a subsequent request after you receive a response with truncated results. Set it to the value of <code>NextMarker</code> from the truncated response you just received.</p>
retiring_principal: <p>The retiring principal for which to list grants. Enter a principal in your Amazon Web Services account.</p> <p>To specify the retiring principal, use the <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon Resource Name (ARN)</a> of an Amazon Web Services principal. Valid principals include Amazon Web Services accounts, IAM users, IAM roles, federated users, and assumed role users. For help with the ARN syntax for a principal, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-arns">IAM ARNs</a> in the <i> <i>Identity and Access Management User Guide</i> </i>.</p> <p>You must specify either <code>RetiringPrincipal</code> or <code>RetiringServicePrincipal</code>, but not both.</p>
retiring_service_principal: <p>The retiring service principal for which to list grants. This filter is only usable by callers in a service principal.</p> <p>You must specify either <code>RetiringPrincipal</code> or <code>RetiringServicePrincipal</code>, but not both.</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.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_marker_exception.InvalidMarkerException: <p>The request was rejected because the marker that specifies where pagination should next begin 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.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.
"""
async def _handler(
req: "AsyncOperationRequest[capo_kms.types.list_retirable_grants_request.ListRetirableGrantsRequest]",
) -> AsyncOperationResponse[
"capo_kms.types.list_grants_response.ListGrantsResponse"
]:
import capo_kms._operations.trent_service.list_retirable_grants
(
output,
http_response,
) = await capo_kms._operations.trent_service.list_retirable_grants.async_list_retirable_grants(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("ListRetirableGrants")
)
input_: capo_kms.types.list_retirable_grants_request.ListRetirableGrantsRequest = {}
if limit is not None:
input_["limit"] = limit
if marker is not None:
input_["marker"] = marker
if retiring_principal is not None:
input_["retiring_principal"] = retiring_principal
if retiring_service_principal is not None:
input_["retiring_service_principal"] = retiring_service_principal
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|