I Tried Sharing AWS KMS Keys Across an Organization Using AWS RAM

I Tried Sharing AWS KMS Keys Across an Organization Using AWS RAM

AWS KMS keys can now be shared through AWS RAM. I shared a symmetric encryption key with an Organization and confirmed that member accounts could Encrypt and Decrypt without changing the default key policy.
2026.11.18

This page has been translated by machine translation. View original

Introduction

On 2026-11-16, AWS KMS added support for key sharing through AWS RAM.

https://aws.amazon.com/jp/about-aws/whats-new/2026/11/kms-key-sharing-resource-access-manager/

By adding a key to a RAM resource share, you can share the key with other accounts without manually editing the key policy. In this article, I used two member accounts in the same Organization, shared a symmetric encryption key from the owner account with the Organization, and tried encryption and decryption in the receiving account.

Prerequisites

Accounts and environment

  • The Region is ap-northeast-1, and the aws-cli version is 2.40.3
  • The owner account (111122223333) and the receiving account (444455556666) are members of the same Organization (feature set ALL)
  • The key to be shared is a symmetric encryption customer managed key (KeySpec is SYMMETRIC_DEFAULT)
  • The management account (123456789012) is used to enable sharing within the Organization
  • AdministratorAccess is attached to the role on the receiving side

Enabling RAM sharing with the Organization

Before creating a resource share targeting the Organization, enable RAM sharing with the Organization in the management account. After enabling it, I confirmed that ram.amazonaws.com was included in the list of services with trusted access enabled.

aws ram enable-sharing-with-aws-organization
{
    "returnValue": true
}
aws organizations list-aws-service-access-for-organization \
  --query "EnabledServicePrincipals[?ServicePrincipal=='ram.amazonaws.com']"
[
    {
        "ServicePrincipal": "ram.amazonaws.com",
        "DateEnabled": "2026-11-18T01:49:02.549000+09:00"
    }
]

Permissions required for sharing

According to the KMS Developer Guide, the principal performing the sharing needs the RAM permission ram:CreateResourceShare. To add a key to an existing resource share, ram:AssociateResourceShare is required. In addition, kms:PutKeyPolicy is required on the target key, and RAM uses this permission to create and update the AWS_RAM key policy.

https://docs.aws.amazon.com/kms/latest/developerguide/key-sharing-ram.html

Sharing the key

Choosing a managed permission

For a resource share, you specify one managed permission (RAM managed permission) for the key. You can list the managed permissions for kms:Key with the following command.

aws ram list-permissions --resource-type kms:Key

Two managed permissions are listed. You can retrieve the contents of each with get-permission.

aws ram get-permission \
  --permission-arn arn:aws:ram::aws:permission/AWSRAMPermissionKMSKeySymmetricEncryption

aws ram get-permission \
  --permission-arn arn:aws:ram::aws:permission/AWSRAMPermissionKMSKeyLockoutResistant

The two managed permissions allow the following.

Managed permission Allowed actions Condition
AWSRAMPermissionKMSKeySymmetricEncryption (default for kms:Key) kms:Encrypt, kms:Decrypt, kms:ReEncrypt*, kms:GenerateDataKey*, kms:DescribeKey, kms:ListGrants, kms:CreateGrant Only for kms:CreateGrant, when kms:GrantIsForAWSResource is true
AWSRAMPermissionKMSKeyLockoutResistant kms:DescribeKey, kms:GetKeyPolicy, kms:List*, kms:PutKeyPolicy When the caller is the root of the owner account

Since we want to perform encryption and decryption on the receiving side, we use the default AWSRAMPermissionKMSKeySymmetricEncryption.

Creating the resource share

In the owner account, specify the key to share by its key ARN and the recipient by the Organization ARN. Create the resource share in the same Region as the key.

aws ram create-resource-share \
  --name devio-kms-share-verify-1118 \
  --resource-arns arn:aws:kms:ap-northeast-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab \
  --principals arn:aws:organizations::123456789012:organization/o-exampleorgid \
  --permission-arns arn:aws:ram::aws:permission/AWSRAMPermissionKMSKeySymmetricEncryption
{
    "resourceShare": {
        "resourceShareArn": "arn:aws:ram:ap-northeast-1:111122223333:resource-share/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
        "name": "devio-kms-share-verify-1118",
        "owningAccountId": "111122223333",
        "allowExternalPrincipals": true,
        "status": "ACTIVE",
        "tags": [],
        "creationTime": "2026-11-18T01:49:15.260000+09:00",
        "lastUpdatedTime": "2026-11-18T01:49:15.260000+09:00",
        "resourceShareConfiguration": {
            "retainSharingOnAccountLeaveOrganization": false
        }
    }
}

Key policies after sharing

List of key policies

I ran list-key-policies in the owner account before and after sharing, and after sharing a key policy named AWS_RAM had been added.

aws kms list-key-policies --key-id 1234abcd-12ab-34cd-56ef-1234567890ab

This is the output before sharing.

{
    "PolicyNames": [
        "default"
    ]
}

This is the output after sharing.

{
    "PolicyNames": [
        "AWS_RAM",
        "default"
    ]
}

The default key policy

The default key policy before sharing is as follows. get-key-policy returns Policy as a string, so it is shown here in formatted form.

aws kms get-key-policy \
  --key-id 1234abcd-12ab-34cd-56ef-1234567890ab \
  --policy-name default \
  --output json
{
  "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": "*"
    }
  ]
}

I compared the output of the same command after sharing with the output before sharing using diff, and there was no difference.

The AWS_RAM key policy

Retrieve the AWS_RAM key policy that was added after sharing.

aws kms get-key-policy \
  --key-id 1234abcd-12ab-34cd-56ef-1234567890ab \
  --policy-name AWS_RAM \
  --output json

The formatted Policy is as follows.

{
  "Version": "2012-10-17",
  "Id": "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222",
  "Statement": [
    {
      "Sid": "AWSRAMPermissionKMSKeySymmetricEncryption-org",
      "Effect": "Allow",
      "Principal": "*",
      "Action": [
        "kms:Encrypt",
        "kms:Decrypt",
        "kms:ReEncrypt*",
        "kms:GenerateDataKey*",
        "kms:DescribeKey",
        "kms:ListGrants"
      ],
      "Resource": "arn:aws:kms:ap-northeast-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
      "Condition": {
        "StringEquals": {
          "aws:PrincipalOrgID": "o-exampleorgid"
        },
        "StringNotEquals": {
          "aws:PrincipalAccount": "111122223333"
        }
      }
    },
    {
      "Sid": "AWSRAMPermissionKMSKeySymmetricEncryption-org",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "kms:CreateGrant",
      "Resource": "arn:aws:kms:ap-northeast-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
      "Condition": {
        "StringEquals": {
          "aws:PrincipalOrgID": "o-exampleorgid"
        },
        "Bool": {
          "kms:GrantIsForAWSResource": "true"
        },
        "StringNotEquals": {
          "aws:PrincipalAccount": "111122223333"
        }
      }
    }
  ]
}

Principal is *, but because of the conditions, the allowed targets are accounts in the Organization other than the owner account.

The AWS_RAM key policy is managed by RAM and users cannot create, modify, or delete it, so you adjust the scope in which the key can be used by changing the resource share.

Usage on the receiving side

Whether an invitation exists

When I checked for resource share invitations in the receiving account, there were 0. Without performing any acceptance operation, Encrypt and Decrypt in the next section succeeded.

aws ram get-resource-share-invitations --output json
{
    "resourceShareInvitations": []
}

Encrypt and Decrypt

From the role in the receiving account, I ran Encrypt and Decrypt specifying the key ARN. For the plaintext, I used plaintext.txt, into which I wrote hello from receiver without a trailing newline.

aws kms encrypt \
  --key-id arn:aws:kms:ap-northeast-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab \
  --plaintext fileb://plaintext.txt \
  --output json

The CiphertextBlob line is omitted because its value changes with every execution.

{
    "KeyId": "arn:aws:kms:ap-northeast-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
    "EncryptionAlgorithm": "SYMMETRIC_DEFAULT"
}

For Decrypt, I decode the CiphertextBlob (Base64) returned by Encrypt with base64 -d, save it to the binary file ct.bin, and pass it. When you specify fileb://, the AWS CLI reads the file contents as binary as-is.

aws kms decrypt \
  --ciphertext-blob fileb://ct.bin \
  --key-id arn:aws:kms:ap-northeast-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab \
  --output json

The KeyMaterialId line is omitted because it is an environment-specific identifier.

{
    "KeyId": "arn:aws:kms:ap-northeast-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
    "Plaintext": "aGVsbG8gZnJvbSByZWNlaXZlcg==",
    "EncryptionAlgorithm": "SYMMETRIC_DEFAULT"
}

Decoding the Base64 of Plaintext gives hello from receiver, which matched the plaintext passed to Encrypt.

For the receiving side to use the key, in addition to the permission in the key policy, you need to grant permission to the users or roles that will use it through an IAM policy in the receiving account. Specify the key ARN in the Resource of the IAM policy.

The first Encrypt, executed about 18 seconds after creating the share, succeeded. Because creating, changing, and deleting shares are eventually consistent, it may take a little time for changes to take effect.

Removing the share

Before scheduling deletion of a shared key, you are advised to remove the key from the resource share. To remove only the key, specify the key ARN with disassociate-resource-share. The resource share itself remains, so other resources in the same resource share and the recipients are not affected.

aws ram disassociate-resource-share \
  --resource-share-arn arn:aws:ram:ap-northeast-1:111122223333:resource-share/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
  --resource-arns arn:aws:kms:ap-northeast-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
{
    "resourceShareAssociations": [
        {
            "resourceShareArn": "arn:aws:ram:ap-northeast-1:111122223333:resource-share/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
            "associatedEntity": "arn:aws:kms:ap-northeast-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
            "associationType": "RESOURCE",
            "status": "DISASSOCIATING",
            "external": false
        }
    ]
}

The removal process is asynchronous, and the status immediately afterward is DISASSOCIATING. Use get-resource-share-associations to confirm that it has become DISASSOCIATED. The resourceShareName, creationTime, and lastUpdatedTime lines are omitted.

aws ram get-resource-share-associations \
  --association-type RESOURCE \
  --resource-share-arns arn:aws:ram:ap-northeast-1:111122223333:resource-share/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111
{
    "resourceShareAssociations": [
        {
            "resourceShareArn": "arn:aws:ram:ap-northeast-1:111122223333:resource-share/a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
            "associatedEntity": "arn:aws:kms:ap-northeast-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
            "associationType": "RESOURCE",
            "status": "DISASSOCIATED",
            "external": false
        }
    ]
}

After removal, the key policies were only default, and AWS_RAM was gone.

aws kms list-key-policies --key-id 1234abcd-12ab-34cd-56ef-1234567890ab
{
    "PolicyNames": [
        "default"
    ]
}

Summary

I confirmed that AWS KMS now supports key sharing through AWS RAM and that customer managed keys can be shared between different accounts.

With key policies, you had to write statements for the recipients, but with RAM you can share simply by specifying the managed permission and the recipients in a resource share, which reduces the effort of managing permissions.
If multiple accounts use the same customer managed key, or if you encrypt resources to be replicated with a common customer managed key, please try sharing via RAM as an alternative to editing the key policy.

Share this article

AWSのお困り事はクラスメソッドへ