Gets a list of aliases in the caller's Amazon Web Services account and region. For more information about aliases, see CreateAlias.
By default, the ListAliases operation returns all aliases in the account and region. To get only the aliases associated with a particular KMS key, use the KeyId parameter.
The ListAliases response can include aliases that you created and associated with your customer managed keys, and aliases that Amazon Web Services created and associated with Amazon Web Services managed keys in your account. You can recognize Amazon Web Services aliases because their names have the format aws/, such as aws/dynamodb.
The response might also include aliases that have no TargetKeyId field. These are predefined aliases that Amazon Web Services has created but has not yet associated with a KMS key. Aliases that Amazon Web Services creates in your account, including predefined aliases, do not count against your KMS aliases quota.
Cross-account use: No. ListAliases does not return aliases in other Amazon Web Services accounts.
Required permissions: kms:ListAliases (IAM policy)
For details, see Controlling access to aliases in the Key Management Service Developer Guide.
Related operations:
Eventual consistency: The KMS API follows an eventual consistency model. For more information, see KMS eventual consistency.
Parameters:
-
key_id
(Optional[KeyIdType], default:
None
)
–
Lists only aliases that are associated with the specified KMS key. Enter a KMS key in your Amazon Web Services account.
This parameter is optional. If you omit it, ListAliases returns all aliases in the account and Region.
Specify the key ID or key ARN of the KMS key.
For example:
To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.
-
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.
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.
Examples:
To list aliases
The following example lists aliases.
>>> client.list_aliases()
Source code in docs_src/capo_kms/_services/kms.py
| def list_aliases(
self,
*,
config_overrides: Optional[KMSClientConfig] = None,
key_id: Optional["capo_kms.types.key_id_type.KeyIdType"] = None,
limit: Optional["capo_kms.types.limit_type.LimitType"] = None,
marker: Optional["capo_kms.types.marker_type.MarkerType"] = None,
) -> "capo_kms.types.list_aliases_response.ListAliasesResponse":
"""<p>Gets a list of aliases in the caller's Amazon Web Services account and region. For more information about aliases, see <a>CreateAlias</a>.</p> <p>By default, the <code>ListAliases</code> operation returns all aliases in the account and region. To get only the aliases associated with a particular KMS key, use the <code>KeyId</code> parameter.</p> <p>The <code>ListAliases</code> response can include aliases that you created and associated with your customer managed keys, and aliases that Amazon Web Services created and associated with Amazon Web Services managed keys in your account. You can recognize Amazon Web Services aliases because their names have the format <code>aws/<service-name></code>, such as <code>aws/dynamodb</code>.</p> <p>The response might also include aliases that have no <code>TargetKeyId</code> field. These are predefined aliases that Amazon Web Services has created but has not yet associated with a KMS key. Aliases that Amazon Web Services creates in your account, including predefined aliases, do not count against your <a href="https://docs.aws.amazon.com/kms/latest/developerguide/resource-limits.html#aliases-per-key">KMS aliases quota</a>.</p> <p> <b>Cross-account use</b>: No. <code>ListAliases</code> does not return aliases in other Amazon Web Services accounts.</p> <p> <b>Required permissions</b>: <a href="https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html">kms:ListAliases</a> (IAM policy)</p> <p>For details, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/alias-access.html">Controlling access to aliases</a> in the <i>Key Management Service Developer Guide</i>.</p> <p> <b>Related operations:</b> </p> <ul> <li> <p> <a>CreateAlias</a> </p> </li> <li> <p> <a>DeleteAlias</a> </p> </li> <li> <p> <a>UpdateAlias</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>Lists only aliases that are associated with the specified KMS key. Enter a KMS key in your Amazon Web Services account. </p> <p>This parameter is optional. If you omit it, <code>ListAliases</code> returns all aliases in the account and Region.</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>
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>
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.
Examples:
To list aliases
The following example lists aliases.
>>> client.list_aliases()
"""
def _handler(
req: "OperationRequest[capo_kms.types.list_aliases_request.ListAliasesRequest]",
) -> OperationResponse[
"capo_kms.types.list_aliases_response.ListAliasesResponse"
]:
import capo_kms._operations.trent_service.list_aliases
output, http_response = (
capo_kms._operations.trent_service.list_aliases.list_aliases(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("ListAliases")
)
input_: capo_kms.types.list_aliases_request.ListAliasesRequest = {}
if key_id is not None:
input_["key_id"] = key_id
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
|