keys
Creates, updates, deletes or gets a key resource or lists keys in a region
Overview
| Name | keys |
| Type | Resource |
| Description | The If you change the value of the |
| Id | awscc.kms.keys |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
description | string | A description of the KMS key. Use a description that helps you to distinguish this KMS key from others in the account, such as its intended use. |
enabled | boolean | Specifies whether the KMS key is enabled. Disabled KMS keys cannot be used in cryptographic operations.WhenEnabled is true, the key state of the KMS key is Enabled. When Enabled is false, the key state of the KMS key is Disabled. The default value is true.The actual key state of the KMS key might be affected by actions taken outside of CloudFormation, such as running the EnableKey, DisableKey, or ScheduleKeyDeletion operations. For information about the key states of a KMS key, see Key state: Effect on your KMS key in the Developer Guide. |
enable_key_rotation | boolean | Enables automatic rotation of the key material for the specified KMS key. By default, automatic key rotation is not enabled.KMS supports automatic rotation only for symmetric encryption KMS keys (KeySpec = SYMMETRIC_DEFAULT). For asymmetric KMS keys, HMAC KMS keys, and KMS keys with Origin EXTERNAL, omit the EnableKeyRotation property or set it to false.To enable automatic key rotation of the key material for a multi-Region KMS key, set EnableKeyRotation to true on the primary key (created by using AWS::KMS::Key). KMS copies the rotation status to all replica keys. For details, see Rotating multi-Region keys in the Developer Guide.When you enable automatic rotation, KMS automatically creates new key material for the KMS key one year after the enable date and every year thereafter. KMS retains all key material until you delete the KMS key. For detailed information about automatic key rotation, see Rotating KMS keys in the Developer Guide. |
key_policy | object | The key policy to attach to the KMS key.If you provide a key policy, it must meet the following criteria:+ The key policy must allow the caller to make a subsequent PutKeyPolicy request on the KMS key. This reduces the risk that the KMS key becomes unmanageable. For more information, see Default key policy in the Developer Guide. (To omit this condition, set BypassPolicyLockoutSafetyCheck to true.)+ Each statement in the key policy must contain one or more principals. The principals in the key policy must exist and be visible to KMS. When you create a new AWS principal (for example, an IAM user or role), you might need to enforce a delay before including the new principal in a key policy because the new principal might not be immediately visible to KMS. For more information, see Changes that I make are not always immediately visible in the User Guide. If you do not provide a key policy, KMS attaches a default key policy to the KMS key. For more information, see Default key policy in the Developer Guide. A key policy document can include only the following characters: + Printable ASCII characters + Printable characters in the Basic Latin and Latin-1 Supplement character set + The tab ( \u0009), line feed (\u000A), and carriage return (\u000D) special charactersMinimum: 1Maximum: 32768 |
key_usage | string | Determines the cryptographic operations for which you can use the KMS key. The default value is If you change the value of the |
origin | string | The source of the key material for the KMS key. You cannot change the origin after you create the KMS key. The default is To create a KMS key with no key material (for imported key material), set this value to |
key_spec | string | Specifies the type of KMS key to create. The default value, The |
multi_region | boolean | Creates a multi-Region primary key that you can replicate in other AWS-Regions. You can't change the For a list of AWS-Regions in which multi-Region keys are supported, see Multi-Region keys in in the **. |
pending_window_in_days | integer | Specifies the number of days in the waiting period before KMS deletes a KMS key that has been removed from a CloudFormation stack. Enter a value between 7 and 30 days. The default value is 30 days.When you remove a KMS key from a CloudFormation stack, KMS schedules the KMS key for deletion and starts the mandatory waiting period. ThePendingWindowInDays property determines the length of waiting period. During the waiting period, the key state of KMS key is Pending Deletion or Pending Replica Deletion, which prevents the KMS key from being used in cryptographic operations. When the waiting period expires, KMS permanently deletes the KMS key.KMS will not delete a multi-Region primary key that has replica keys. If you remove a multi-Region primary key from a CloudFormation stack, its key state changes to PendingReplicaDeletion so it cannot be replicated or used in cryptographic operations. This state can persist indefinitely. When the last of its replica keys is deleted, the key state of the primary key changes to PendingDeletion and the waiting period specified by PendingWindowInDays begins. When this waiting period expires, KMS deletes the primary key. For details, see Deleting multi-Region keys in the Developer Guide.You cannot use a CloudFormation template to cancel deletion of the KMS key after you remove it from the stack, regardless of the waiting period. If you specify a KMS key in your template, even one with the same name, CloudFormation creates a new KMS key. To cancel deletion of a KMS key, use the KMS console or the CancelKeyDeletion operation. For information about the Pending Deletion and Pending Replica Deletion key states, see Key state: Effect on your KMS key in the Developer Guide. For more information about deleting KMS keys, see the ScheduleKeyDeletion operation in the API Reference and Deleting KMS keys in the Developer Guide. |
tags | array | Assigns one or more tags to the replica key.Tagging or untagging a KMS key can allow or deny permission to the KMS key. For details, see ABAC for in the Developer Guide.For information about tags in KMS, see Tagging keys in the Developer Guide. For information about tags in CloudFormation, see Tag. |
arn | string | |
key_id | string | |
bypass_policy_lockout_safety_check | boolean | Skips ("bypasses") the key policy lockout safety check. The default value is false.Setting this value to true increases the risk that the KMS key becomes unmanageable. Do not set this value to true indiscriminately.For more information, see Default key policy in the Developer Guide. Use this parameter only when you intend to prevent the principal that is making the request from making a subsequent PutKeyPolicy request on the KMS key. |
rotation_period_in_days | integer | Specifies a custom period of time between each rotation date. If no value is specified, the default value is 365 days.The rotation period defines the number of days after you enable automatic key rotation that KMS will rotate your key material, and the number of days between each automatic rotation thereafter.You can use the kms:RotationPeriodInDays condition key to further constrain the values that principals can specify in the RotationPeriodInDays parameter.For more information about rotating KMS keys and automatic rotation, see Rotating keys in the Developer Guide. |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
key_id | string | |
region | string | AWS region. |
For more information, see AWS::KMS::Key.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | keys | INSERT | region |
delete_resource | keys | DELETE | Identifier, region |
update_resource | keys | UPDATE | Identifier, PatchDocument, region |
list_resources | keys_list_only | SELECT | region |
get_resource | keys | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
Gets all properties from an individual key.
SELECT
region,
description,
enabled,
enable_key_rotation,
key_policy,
key_usage,
origin,
key_spec,
multi_region,
pending_window_in_days,
tags,
arn,
key_id,
bypass_policy_lockout_safety_check,
rotation_period_in_days
FROM awscc.kms.keys
WHERE
region = '{{ region }}' AND
Identifier = '{{ key_id }}';
Lists all keys in a region.
SELECT
region,
key_id
FROM awscc.kms.keys_list_only
WHERE
region = '{{ region }}';
INSERT example
Use the following StackQL query and manifest file to create a new key resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO awscc.kms.keys (
Description,
Enabled,
EnableKeyRotation,
KeyPolicy,
KeyUsage,
Origin,
KeySpec,
MultiRegion,
PendingWindowInDays,
Tags,
BypassPolicyLockoutSafetyCheck,
RotationPeriodInDays,
region
)
SELECT
'{{ description }}',
'{{ enabled }}',
'{{ enable_key_rotation }}',
'{{ key_policy }}',
'{{ key_usage }}',
'{{ origin }}',
'{{ key_spec }}',
'{{ multi_region }}',
'{{ pending_window_in_days }}',
'{{ tags }}',
'{{ bypass_policy_lockout_safety_check }}',
'{{ rotation_period_in_days }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
/*+ create */
INSERT INTO awscc.kms.keys (
Description,
Enabled,
EnableKeyRotation,
KeyPolicy,
KeyUsage,
Origin,
KeySpec,
MultiRegion,
PendingWindowInDays,
Tags,
BypassPolicyLockoutSafetyCheck,
RotationPeriodInDays,
region
)
SELECT
'{{ description }}',
'{{ enabled }}',
'{{ enable_key_rotation }}',
'{{ key_policy }}',
'{{ key_usage }}',
'{{ origin }}',
'{{ key_spec }}',
'{{ multi_region }}',
'{{ pending_window_in_days }}',
'{{ tags }}',
'{{ bypass_policy_lockout_safety_check }}',
'{{ rotation_period_in_days }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: key
props:
- name: description
value: '{{ description }}'
- name: enabled
value: '{{ enabled }}'
- name: enable_key_rotation
value: '{{ enable_key_rotation }}'
- name: key_policy
value: {}
- name: key_usage
value: '{{ key_usage }}'
- name: origin
value: '{{ origin }}'
- name: key_spec
value: '{{ key_spec }}'
- name: multi_region
value: '{{ multi_region }}'
- name: pending_window_in_days
value: '{{ pending_window_in_days }}'
- name: tags
value:
- value: '{{ value }}'
key: '{{ key }}'
- name: bypass_policy_lockout_safety_check
value: '{{ bypass_policy_lockout_safety_check }}'
- name: rotation_period_in_days
value: '{{ rotation_period_in_days }}'
UPDATE example
Use the following StackQL query and manifest file to update a key resource, using stack-deploy.
/*+ update */
UPDATE awscc.kms.keys
SET PatchDocument = string('{{ {
"Description": description,
"Enabled": enabled,
"EnableKeyRotation": enable_key_rotation,
"KeyPolicy": key_policy,
"KeyUsage": key_usage,
"Origin": origin,
"KeySpec": key_spec,
"MultiRegion": multi_region,
"PendingWindowInDays": pending_window_in_days,
"Tags": tags,
"BypassPolicyLockoutSafetyCheck": bypass_policy_lockout_safety_check,
"RotationPeriodInDays": rotation_period_in_days
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ key_id }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
DELETE example
/*+ delete */
DELETE FROM awscc.kms.keys
WHERE
Identifier = '{{ key_id }}' AND
region = '{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
Additional Parameters
Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with INSERT, UPDATE, or DELETE operations. These include:
| Parameter | Description |
|---|---|
ClientToken | A unique identifier to ensure the idempotency of the resource request.This allows the provider to accurately distinguish between retries and new requests.A client token is valid for 36 hours once used. After that, a resource request with the same client token is treated as a new request. If you do not specify a client token, one is generated for inclusion in the request. |
RoleArn | The ARN of the IAM role used to perform this resource operation.The role specified must have the permissions required for this operation.If you do not specify a role, a temporary session is created using your AWS user credentials. |
TypeVersionId | For private resource types, the type version to use in this resource operation.If you do not specify a resource version, the default version is used. |
Permissions
To operate on the keys resource, the following permissions are required:
- Create
- Read
- Update
- Delete
- List
kms:CreateKey,
kms:EnableKeyRotation,
kms:DisableKey,
kms:TagResource,
kms:PutKeyPolicy
kms:DescribeKey,
kms:GetKeyPolicy,
kms:GetKeyRotationStatus,
kms:ListResourceTags
kms:DescribeKey,
kms:DisableKey,
kms:DisableKeyRotation,
kms:EnableKey,
kms:EnableKeyRotation,
kms:PutKeyPolicy,
kms:TagResource,
kms:UntagResource,
kms:UpdateKeyDescription,
kms:ListResourceTags
kms:DescribeKey,
kms:ScheduleKeyDeletion
kms:ListKeys,
kms:DescribeKey