2017/02/15 - AWS Key Management Service - 3 new1 updated api methods
Changes Update kms client to latest version
Returns a list of all tags for the specified customer master key (CMK).
See also: AWS API Documentation
Request Syntax
client.list_resource_tags( KeyId='string', Limit=123, Marker='string' )
string
[REQUIRED]
A unique identifier for the CMK whose tags you are listing. You can use the unique key ID or the Amazon Resource Name (ARN) of the CMK. Examples:
Unique key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
integer
Use this parameter to specify the maximum number of items to return. When this value is present, AWS 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 50, inclusive. If you do not include a value, it defaults to 50.
string
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.
Do not attempt to construct this value. Use only the value of NextMarker from the truncated response you just received.
dict
Response Syntax
{ 'Tags': [ { 'TagKey': 'string', 'TagValue': 'string' }, ], 'NextMarker': 'string', 'Truncated': True|False }
Response Structure
(dict) --
Tags (list) --
A list of tags. Each tag consists of a tag key and a tag value.
(dict) --
A key-value pair. A tag consists of a tag key and a tag value. Tag keys and tag values are both required, but tag values can be empty (null) strings.
TagKey (string) --
The key of the tag.
TagValue (string) --
The value of the tag.
NextMarker (string) --
When Truncated is true, this element is present and contains the value to use for the Marker parameter in a subsequent request.
Do not assume or infer any information from this value.
Truncated (boolean) --
A flag that indicates whether there are more items in the list. When this value is true, the list in this response is truncated. To retrieve more items, pass the value of the NextMarker element in this response to the Marker parameter in a subsequent request.
Removes the specified tag or tags from the specified customer master key (CMK).
To remove a tag, you specify the tag key for each tag to remove. You do not specify the tag value. To overwrite the tag value for an existing tag, use TagResource.
See also: AWS API Documentation
Request Syntax
client.untag_resource( KeyId='string', TagKeys=[ 'string', ] )
string
[REQUIRED]
A unique identifier for the CMK from which you are removing tags. You can use the unique key ID or the Amazon Resource Name (ARN) of the CMK. Examples:
Unique key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
list
[REQUIRED]
One or more tag keys. Specify only the tag keys, not the tag values.
(string) --
None
Adds or overwrites one or more tags for the specified customer master key (CMK).
Each tag consists of a tag key and a tag value. Tag keys and tag values are both required, but tag values can be empty (null) strings.
You cannot use the same tag key more than once per CMK. For example, consider a CMK with one tag whose tag key is Purpose and tag value is Test. If you send a TagResource request for this CMK with a tag key of Purpose and a tag value of Prod, it does not create a second tag. Instead, the original tag is overwritten with the new tag value.
See also: AWS API Documentation
Request Syntax
client.tag_resource( KeyId='string', Tags=[ { 'TagKey': 'string', 'TagValue': 'string' }, ] )
string
[REQUIRED]
A unique identifier for the CMK you are tagging. You can use the unique key ID or the Amazon Resource Name (ARN) of the CMK. Examples:
Unique key ID: 1234abcd-12ab-34cd-56ef-1234567890ab
Key ARN: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
list
[REQUIRED]
One or more tags. Each tag consists of a tag key and a tag value.
(dict) --
A key-value pair. A tag consists of a tag key and a tag value. Tag keys and tag values are both required, but tag values can be empty (null) strings.
TagKey (string) -- [REQUIRED]
The key of the tag.
TagValue (string) -- [REQUIRED]
The value of the tag.
None
{'Tags': [{'TagKey': 'string', 'TagValue': 'string'}]}
Creates a customer master key (CMK).
You can use a CMK to encrypt small amounts of data (4 KiB or less) directly, but CMKs are more commonly used to encrypt data encryption keys (DEKs), which are used to encrypt raw data. For more information about DEKs and the difference between CMKs and DEKs, see the following:
The GenerateDataKey operation
AWS Key Management Service Concepts in the AWS Key Management Service Developer Guide
See also: AWS API Documentation
Request Syntax
client.create_key( Policy='string', Description='string', KeyUsage='ENCRYPT_DECRYPT', Origin='AWS_KMS'|'EXTERNAL', BypassPolicyLockoutSafetyCheck=True|False, Tags=[ { 'TagKey': 'string', 'TagValue': 'string' }, ] )
string
The key policy to attach to the CMK.
If you specify a policy and do not set BypassPolicyLockoutSafetyCheck to true, the policy must meet the following criteria:
It must allow the principal that is making the CreateKey request to make a subsequent PutKeyPolicy request on the CMK. This reduces the likelihood that the CMK becomes unmanageable. For more information, refer to the scenario in the Default Key Policy section in the AWS Key Management Service Developer Guide.
The principals that are specified in the key policy must exist and be visible to AWS KMS. When you create a new AWS principal (for example, an IAM user or role), you might need to enforce a delay before specifying the new principal in a key policy because the new principal might not immediately be visible to AWS KMS. For more information, see Changes that I make are not always immediately visible in the IAM User Guide.
If you do not specify a policy, AWS KMS attaches a default key policy to the CMK. For more information, see Default Key Policy in the AWS Key Management Service Developer Guide.
The policy size limit is 32 KiB (32768 bytes).
string
A description of the CMK.
Use a description that helps you decide whether the CMK is appropriate for a task.
string
The intended use of the CMK.
You can use CMKs only for symmetric encryption and decryption.
string
The source of the CMK's key material.
The default is AWS_KMS, which means AWS KMS creates the key material. When this parameter is set to EXTERNAL, the request creates a CMK without key material so that you can import key material from your existing key management infrastructure. For more information about importing key material into AWS KMS, see Importing Key Material in the AWS Key Management Service Developer Guide.
The CMK's Origin is immutable and is set when the CMK is created.
boolean
A flag to indicate whether to bypass the key policy lockout safety check.
Use this parameter only when you include a policy in the request and you intend to prevent the principal that is making the request from making a subsequent PutKeyPolicy request on the CMK.
The default value is false.
list
One or more tags. Each tag consists of a tag key and a tag value. Tag keys and tag values are both required, but tag values can be empty (null) strings.
Use this parameter to tag the CMK when it is created. Alternately, you can omit this parameter and instead tag the CMK after it is created using TagResource.
(dict) --
A key-value pair. A tag consists of a tag key and a tag value. Tag keys and tag values are both required, but tag values can be empty (null) strings.
TagKey (string) -- [REQUIRED]
The key of the tag.
TagValue (string) -- [REQUIRED]
The value of the tag.
dict
Response Syntax
{ 'KeyMetadata': { 'AWSAccountId': 'string', 'KeyId': 'string', 'Arn': 'string', 'CreationDate': datetime(2015, 1, 1), 'Enabled': True|False, 'Description': 'string', 'KeyUsage': 'ENCRYPT_DECRYPT', 'KeyState': 'Enabled'|'Disabled'|'PendingDeletion'|'PendingImport', 'DeletionDate': datetime(2015, 1, 1), 'ValidTo': datetime(2015, 1, 1), 'Origin': 'AWS_KMS'|'EXTERNAL', 'ExpirationModel': 'KEY_MATERIAL_EXPIRES'|'KEY_MATERIAL_DOES_NOT_EXPIRE' } }
Response Structure
(dict) --
KeyMetadata (dict) --
Metadata associated with the CMK.
AWSAccountId (string) --
The twelve-digit account ID of the AWS account that owns the CMK.
KeyId (string) --
The globally unique identifier for the CMK.
Arn (string) --
The Amazon Resource Name (ARN) of the CMK. For examples, see AWS Key Management Service (AWS KMS) in the Example ARNs section of the AWS General Reference.
CreationDate (datetime) --
The date and time when the CMK was created.
Enabled (boolean) --
Specifies whether the CMK is enabled. When KeyState is Enabled this value is true, otherwise it is false.
Description (string) --
The description of the CMK.
KeyUsage (string) --
The cryptographic operations for which you can use the CMK. Currently the only allowed value is ENCRYPT_DECRYPT, which means you can use the CMK for the Encrypt and Decrypt operations.
KeyState (string) --
The state of the CMK.
For more information about how key state affects the use of a CMK, see How Key State Affects the Use of a Customer Master Key in the AWS Key Management Service Developer Guide.
DeletionDate (datetime) --
The date and time after which AWS KMS deletes the CMK. This value is present only when KeyState is PendingDeletion, otherwise this value is omitted.
ValidTo (datetime) --
The time at which the imported key material expires. When the key material expires, AWS KMS deletes the key material and the CMK becomes unusable. This value is present only for CMKs whose Origin is EXTERNAL and whose ExpirationModel is KEY_MATERIAL_EXPIRES, otherwise this value is omitted.
Origin (string) --
The source of the CMK's key material. When this value is AWS_KMS, AWS KMS created the key material. When this value is EXTERNAL, the key material was imported from your existing key management infrastructure or the CMK lacks key material.
ExpirationModel (string) --
Specifies whether the CMK's key material expires. This value is present only when Origin is EXTERNAL, otherwise this value is omitted.