Security for integrations with Amazon S3 Tables
This is preview documentation for the Aurora PostgreSQL integration with Amazon S3
Tables. Before using this capability, review the Betas and Previews terms in
the AWS Service
Terms
Security for an Aurora PostgreSQL integration with Amazon S3 Tables covers how the replicated data is encrypted and which permissions the integration needs on the target table bucket. It also covers how you control access to the replicated tables. You control access to the replicated tables with AWS Identity and Access Management (IAM), separately from your Aurora database permissions.
Topics
Data protection and encryption
An integration encrypts data with an AWS owned key or a customer managed AWS Key Management Service (AWS KMS) key. If you use AWS owned keys, you don't need a key policy. If you use customer managed keys, each key policy must allow the integration to use the key. Up to three keys can be involved:
-
The key that encrypts the integration.
-
The key of the source DB cluster.
-
The key of the target table bucket.
Topics
Customer managed key for the integration
When you create an integration with a customer managed key
(--kms-key-id), Amazon RDS creates grants on the key with the
credentials of the identity that calls create-integration. For the
option, see Encrypting the integration with a customer managed key.
Add the statements from the following examples to the Statement
array of a single key policy for the integration key. Include the key administration
and key use statements. The deny statements are optional. Replace
111122223333 with your AWS account ID.
- Key administration
-
This statement lets identities in your account administer the key. It deliberately doesn't allow
kms:CreateGrant,kms:DescribeKey, or any cryptographic operation.{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowKeyAdministration", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:root" }, "Action": [ "kms:GetKeyPolicy", "kms:PutKeyPolicy", "kms:ListGrants", "kms:ListResourceTags", "kms:RevokeGrant", "kms:RetireGrant", "kms:EnableKey", "kms:DisableKey", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription", "kms:ScheduleKeyDeletion", "kms:CancelKeyDeletion" ], "Resource": "*" } ] } - Key use through Amazon RDS
-
These statements let your account call
kms:CreateGrantandkms:DescribeKeyon the key only through Amazon RDS (kms:ViaServicematches*rds*). They don't name a service principal. Thekms:GrantOperationslist limits the grants that Amazon RDS can create to the operations that the integration uses. The*rds*pattern matches anykms:ViaServicevalue that containsrds. Published Aurora key policy examples use the narrower valuerds..aws-region.amazonaws.com{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowRDSZeroEtlCreateGrantOnIntegrationKey", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:root" }, "Action": "kms:CreateGrant", "Resource": "*", "Condition": { "Bool": { "kms:GrantIsForAWSResource": "true" }, "StringLike": { "kms:ViaService": "*rds*" }, "ForAllValues:StringEquals": { "kms:GrantOperations": [ "Decrypt", "GenerateDataKey", "GenerateDataKeyWithoutPlaintext", "CreateGrant", "DescribeKey" ] } } }, { "Sid": "AllowRDSZeroEtlDescribeIntegrationKey", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:root" }, "Action": "kms:DescribeKey", "Resource": "*", "Condition": { "StringLike": { "kms:ViaService": "*rds*" } } } ] } - Optional deny statements
-
To limit access further, you can add the following statements. The first statement denies requests that AWS services make on your behalf, called forward access sessions (FAS), unless they come through a service that is integrated with AWS KMS (
kms:ViaService). The second statement denies requests from principals outside your account that aren't AWS services.{ "Version": "2012-10-17", "Statement": [ { "Sid": "DenyFASRequestsWithoutViaService", "Effect": "Deny", "Principal": "*", "Action": "kms:*", "Resource": "*", "Condition": { "Bool": { "aws:ViaAWSService": "true" }, "Null": { "kms:ViaService": "true" } } }, { "Sid": "DenyCrossAccountAccessExceptViaAWSService", "Effect": "Deny", "Principal": "*", "Action": "kms:*", "Resource": "*", "Condition": { "StringNotEquals": { "aws:PrincipalAccount": "${aws:ResourceAccount}" }, "Bool": { "aws:PrincipalIsAWSService": "false" } } } ] }
If the key policy denies the caller's use of the key through Amazon RDS,
create-integration fails with
KMSKeyNotAccessibleFault. The error message includes the key's Amazon
Resource Name (ARN).
- Grants on the integration key
-
When you create the integration, Amazon RDS creates three named grants on the key:
-
zero-etl-s3t-staging-source- -
zero-etl-s3t-staging-target- -
zero-etl-s3t-ebs-
While the integration is active, more grants appear on the key. Each of them requests only operations from the
kms:GrantOperationslist in the key policy:Decrypt,GenerateDataKey,GenerateDataKeyWithoutPlaintext,CreateGrant, andDescribeKey.Only the
zero-etl-s3t-staging-source-grant has an encryption context constraint:aws:servicename:id=s3tablesandaws:s3tables:integration:arn= the integration ARN. The other two named grants have no constraint. When you delete the integration, Amazon RDS removes the three named grants from the key. -
- Revoking grants
-
If you revoke all of the integration's grants on the key while the integration is active, the integration enters the
failedstatus. For more information, see My integration has a status of failed.
Customer managed key for the source DB cluster
If your source DB cluster is encrypted with a customer managed key,
create-integration checks that the caller can use that key:
kms:DescribeKey, a kms:Decrypt dry run, and
kms:CreateGrant. The following key policy works with an integration. Replace 111122223333 with your AWS
account ID, and
cluster-ABCDEFGHIJKL0123456789 with the resource ID
of your DB cluster (DbClusterResourceId).
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowKeyAdministration", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:root" }, "Action": [ "kms:GetKeyPolicy", "kms:PutKeyPolicy", "kms:ListGrants", "kms:ListResourceTags", "kms:RevokeGrant", "kms:RetireGrant", "kms:EnableKey", "kms:DisableKey", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription", "kms:ScheduleKeyDeletion", "kms:CancelKeyDeletion" ], "Resource": "*" }, { "Sid": "AllowRDSZeroEtlDescribeSourceClusterKey", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:root" }, "Action": "kms:DescribeKey", "Resource": "*", "Condition": { "StringLike": { "kms:ViaService": "*rds*" } } }, { "Sid": "AllowRDSZeroEtlDecryptWithSourceClusterKey", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:root" }, "Action": "kms:Decrypt", "Resource": "*", "Condition": { "StringLike": { "kms:ViaService": "*rds*" }, "StringEquals": { "kms:EncryptionContext:aws:rds:dbc-id": "cluster-ABCDEFGHIJKL0123456789" } } }, { "Sid": "AllowRDSZeroEtlCreateGrantOnSourceClusterKey", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:root" }, "Action": "kms:CreateGrant", "Resource": "*", "Condition": { "Bool": { "kms:GrantIsForAWSResource": "true" }, "StringLike": { "kms:ViaService": "*rds*" }, "ForAllValues:StringEquals": { "kms:GrantOperations": [ "Encrypt", "Decrypt", "GenerateDataKey", "GenerateDataKeyWithoutPlaintext", "ReEncryptFrom", "ReEncryptTo", "CreateGrant", "DescribeKey", "RetireGrant" ] } } } ] }
- Grant on the source cluster key
-
When you create the integration, Amazon RDS creates the following grant on the source cluster key. During a full sync, more grants appear on the key, and Amazon RDS retires them when the full sync finishes. When you delete the integration, Amazon RDS removes the grant.
The following table describes the grant.
Grant name Operations Encryption context constraint CustomerId:…:DbClusterResourceId:…:IntegrationId:…:ExportSourceKeyEncrypt,Decrypt,GenerateDataKey,GenerateDataKeyWithoutPlaintext,ReEncryptFrom,ReEncryptTo,CreateGrant,DescribeKey,RetireGrantNone The
kms:GrantOperationslist in theAllowRDSZeroEtlCreateGrantOnSourceClusterKeystatement contains exactly these operations.
Customer managed key for the target table bucket
Your target table bucket can use server-side encryption with AWS KMS keys (SSE-KMS) with a customer managed key. In that case, the key policy must allow Amazon S3 Tables maintenance and the integration to use the key. The following key policy works with an integration. Replace the values as follows:
-
In
AllowKeyAdministrationandEnableAccountRoot, use the ID of the account that owns the key. -
In
aws:SourceArn, use the ARN of your source DB cluster. The ARN contains the ID of the account that owns the source DB cluster.
If the source DB cluster, the table bucket, and the key are in one account, every value uses the same account ID.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowKeyAdministration", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:root" }, "Action": [ "kms:GetKeyPolicy", "kms:PutKeyPolicy", "kms:ListGrants", "kms:ListResourceTags", "kms:RevokeGrant", "kms:RetireGrant", "kms:EnableKey", "kms:DisableKey", "kms:TagResource", "kms:UntagResource", "kms:UpdateKeyDescription", "kms:ScheduleKeyDeletion", "kms:CancelKeyDeletion" ], "Resource": "*" }, { "Sid": "EnableAccountRoot", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::111122223333:root" }, "Action": ["kms:Decrypt", "kms:GenerateDataKey", "kms:DescribeKey"], "Resource": "*" }, { "Sid": "EnableS3TablesMaintenance", "Effect": "Allow", "Principal": { "Service": "maintenance.s3tables.amazonaws.com" }, "Action": ["kms:GenerateDataKey", "kms:Decrypt"], "Resource": "*" }, { "Sid": "AllowZeroEtlServicePrincipalsForSourceCluster", "Effect": "Allow", "Principal": { "Service": ["export.rds.amazonaws.com"] }, "Action": ["kms:GenerateDataKey", "kms:Decrypt", "kms:DescribeKey"], "Resource": "*", "Condition": { "ArnEquals": { "aws:SourceArn": "arn:aws:rds:aws-region:111122223333:cluster:my-source-cluster" } } } ] }
The EnableAccountRoot statement lets IAM policies in your account
grant use of the key, for example kms:Decrypt and
kms:GenerateDataKey for the principals that query the tables.
Without it, IAM policies that allow access to the key have no effect. For more
information, see Allows access to the AWS account and enables IAM policies in the
AWS Key Management Service Developer Guide. In IAM policies, grant
kms:Decrypt and kms:GenerateDataKey on the key only to
the principals that need to query the tables.
With this policy, the tables from the initial full sync and the tables that the
integration creates later are encrypted with the table bucket key. The aws:SourceArn
condition names the source DB cluster. A Deny statement for
kms:GenerateDataKey and kms:Decrypt with the same
aws:SourceArn condition makes the integration enter the
failed status.
Identity and access management
You do not create or attach an IAM role for the integration. The integration reaches your resources as follows:
-
Integration key: Through grants that Amazon RDS creates on the key when you create the integration. For more information, see Customer managed key for the integration.
-
Target table bucket: Through the table bucket resource policy, which allows the service principal
export.rds.amazonaws.com. For the policy, see Creating the table bucket and resource policy. -
Table bucket key: If the table bucket uses SSE-KMS with a customer managed key, through the key policy. For more information, see Customer managed key for the target table bucket.
For the permissions that the identity that creates the integration needs, see Required permissions.
Table bucket resource policy
The resource policy of the target table bucket must allow the integration's service
principal, export.rds.amazonaws.com, to act on the table bucket and its
tables. The integration's requests to the table bucket carry the ARN of the source DB cluster
as aws:SourceArn and the cluster's account as
aws:SourceAccount. With these condition keys, the policy can limit the
service principal to integrations from one source DB cluster. For the policy and the steps to
attach it, see Creating the table bucket and resource policy.
Table bucket resource policies accept only s3tables: actions. A
Deny statement for the service principal with the same
aws:SourceArn condition makes create-integration fail for
that source DB cluster.
Cross-account access
The source DB cluster and the target table bucket can be in different AWS accounts if
both are in the same AWS Region. When they are, both accounts must allow the
replication actions. In the bucket resource policy, aws:SourceAccount and
aws:SourceArn name the source account, not the table bucket owner's
account. For the steps, see Using a table bucket in another account.
Best practices for IAM and bucket policies
Follow these practices for the policies that give access to the table bucket:
-
Grant the service principal only the actions in Creating the table bucket and resource policy, and avoid wildcard actions.
-
Scope the resource ARNs to the specific table bucket and its tables, not to all Amazon S3 Tables resources in the account.
-
Regularly review the table bucket resource policy and any IAM policies that use the
s3tables:namespacecondition key, especially after you add or remove integrations that share the table bucket.
Namespace-level access control and Lake Formation
Aurora creates one namespace for each source database, with a name that you know before you create the integration. For how namespaces are named, see Namespace and table names.
You can set IAM permissions for each namespace, which gives fine-grained control
similar to database-level permissions in PostgreSQL. A table's ARN identifies the table
bucket and a table ID. The namespace is not part of the ARN, and the table ID is not
derived from the table or namespace name. To scope a policy to one namespace, use the
s3tables:namespace condition key.
For example, the following identity-based policy lets a principal read the tables in
the namespace sales_replica_postgres and no other namespace in the table
bucket.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "ReadOneNamespace", "Effect": "Allow", "Action": [ "s3tables:GetTable", "s3tables:GetTableMetadataLocation", "s3tables:GetTableData" ], "Resource": "arn:aws:s3tables:aws-region:111122223333:bucket/my-table-bucket/table/*", "Condition": { "StringEquals": { "s3tables:namespace": "sales_replica_postgres" } } } ] }
To query through AWS analytics services such as Amazon Athena, the principal also needs AWS Glue Data Catalog permissions. If you use Lake Formation access control, grant Lake Formation permissions on the namespace instead.
After you turn on the table bucket's integration with AWS analytics services (a table bucket setting, separate from the Aurora integration), each namespace appears as an AWS Glue Data Catalog database. Lake Formation permissions and governance then apply to the replicated tables without extra catalog setup; you still grant Lake Formation permissions to the principals that query them. For more information, see Managed target tables.
Users cannot write to the target tables, regardless of the permissions you grant.
However, users with delete permissions can delete a table, a namespace, or the table
bucket, and these actions are destructive. Grant s3tables:DeleteTable,
s3tables:DeleteNamespace, and s3tables:DeleteTableBucket
only to the people who need them.
- Deleting target tables and namespaces
-
Aurora manages the target tables and namespaces. If you delete a target table, the integration's per-table status for that table changes to
FAILEDwith the reasonTARGET_TABLE_DELETED, and the other tables keep replicating. To restore the table, resync that table. For more information, see Per-table status.If you delete all the tables in a namespace and then delete the namespace, resync the whole integration to restore the namespace. The resync recreates the namespace and its tables and reloads the data from the source DB cluster. For more information, see Resyncing integrations with Amazon S3 Tables.