AWS::KMS::Key - AWS CloudFormation (original) (raw)

The AWS::KMS::Key resource specifies an KMS key in AWS Key Management Service. You can use this resource to create symmetric encryption KMS keys, asymmetric KMS keys for encryption or signing, and symmetric HMAC KMS keys. You can useAWS::KMS::Key to create multi-Region primary keys of all supported types. To replicate a multi-Region key, use theAWS::KMS::ReplicaKey resource.

Important

If you change the value of the KeySpec, KeyUsage,Origin, or MultiRegion properties of an existing KMS key, the update request fails, regardless of the value of the UpdateReplacePolicy attribute. This prevents you from accidentally deleting a KMS key by changing any of its immutable property values.

Note

AWS KMS replaced the term customer master key (CMK) with AWS KMS key and KMS key. The concept has not changed. To prevent breaking changes, AWS KMS is keeping some variations of this term.

You can use symmetric encryption KMS keys to encrypt and decrypt small amounts of data, but they are more commonly used to generate data keys and data key pairs. You can also use a symmetric encryption KMS key to encrypt data stored in AWS services that are integrated with AWS KMS. For more information, see Symmetric encryption KMS keys in the_AWS Key Management Service Developer Guide_.

You can use asymmetric KMS keys to encrypt and decrypt data or sign messages and verify signatures. To create an asymmetric key, you must specify an asymmetric KeySpec value and a KeyUsage value. For details, see Asymmetric keys in AWS KMS in the_AWS Key Management Service Developer Guide_.

You can use HMAC KMS keys (which are also symmetric keys) to generate and verify hash-based message authentication codes. To create an HMAC key, you must specify an HMACKeySpec value and a KeyUsage value ofGENERATE_VERIFY_MAC. For details, see HMAC keys in AWS KMS in the_AWS Key Management Service Developer Guide_.

You can also create symmetric encryption, asymmetric, and HMAC multi-Region primary keys. To create a multi-Region primary key, set the MultiRegion property totrue. For information about multi-Region keys, see Multi-Region keys in AWS KMS in the AWS Key Management Service Developer Guide.

You cannot use the AWS::KMS::Key resource to specify a KMS key with imported key material or a KMS key in a custom key store.

Regions

AWS KMS CloudFormation resources are available in all Regions in which AWS KMS and AWS CloudFormation are supported. You can use the AWS::KMS::Key resource to create and manage all KMS key types that are supported in a Region.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{
  "Type" : "AWS::KMS::Key",
  "Properties" : {
      "BypassPolicyLockoutSafetyCheck" : Boolean,
      "Description" : String,
      "Enabled" : Boolean,
      "EnableKeyRotation" : Boolean,
      "KeyPolicy" : Json,
      "KeySpec" : String,
      "KeyUsage" : String,
      "MultiRegion" : Boolean,
      "Origin" : String,
      "PendingWindowInDays" : Integer,
      "RotationPeriodInDays" : Integer,
      "Tags" : [ Tag, ... ]
    }
}

YAML

Type: AWS::KMS::Key
Properties:
  BypassPolicyLockoutSafetyCheck: Boolean
  Description: String
  Enabled: Boolean
  EnableKeyRotation: Boolean
  KeyPolicy: Json
  KeySpec: String
  KeyUsage: String
  MultiRegion: Boolean
  Origin: String
  PendingWindowInDays: Integer
  RotationPeriodInDays: Integer
  Tags: 
    - Tag

Properties

BypassPolicyLockoutSafetyCheck

Skips ("bypasses") the key policy lockout safety check. The default value is false.

Important

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, seeDefault key policy in the AWS Key Management Service Developer Guide.

Use this parameter only when you intend to prevent the principal that is making the request from making a subsequentPutKeyPolicy request on the KMS key.

Required: No

Type: Boolean

Update requires: No interruption

Description

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.

Required: No

Type: String

Minimum: 0

Maximum: 8192

Update requires: No interruption

Enabled

Specifies whether the KMS key is enabled. Disabled KMS keys cannot be used in cryptographic operations.

When Enabled 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_AWS Key Management Service Developer Guide_.

Required: No

Type: Boolean

Update requires: No interruption

EnableKeyRotation

Enables automatic rotation of the key material for the specified KMS key. By default, automatic key rotation is not enabled.

AWS 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). AWS KMS copies the rotation status to all replica keys. For details, see Rotating multi-Region keys in the AWS Key Management Service Developer Guide.

When you enable automatic rotation, AWS KMS automatically creates new key material for the KMS key one year after the enable date and every year thereafter. AWS KMS retains all key material until you delete the KMS key. For detailed information about automatic key rotation, see Rotating KMS keys in the_AWS Key Management Service Developer Guide_.

Required: No

Type: Boolean

Update requires: No interruption

KeyPolicy

The key policy to attach to the KMS key.

If you provide a key policy, it must meet the following criteria:

If you do not provide a key policy, AWS KMS attaches a default key policy to the KMS key. For more information, see Default key policy in the AWS Key Management Service Developer Guide.

A key policy document can include only the following characters:

Minimum: 1

Maximum: 32768

Required: No

Type: Json

Update requires: No interruption

KeySpec

Specifies the type of KMS key to create. The default value, SYMMETRIC_DEFAULT, creates a KMS key with a 256-bit symmetric key for encryption and decryption. In China Regions, SYMMETRIC_DEFAULT creates a 128-bit symmetric key that uses SM4 encryption. You can't change theKeySpec value after the KMS key is created. For help choosing a key spec for your KMS key, see Choosing a KMS key type in the AWS Key Management Service Developer Guide.

The KeySpec property determines the type of key material in the KMS key and the algorithms that the KMS key supports. To further restrict the algorithms that can be used with the KMS key, use a condition key in its key policy or IAM policy. For more information, see AWS KMS condition keys in the AWS Key Management Service Developer Guide.

Important

If you change the value of the KeySpec property on an existing KMS key, the update request fails, regardless of the value of the UpdateReplacePolicy attribute. This prevents you from accidentally deleting a KMS key by changing an immutable property value.

AWS KMS supports the following key specs for KMS keys:

Required: No

Type: String

Allowed values: SYMMETRIC_DEFAULT | RSA_2048 | RSA_3072 | RSA_4096 | ECC_NIST_P256 | ECC_NIST_P384 | ECC_NIST_P521 | ECC_SECG_P256K1 | HMAC_224 | HMAC_256 | HMAC_384 | HMAC_512 | SM2

Update requires: Replacement

KeyUsage

Determines the cryptographic operations for which you can use the KMS key. The default value isENCRYPT_DECRYPT. This property is required for asymmetric KMS keys and HMAC KMS keys. You can't change the KeyUsage value after the KMS key is created.

Important

If you change the value of the KeyUsage property on an existing KMS key, the update request fails, regardless of the value of the UpdateReplacePolicy attribute. This prevents you from accidentally deleting a KMS key by changing an immutable property value.

Select only one valid value.

Required: No

Type: String

Allowed values: ENCRYPT_DECRYPT | SIGN_VERIFY | GENERATE_VERIFY_MAC | KEY_AGREEMENT

Update requires: Replacement

MultiRegion

Creates a multi-Region primary key that you can replicate in other AWS Regions. You can't change theMultiRegion value after the KMS key is created.

For a list of AWS Regions in which multi-Region keys are supported, see Multi-Region keys in AWS KMS in the AWS Key Management Service Developer Guide.

Important

If you change the value of the MultiRegion property on an existing KMS key, the update request fails, regardless of the value of the UpdateReplacePolicy attribute. This prevents you from accidentally deleting a KMS key by changing an immutable property value.

For a multi-Region key, set to this property to true. For a single-Region key, omit this property or set it to false. The default value isfalse.

Multi-Region keys are an AWS KMS feature that lets you create multiple interoperable KMS keys in different AWS Regions. Because these KMS keys have the same key ID, key material, and other metadata, you can use them to encrypt data in one AWS Region and decrypt it in a different AWS Region without making a cross-Region call or exposing the plaintext data. For more information, seeMulti-Region keys in the AWS Key Management Service Developer Guide.

You can create a symmetric encryption, HMAC, or asymmetric multi-Region KMS key, and you can create a multi-Region key with imported key material. However, you cannot create a multi-Region key in a custom key store.

To create a replica of this primary key in a different AWS Region , create an AWS::KMS::ReplicaKey resource in a CloudFormation stack in the replica Region. Specify the key ARN of this primary key.

Required: No

Type: Boolean

Update requires: Replacement

Origin

The source of the key material for the KMS key. You cannot change the origin after you create the KMS key. The default is AWS_KMS, which means that AWS KMS creates the key material.

To create a KMS key with no key material (for imported key material), set this value to EXTERNAL. For more information about importing key material into AWS KMS, see Importing Key Material in the AWS Key Management Service Developer Guide.

You can ignore ENABLED when Origin is EXTERNAL. When a KMS key with Origin EXTERNAL is created, the key state is PENDING_IMPORT andENABLED is false. After you import the key material,ENABLED updated to true. The KMS key can then be used for Cryptographic Operations.

Note

AWS CloudFormation doesn't support creating an Origin parameter of theAWS_CLOUDHSM or EXTERNAL_KEY_STORE values.

Required: No

Type: String

Allowed values: AWS_KMS | EXTERNAL

Update requires: No interruption

PendingWindowInDays

Specifies the number of days in the waiting period before AWS 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, AWS KMS schedules the KMS key for deletion and starts the mandatory waiting period. The PendingWindowInDays 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, AWS KMS permanently deletes the KMS key.

AWS 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 toPendingDeletion and the waiting period specified byPendingWindowInDays begins. When this waiting period expires, AWS KMS deletes the primary key. For details, see Deleting multi-Region keys in the AWS Key Management Service 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 AWS 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_AWS Key Management Service Developer Guide_. For more information about deleting KMS keys, see the ScheduleKeyDeletion operation in the AWS Key Management Service API Reference and Deleting KMS keys in the AWS Key Management Service Developer Guide.

Required: No

Type: Integer

Minimum: 7

Maximum: 30

Update requires: No interruption

RotationPeriodInDays

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 AWS 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 AWS Key Management Service Developer Guide.

Required: No

Type: Integer

Minimum: 90

Maximum: 2560

Update requires: No interruption

Tags

Assigns one or more tags to the replica key.

Note

Tagging or untagging a KMS key can allow or deny permission to the KMS key. For details, seeABAC for AWS KMS in the AWS Key Management Service Developer Guide.

For information about tags in AWS KMS, see Tagging keys in the_AWS Key Management Service Developer Guide_. For information about tags in CloudFormation, see Tag.

Required: No

Type: Array of Tag

Update requires: No interruption

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the key ID, such as1234abcd-12ab-34cd-56ef-1234567890ab.

For more information about using the Ref function, see Ref.

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

Arn

The Amazon Resource Name (ARN) of the KMS key, such asarn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab.

For information about the key ARN of a KMS key, see Key ARN in the_AWS Key Management Service Developer Guide_.

KeyId

The key ID of the KMS key, such as1234abcd-12ab-34cd-56ef-1234567890ab.

For information about the key ID of a KMS key, see Key ID in the_AWS Key Management Service Developer Guide_.

Examples

Create a symmetric encryption KMS key

The following example creates a symmetric encryption KMS key. The key policy for the KMS key allows Alice to manage the key and allows Bob to view the KMS key and use it in cryptographic operations. It also allows the AWS account (root) full access to the key. This prevents you from losing control of the key if both Alice and Bob are deleted from the account.

JSON

"myKey": {
        "Type": "AWS::KMS::Key",
        "Properties": {
            "Description": "An example symmetric encryption KMS key",
            "EnableKeyRotation": true,
            "PendingWindowInDays": 20,
            "KeyPolicy": {
                "Version": "2012-10-17",
                "Id": "key-default-1",
                "Statement": [
                    {
                        "Sid": "Enable IAM User Permissions",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": "arn:aws:iam::111122223333:root"
                        },
                        "Action": "kms:*",
                        "Resource": "*"
                    },
                    {
                        "Sid": "Allow administration of the key",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": "arn:aws:iam::111122223333:user/Alice"
                        },
                        "Action": [
                            "kms:Create*",
                            "kms:Describe*",
                            "kms:Enable*",
                            "kms:List*",
                            "kms:Put*",
                            "kms:Update*",
                            "kms:Revoke*",
                            "kms:Disable*",
                            "kms:Get*",
                            "kms:Delete*",
                            "kms:ScheduleKeyDeletion",
                            "kms:CancelKeyDeletion"
                        ],
                        "Resource": "*"
                    },
                    {
                        "Sid": "Allow use of the key",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": "arn:aws:iam::111122223333:user/Bob"
                        },
                        "Action": [
                            "kms:DescribeKey",
                            "kms:Encrypt",
                            "kms:Decrypt",
                            "kms:ReEncrypt*",
                            "kms:GenerateDataKey",
                            "kms:GenerateDataKeyWithoutPlaintext"
                        ],
                        "Resource": "*"
                    }
                ]
            }
        }
    }

YAML

myKey:
  Type: 'AWS::KMS::Key'
  Properties:
    Description: An example symmetric encryption KMS key
    EnableKeyRotation: true
    PendingWindowInDays: 20
    KeyPolicy:
      Version: 2012-10-17
      Id: key-default-1
      Statement:
        - Sid: Enable IAM User Permissions
          Effect: Allow
          Principal:
            AWS: 'arn:aws:iam::111122223333:root'
          Action: 'kms:*'
          Resource: '*'
        - Sid: Allow administration of the key
          Effect: Allow
          Principal:
            AWS: 'arn:aws:iam::111122223333:user/Alice'
          Action:
            - 'kms:Create*'
            - 'kms:Describe*'
            - 'kms:Enable*'
            - 'kms:List*'
            - 'kms:Put*'
            - 'kms:Update*'
            - 'kms:Revoke*'
            - 'kms:Disable*'
            - 'kms:Get*'
            - 'kms:Delete*'
            - 'kms:ScheduleKeyDeletion'
            - 'kms:CancelKeyDeletion'
          Resource: '*'
        - Sid: Allow use of the key
          Effect: Allow
          Principal:
            AWS: 'arn:aws:iam::111122223333:user/Bob'
          Action:
            - 'kms:DescribeKey'
            - 'kms:Encrypt'
            - 'kms:Decrypt'
            - 'kms:ReEncrypt*'
            - 'kms:GenerateDataKey'
            - 'kms:GenerateDataKeyWithoutPlaintext'
          Resource: '*'

Create a symmetric encryption KMS key with a resource tag

The following example creates a symmetric encryption KMS key with one resource tag.

Note

Tagging or untagging a KMS key can allow or deny permission to the KMS key. For details, seeABAC for AWS KMS in the AWS Key Management Service Developer Guide.

JSON

"myKeyWithTag": {
        "Type": "AWS::KMS::Key",
        "Properties": {
            "KeyPolicy": {
                "Version": "2012-10-17",
                "Id": "key-default-1",
                "Statement": [
                    {
                        "Sid": "Enable IAM User Permissions",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": {
                                "Fn::Join": [
                                    "",
                                    [
                                        "arn:aws:iam::",
                                        {
                                            "Ref": "AWS::AccountId"
                                        },
                                        ":root"
                                    ]
                                ]
                            }
                        },
                        "Action": "kms:*",
                        "Resource": "*"
                    }
                ]
            },
            "Tags": [
                {
                    "Key": {
                        "Ref": "Key"
                    },
                    "Value": {
                        "Ref": "Value"
                    }
                }
            ]
        },
        "Parameters": {
            "Key": {
                "Type": "String"
            },
            "Value": {
                "Type": "String"
            }
        }
    }

YAML

myKeyWithTag:
  Type: 'AWS::KMS::Key'
  Properties:
    KeyPolicy:
      Version: 2012-10-17
      Id: key-default-1
      Statement:
        - Sid: Enable IAM User Permissions
          Effect: Allow
          Principal:
            AWS: !Join 
              - ''
              - - 'arn:aws:iam::'
                - !Ref 'AWS::AccountId'
                - ':root'
          Action: 'kms:*'
          Resource: '*'
    Tags:
      - Key: !Ref Key
        Value: !Ref Value
  Parameters:
    Key:
      Type: String
    Value:
      Type: String

Create an asymmetric KMS key

The following example creates an RSA asymmetric KMS key for signing and verification. For an asymmetric KMS key, you must specify KeySpec and KeyUsage properties. The EnableKeyRotation property must be omitted or set tofalse.

JSON

"RSASigningKey": {
        "Type": "AWS::KMS::Key",
        "Properties": {
            "Description": "RSA-3072 asymmetric KMS key for signing and verification",
            "KeySpec": "RSA_3072",
            "KeyUsage": "SIGN_VERIFY",
            "KeyPolicy": {
                "Version": "2012-10-17",
                "Id": "key-default-1",
                "Statement": [
                    {
                        "Sid": "Enable IAM User Permissions",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": "arn:aws:iam::111122223333:root"
                        },
                        "Action": "kms:*",
                        "Resource": "*"
                    },
                    {
                        "Sid": "Allow administration of the key",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": "arn:aws:iam::111122223333:role/Admin"
                        },
                        "Action": [
                            "kms:Create*",
                            "kms:Describe*",
                            "kms:Enable*",
                            "kms:List*",
                            "kms:Put*",
                            "kms:Update*",
                            "kms:Revoke*",
                            "kms:Disable*",
                            "kms:Get*",
                            "kms:Delete*",
                            "kms:ScheduleKeyDeletion",
                            "kms:CancelKeyDeletion"
                        ],
                        "Resource": "*"
                    },
                    {
                        "Sid": "Allow use of the key",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": "arn:aws:iam::111122223333:role/Developer"
                        },
                        "Action": [
                            "kms:Sign",
                            "kms:Verify",
                            "kms:DescribeKey"
                        ],
                        "Resource": "*"
                    }
                ]
            }
        }
    }

YAML

RSASigningKey:
  Type: 'AWS::KMS::Key'
  Properties:
    Description: RSA-3072 asymmetric KMS key for signing and verification
    KeySpec: RSA_3072
    KeyUsage: SIGN_VERIFY
    KeyPolicy:
      Version: 2012-10-17
      Id: key-default-1
      Statement:
        - Sid: Enable IAM User Permissions
          Effect: Allow
          Principal:
            AWS: 'arn:aws:iam::111122223333:root'
          Action: 'kms:*'
          Resource: '*'
        - Sid: Allow administration of the key
          Effect: Allow
          Principal:
            AWS: 'arn:aws:iam::111122223333:role/Admin'
          Action:
            - 'kms:Create*'
            - 'kms:Describe*'
            - 'kms:Enable*'
            - 'kms:List*'
            - 'kms:Put*'
            - 'kms:Update*'
            - 'kms:Revoke*'
            - 'kms:Disable*'
            - 'kms:Get*'
            - 'kms:Delete*'
            - 'kms:ScheduleKeyDeletion'
            - 'kms:CancelKeyDeletion'
          Resource: '*'
        - Sid: Allow use of the key
          Effect: Allow
          Principal:
            AWS: 'arn:aws:iam::111122223333:role/Developer'
          Action:
            - 'kms:Sign'
            - 'kms:Verify'
            - 'kms:DescribeKey'
          Resource: '*'

Create an HMAC KMS key

The following example creates an HMAC KMS key. For an HMAC KMS key, you must specify an HMAC KeySpec and the GENERATE_VERIFY_MAC value for the KeyUsage property. Omit the EnableKeyRotation property or it set tofalse.

JSON

{
    "HMACExampleKey": {
        "Type": "AWS::KMS::Key",
        "Properties": {
            "Description": "HMAC_384 key for tokens",
            "KeySpec": "HMAC_384",
            "KeyUsage": "GENERATE_VERIFY_MAC",
            "KeyPolicy": {
                "Version": "2012-10-17",
                "Id": "key-default-1",
                "Statement": [
                    {
                        "Sid": "Enable IAM User Permissions",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": "arn:aws:iam::111122223333:root"
                        },
                        "Action": "kms:*",
                        "Resource": "*"
                    },
                    {
                        "Sid": "Allow administration of the key",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": "arn:aws:iam::111122223333:role/Admin"
                        },
                        "Action": [
                            "kms:Create*",
                            "kms:Describe*",
                            "kms:Enable*",
                            "kms:List*",
                            "kms:Put*",
                            "kms:Update*",
                            "kms:Revoke*",
                            "kms:Disable*",
                            "kms:Get*",
                            "kms:Delete*",
                            "kms:ScheduleKeyDeletion",
                            "kms:CancelKeyDeletion"
                        ],
                        "Resource": "*"
                    },
                    {
                        "Sid": "Allow use of the key",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": "arn:aws:iam::111122223333:role/Developer"
                        },
                        "Action": [
                            "kms:GenerateMac",
                            "kms:VerifyMac",
                            "kms:DescribeKey"
                        ],
                        "Resource": "*"
                    }
                ]
            }
        }
    }
}

YAML

HMACExampleKey:
  Type: 'AWS::KMS::Key'
  Properties:
    Description: HMAC_384 key for tokens
    KeySpec: HMAC_384
    KeyUsage: GENERATE_VERIFY_MAC
    KeyPolicy:
      Version: 2012-10-17
      Id: key-default-1
      Statement:
        - Sid: Enable IAM User Permissions
          Effect: Allow
          Principal:
            AWS: 'arn:aws:iam::111122223333:root'
          Action: 'kms:*'
          Resource: '*'
        - Sid: Allow administration of the key
          Effect: Allow
          Principal:
            AWS: 'arn:aws:iam::111122223333:role/Admin'
          Action:
            - 'kms:Create*'
            - 'kms:Describe*'
            - 'kms:Enable*'
            - 'kms:List*'
            - 'kms:Put*'
            - 'kms:Update*'
            - 'kms:Revoke*'
            - 'kms:Disable*'
            - 'kms:Get*'
            - 'kms:Delete*'
            - 'kms:ScheduleKeyDeletion'
            - 'kms:CancelKeyDeletion'
          Resource: '*'
        - Sid: Allow use of the key
          Effect: Allow
          Principal:
            AWS: 'arn:aws:iam::111122223333:role/Developer'
          Action:
            - 'kms:GenerateMac'
            - 'kms:VerifyMac'
            - 'kms:DescribeKey'
          Resource: '*'

Create a multi-Region primary key

The following example creates a multi-Region primary key. This example key is a symmetric encryption KMS key, but you can create multi-Region versions of asymmetric KMS keys and HMAC KMS keys.

Multi-Region keys are an AWS KMS feature that lets you create multiple interoperable KMS keys in different AWS Regions. Because these KMS keys have the same key ID, key material, and other metadata, you can use them to encrypt data in one AWS Region and decrypt it in a different AWS Region without making a cross-Region call or exposing the plaintext data. For more information, see Multi-Region keys in the AWS Key Management Service Developer Guide.

To replicate this primary key into a different AWS Region, use the AWS::KMS::ReplicaKey CloudFormation resource.

JSON

"myPrimaryKey": {
        "Type": "AWS::KMS::Key",
        "Properties": {
            "Description": "An example multi-Region primary key",
            "MultiRegion": true,
            "EnableKeyRotation": true,
            "PendingWindowInDays": 10,
            "KeyPolicy": {
                "Version": "2012-10-17",
                "Id": "key-default-1",
                "Statement": [
                    {
                        "Sid": "Enable IAM User Permissions",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": "arn:aws:iam::111122223333:root"
                        },
                        "Action": "kms:*",
                        "Resource": "*"
                    },
                    {
                        "Sid": "Allow administration of the key",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": "arn:aws:iam::111122223333:user/Alice"
                        },
                        "Action": [
                            "kms:ReplicateKey",
                            "kms:Create*",
                            "kms:Describe*",
                            "kms:Enable*",
                            "kms:List*",
                            "kms:Put*",
                            "kms:Update*",
                            "kms:Revoke*",
                            "kms:Disable*",
                            "kms:Get*",
                            "kms:Delete*",
                            "kms:ScheduleKeyDeletion",
                            "kms:CancelKeyDeletion"
                        ],
                        "Resource": "*"
                    },
                    {
                        "Sid": "Allow use of the key",
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": "arn:aws:iam::111122223333:user/Bob"
                        },
                        "Action": [
                            "kms:DescribeKey",
                            "kms:Encrypt",
                            "kms:Decrypt",
                            "kms:ReEncrypt*",
                            "kms:GenerateDataKey",
                            "kms:GenerateDataKeyWithoutPlaintext"
                        ],
                        "Resource": "*"
                    }
                ]
            }
        }
    }

YAML

myPrimaryKey:
  Type: 'AWS::KMS::Key'
  Properties:
    Description: An example multi-Region primary key
    MultiRegion: true
    EnableKeyRotation: true
    PendingWindowInDays: 10
    KeyPolicy:
      Version: 2012-10-17
      Id: key-default-1
      Statement:
        - Sid: Enable IAM User Permissions
          Effect: Allow
          Principal:
            AWS: 'arn:aws:iam::111122223333:root'
          Action: 'kms:*'
          Resource: '*'
        - Sid: Allow administration of the key
          Effect: Allow
          Principal:
            AWS: 'arn:aws:iam::111122223333:user/Alice'
          Action:
            - 'kms:ReplicateKey'
            - 'kms:Create*'
            - 'kms:Describe*'
            - 'kms:Enable*'
            - 'kms:List*'
            - 'kms:Put*'
            - 'kms:Update*'
            - 'kms:Revoke*'
            - 'kms:Disable*'
            - 'kms:Get*'
            - 'kms:Delete*'
            - 'kms:ScheduleKeyDeletion'
            - 'kms:CancelKeyDeletion'
          Resource: '*'
        - Sid: Allow use of the key
          Effect: Allow
          Principal:
            AWS: 'arn:aws:iam::111122223333:user/Bob'
          Action:
            - 'kms:DescribeKey'
            - 'kms:Encrypt'
            - 'kms:Decrypt'
            - 'kms:ReEncrypt*'
            - 'kms:GenerateDataKey'
            - 'kms:GenerateDataKeyWithoutPlaintext'
          Resource: '*'

See also