Skip to content

list_key_rotations

list_key_rotations(
    key_id: KeyIdType,
    *,
    config_overrides: Optional[KMSClientConfig] = None,
    include_key_material: Optional[IncludeKeyMaterial] = None,
    limit: Optional[LimitType] = None,
    marker: Optional[MarkerType] = None,
) -> ListKeyRotationsResponse

Returns information about the key materials associated with the specified KMS key. You can use the optional IncludeKeyMaterial parameter to control which key materials are included in the response.

You must specify the KMS key in all requests. You can refine the key rotations list by limiting the number of rotations returned.

For detailed information about automatic and on-demand key rotations, see Rotate KMS keys in the Key Management Service Developer Guide.

Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.

Required permissions: kms:ListKeyRotations (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) –

    Gets the key rotations for the specified KMS key.

    Specify the key ID or key ARN of the KMS key.

    For example:

    • Key ID: 1234abcd-12ab-34cd-56ef-1234567890ab

    • Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab

    To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.

  • include_key_material (Optional[IncludeKeyMaterial], default: None ) –

    Use this optional parameter to control which key materials associated with this key are listed in the response. The default value of this parameter is ROTATIONS_ONLY. If you omit this parameter, KMS returns information on the key materials created by automatic or on-demand key rotation. When you specify a value of ALL_KEY_MATERIAL, KMS adds the first key material and any imported key material pending rotation to the response. This parameter can only be used with KMS keys that support automatic or on-demand key rotation.

  • 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 1000, inclusive. If you do not include a value, it defaults to 100.

  • 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.

Raises:

  • 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.

  • 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.

  • UnsupportedOperationException –

    The request was rejected because a specified parameter is not supported or a specified resource is not valid for this operation.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_kms/_services/kms.py
def list_key_rotations(
    self,
    key_id: "capo_kms.types.key_id_type.KeyIdType",
    *,
    config_overrides: Optional[KMSClientConfig] = None,
    include_key_material: Optional[
        "capo_kms.types.include_key_material.IncludeKeyMaterial"
    ] = None,
    limit: Optional["capo_kms.types.limit_type.LimitType"] = None,
    marker: Optional["capo_kms.types.marker_type.MarkerType"] = None,
) -> "capo_kms.types.list_key_rotations_response.ListKeyRotationsResponse":
    """<p>Returns information about the key materials associated with the specified KMS key. You can use the optional <code>IncludeKeyMaterial</code> parameter to control which key materials are included in the response.</p> <p>You must specify the KMS key in all requests. You can refine the key rotations list by limiting the number of rotations returned.</p> <p>For detailed information about automatic and on-demand key rotations, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/rotate-keys.html">Rotate KMS keys</a> in the <i>Key Management Service Developer Guide</i>.</p> <p> <b>Cross-account use</b>: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.</p> <p> <b>Required permissions</b>: <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:ListKeyRotations</a> (key policy)</p> <p> <b>Related operations:</b> </p> <ul> <li> <p> <a>EnableKeyRotation</a> </p> </li> <li> <p> <a>DeleteImportedKeyMaterial</a> </p> </li> <li> <p> <a>DisableKeyRotation</a> </p> </li> <li> <p> <a>GetKeyRotationStatus</a> </p> </li> <li> <p> <a>ImportKeyMaterial</a> </p> </li> <li> <p> <a>RotateKeyOnDemand</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>Gets the key rotations for the specified KMS key.</p> <p>Specify the key ID or key ARN of the KMS key.</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>
        include_key_material: <p>Use this optional parameter to control which key materials associated with this key are listed in the response. The default value of this parameter is <code>ROTATIONS_ONLY</code>. If you omit this parameter, KMS returns information on the key materials created by automatic or on-demand key rotation. When you specify a value of <code>ALL_KEY_MATERIAL</code>, KMS adds the first key material and any imported key material pending rotation to the response. This parameter can only be used with KMS keys that support automatic or on-demand key rotation. </p>
        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 1000, inclusive. If you do not include a value, it defaults to 100.</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>

    Raises:
        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.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.unsupported_operation_exception.UnsupportedOperationException: <p>The request was rejected because a specified parameter is not supported or a specified resource is not valid for this operation.</p>
        capo_kms.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_kms.types.list_key_rotations_request.ListKeyRotationsRequest]",
    ) -> OperationResponse[
        "capo_kms.types.list_key_rotations_response.ListKeyRotationsResponse"
    ]:
        import capo_kms._operations.trent_service.list_key_rotations

        output, http_response = (
            capo_kms._operations.trent_service.list_key_rotations.list_key_rotations(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListKeyRotations")
    )
    input_: capo_kms.types.list_key_rotations_request.ListKeyRotationsRequest = {
        "key_id": key_id
    }
    if include_key_material is not None:
        input_["include_key_material"] = include_key_material
    if limit is not None:
        input_["limit"] = limit
    if marker is not None:
        input_["marker"] = marker

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output