Encrypting data groups in Amazon Aurora
Amazon Aurora encrypts a data group's data at rest on the server side, with no action from you. You can't turn encryption off for a data group. You choose which key encrypts it.
By default, a data group inherits the encryption setting of its DB cluster. If the DB cluster uses a customer managed key or an AWS managed key, Aurora uses that key for the data group. If the DB cluster uses an AWS owned key, Aurora uses that AWS owned key for the data group.
You can give a data group its own customer managed key instead, for example to control the key of one data group separately from the others.
Topics
How data groups use KMS keys
A data group's key encrypts the data group's data.
The following rules apply to data group keys:
-
You choose the key when you create the data group. You can't change it later.
-
If the DB cluster uses an AWS owned key, a data group created without its own key inherits that AWS owned key.
-
To put the data under a different key, restore the DB cluster and set a new key for the data group in the restore request. For more information, see Backing up and restoring DB clusters with data groups.
-
The default data group uses the DB cluster key.
When you restore a DB cluster, each data group keeps its key unless you set a different one:
-
A data group that has its own key keeps that key.
-
A data group that uses the DB cluster key uses the key of the restored DB cluster.
-
To use a different key, set
KmsKeyIdfor that data group in--data-group-restore-configurations. You can also setAdditionalEncryptionContextthere. If you don't, the restored data group keeps the encryption context entries that you added to the source data group. For more information about restoring a DB cluster with data groups, see Restoring a DB cluster with data groups.
To restore a data group that uses its own customer managed key, you need kms:DescribeKey and kms:CreateGrant on that key. For more information about the keys that a
restore needs, see Finding the data groups in a snapshot.
A data group supports symmetric encryption KMS keys only. Asymmetric keys and HMAC keys aren't supported.
Aurora checks your permissions on the KMS key each time you create or move a data group. The following table shows the permissions you need, depending on the operation and on which key the data group uses.
| Operation | Key the data group uses | Permissions you need | Why |
|---|---|---|---|
|
Create |
Its own KMS key |
|
Aurora creates a grant on that key, so that it can use the key on your behalf for the data group's data. |
|
Create |
The DB cluster KMS key |
|
Aurora confirms that you can use the DB cluster key for the new data group. Aurora doesn't create a grant for the data group. It uses the grants that it created on the DB cluster key when you created the DB cluster. |
|
Move |
Its own KMS key |
|
Aurora confirms that you can use the data group's key. |
|
Move |
The DB cluster KMS key |
|
Aurora confirms that you can use both DB cluster keys. |
The StorageEncryptionType field in the describe-data-groups output shows how the data group is
encrypted:
-
sse-kms– The data group is encrypted with a KMS key, either its own key or the DB cluster key. -
sse-rds– The data group is encrypted with an AWS owned key.
Creating a data group with its own KMS key
You can use the AWS Management Console or AWS CLI to create a data group with its own KMS key. To create the data group, you need the following permissions on that key:
-
kms:DescribeKey– To read the key's metadata. Aurora resolves the key that you name to its key ARN and confirms that the key exists. -
kms:CreateGrant– To create the grant that lets Aurora use the key on your behalf for the data group's data.
Follow the console procedure in Creating a data group. On the Data encryption step, choose your customer managed key.
Use the create-data-group AWS CLI command with the following parameters:
-
--kms-key-id– The key ID or ARN of the KMS key. In the Amazon RDS API, this is theKMSKeyIdparameter of theCreateDataGroupoperation. -
--additional-encryption-context– (Optional) Key-value pairs that Aurora adds to the encryption context for this data group. You can supply this parameter only when you also supply--kms-key-id. A data group that uses the DB cluster key doesn't accept it. In the Amazon RDS API, this is theAdditionalEncryptionContextparameter.
The following example creates a data group with its own key and an extra encryption context.
aws rds create-data-group \ --db-cluster-identifierorders-cluster-1\ --data-group-nametenant57\ --kms-key-idarn:aws:kms:us-east-1:111122223333:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222\ --additional-encryption-context '{"tenant":"57"}'
The output resembles the following example.
{ "DBClusterIdentifier": "orders-cluster-1", "DataGroupName": "tenant57", "DataGroupIdentifier": "dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "DataGroupArn": "arn:aws:rds:us-east-1:111122223333:data-group:dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "KMSKeyId": "arn:aws:kms:us-east-1:111122223333:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "AdditionalEncryptionContext": { "tenant": "57" }, "StorageEncryptionType": "sse-kms", "Status": "creating", "CreateTime": "2026-11-24T18:15:40.208Z" }
When you create the data group, Aurora creates grants on the KMS key. The grants let Aurora encrypt and decrypt the data group's data on your behalf. The data group's encryption context constrains the grants, so they apply to this data group only.
What happens to the key during a move
What happens to the key during a move depends on the key that the data group uses:
-
Its own key – The data group keeps the same key on the target DB cluster.
-
The DB cluster key – After the move, the target DB cluster key encrypts the data group. Aurora uses envelope encryption, so the move doesn't re-encrypt the data group's data. For more information, see Envelope encryption in the AWS Key Management Service Developer Guide.
When a data group key becomes inaccessible
After a data group's status becomes inaccessible-encryption-credentials, enabling its key again doesn't make
the data group available. To get the data back, enable the key and restore the DB cluster from a snapshot or to a point in
time.
If Aurora can't use a data group's own key, for example because you disable the key or revoke a grant on it, only the data groups that use that key are affected:
-
Their status becomes
inaccessible-encryption-credentials, and their data can't be read. -
Aurora sends event RDS-EVENT-0538 for each one.
-
Other data groups in the DB cluster stay online.
Aurora checks that it can still use the KMS key about every 30 minutes. After you disable the key or revoke a grant that Aurora created on it, the data group typically becomes inaccessible within an hour.
You can't move a data group in the inaccessible-encryption-credentials status. For more information about
restoring the DB cluster, see Restoring a DB cluster with data groups.
You can delete a data group in this state. Deleting it deletes its data, and you can't recover that data from the data group afterward.
If the DB cluster key becomes inaccessible, every data group in the DB cluster becomes inaccessible, including data groups that have their own key.
Encryption context
Aurora uses an encryption context on the cryptographic operations that it performs for a data group. The encryption context identifies the data group that the operation belongs to.
A data group with its own KMS key
Aurora sets the following encryption context entry. You can't change or remove it.
aws:rds:dg-id-
The identifier of the data group, such as
dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE22222. This is theDataGroupIdentifiervalue thatcreate-data-groupreturns, and the last part of the data group ARN.
The encryption context also constrains the grants that Aurora creates on the key, so those grants apply to that data group
only. You can add your own entries with --additional-encryption-context. Entry names that begin with
aws: are reserved for AWS services. Don't use them for your own entries. To use the encryption context in a key
policy, see Scoping down access to your KMS key for a data group.
A data group that uses the DB cluster key
Aurora uses the grants that it created on the DB cluster key when you created the DB cluster. Those grants already require the
aws:rds:dbc-id entry, which is the resource ID of the DB cluster, such as cluster-123ABCEXAMPLE. For a data
group, Aurora adds the aws:rds:dg-id entry to that encryption context. If the key policy of your DB cluster key has
conditions on the encryption context, make sure that they allow the additional aws:rds:dg-id entry.
Aurora might add encryption context entries in the future. Write your key policies so that they continue to work when it does. Condition on the individual entries that you care about rather than requiring an exact match on the whole encryption context.
Scoping down access to your KMS key for a data group
When you give a data group its own KMS key, the key policy must let the user who creates the data group read the key's metadata and create a grant on the key. AWS recommends that you scope those permissions down.
Use the kms:ViaService condition key with the value
rds.. With this condition, the statement applies only to requests that
Aurora makes on your behalf. It doesn't apply to requests that a principal makes directly to AWS KMS. Other statements in the key policy or in
IAM policies can still allow other use of the key. For more information, see kms:ViaService in the AWS Key Management Service Developer Guide.region.amazonaws.com
With the following JSON key policy, the DataGroupAdmin role can use this key to create and move data groups through Aurora, and can create only grants for the operations that Aurora needs. The
first statement is the default key policy statement that gives your account access to the key and enables IAM policies for it.
Keep it. Without it, the key can become unmanageable. For more information, see Allows access to the AWS
account and enables IAM policies in the AWS Key Management Service Developer Guide.
{ "Version": "2012-10-17", "Id": "key-policy-aurora-data-group", "Statement": [ { "Sid": "EnableIAMUserPermissions", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:root" }, "Action": "kms:*", "Resource": "*" }, { "Sid": "AllowDescribeAndDecryptThroughAurora", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:role/DataGroupAdmin" }, "Action": [ "kms:DescribeKey", "kms:Decrypt" ], "Resource": "*", "Condition": { "StringEquals": { "kms:ViaService": "rds.us-east-1.amazonaws.com" } } }, { "Sid": "AllowDataGroupGrantsThroughAurora", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:role/DataGroupAdmin" }, "Action": "kms:CreateGrant", "Resource": "*", "Condition": { "StringEquals": { "kms:ViaService": "rds.us-east-1.amazonaws.com", "kms:GrantConstraintType": "EncryptionContextSubset" }, "StringLike": { "kms:EncryptionContext:aws:rds:dg-id": "dg-*" }, "ForAllValues:StringEquals": { "kms:GrantOperations": [ "Encrypt", "Decrypt", "GenerateDataKey", "DescribeKey", "CreateGrant" ] } } } ] }
In this policy, replace the following values:
-
111122223333– Your AWS account ID. -
DataGroupAdmin– The name of the IAM role that creates data groups. -
us-east-1– The AWS Region of your DB cluster.
When you create or move a data group, Aurora calls AWS KMS with your permissions. Creating the data group needs kms:DescribeKey
and kms:CreateGrant. Moving it needs kms:DescribeKey and kms:Decrypt. The kms:ViaService condition keeps those
permissions from being used for requests that don't come through Aurora. The grants that Aurora creates are constrained by the data
group's encryption context, so they apply to that data group only. For more information about the cross-service confused deputy
problem, see Preventing cross-service confused deputy problems.
The grant that Aurora creates on the key allows the Encrypt, Decrypt,
GenerateDataKey, DescribeKey, and CreateGrant operations. The
kms:GrantOperations condition must list all of them. If it leaves one out, AWS KMS denies the grant request,
and Aurora doesn't create the data group.
The kms:GrantConstraintType and kms:EncryptionContext:aws:rds:dg-id conditions allow only
grants that are constrained to a data group's encryption context. Aurora assigns the data group identifier when it creates
the data group. You can't name a specific identifier in the policy before then, so the dg-* pattern matches
any data group identifier.
To narrow the policy further, add a condition on an encryption context entry that you set yourself with
--additional-encryption-context. For example, a condition on
kms:EncryptionContext:tenant in the AllowDataGroupGrantsThroughAurora statement limits the key to data groups that you create with that entry. Don't add it to the AllowDescribeAndDecryptThroughAurora statement, because DescribeKey requests don't carry an encryption context. Don't condition on an
exact match of the whole encryption context, because Aurora might add entries to it in the future.
The role also needs an IAM policy that allows the same AWS KMS permissions. The following JSON policy allows them on one key, only through Aurora. It grants only the AWS KMS permissions. The role also needs permission to create data groups.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowDescribeAndDecryptDataGroupKeyThroughAurora", "Effect": "Allow", "Action": [ "kms:DescribeKey", "kms:Decrypt" ], "Resource": "arn:aws:kms:us-east-1:111122223333:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "Condition": { "StringEquals": { "kms:ViaService": "rds.us-east-1.amazonaws.com" } } }, { "Sid": "AllowDataGroupGrantsThroughAurora", "Effect": "Allow", "Action": "kms:CreateGrant", "Resource": "arn:aws:kms:us-east-1:111122223333:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "Condition": { "StringEquals": { "kms:ViaService": "rds.us-east-1.amazonaws.com", "kms:GrantConstraintType": "EncryptionContextSubset" }, "StringLike": { "kms:EncryptionContext:aws:rds:dg-id": "dg-*" }, "ForAllValues:StringEquals": { "kms:GrantOperations": [ "Encrypt", "Decrypt", "GenerateDataKey", "DescribeKey", "CreateGrant" ] } } } ] }
In this policy, replace 111122223333 and us-east-1 as in the
key policy, and replace a1b2c3d4-5678-90ab-cdef-EXAMPLE22222 with the ID of your KMS key.
The kms:CreateGrant statement has the same conditions as the
AllowDataGroupGrantsThroughAurora statement in the key policy. The key policy's default statement lets IAM
policies allow access to the key. Without the same conditions, this IAM policy would allow grants that the key policy's
conditions don't. kms:DescribeKey and kms:Decrypt are in a separate statement because DescribeKey
requests don't carry an encryption context. If you add a condition on your own encryption context entry, add it to the
kms:CreateGrant statement in both policies.
Monitoring use of a KMS key in a data group
CloudTrail records the AWS KMS operations that Aurora performs on a data group's own KMS key. You can use these entries to audit when
and how the key is used. Encrypt, Decrypt, and CreateGrant entries carry the data group's
encryption context, so you can find the entries for one data group by its aws:rds:dg-id value.
Expect the following events in CloudTrail.
DescribeKey-
When you create the data group, to confirm that the key exists.
CreateGrant-
When you create the data group. You see two of these events, one for each grant. The encryption context appears under
constraints.encryptionContextSubset. Encrypt-
When Aurora uses the key to protect the data group's data, and when it checks that it can still use the key.
RetireGrant-
When you delete the data group.
Decrypt-
When Aurora uses the key to read and write the data group's data, and before a move.
The following example shows the fields of an Encrypt event that identify the key and the data group.
{ "eventSource": "kms.amazonaws.com", "eventName": "Encrypt", "awsRegion": "us-east-1", "requestParameters": { "keyId": "arn:aws:kms:us-east-1:111122223333:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "encryptionAlgorithm": "SYMMETRIC_DEFAULT", "encryptionContext": { "aws:rds:dg-id": "dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "tenant": "57" } }, "resources": [ { "accountId": "111122223333", "type": "AWS::KMS::Key", "ARN": "arn:aws:kms:us-east-1:111122223333:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE22222" } ] }
For more information about reading these entries, see Monitoring AWS KMS keys.