

# Example policy: Allow a principal to turn on usage system tables

This identity-based policy allows an IAM principal to turn system table integration on or off for an Amazon SageMaker Unified Studio domain. It also allows Amazon SageMaker Unified Studio to create the `aws-sagemaker-unified-studio` table bucket with that principal's identity, which happens the first time the integration is turned on in an account and Region. Attach the policy to the principal that turns on the integration.

## Prerequisites
<a name="usage-system-tables-example-policy-prereqs"></a>
+ If the domain is encrypted with a customer managed AWS Key Management Service (AWS KMS) key, the principal also needs `kms:Decrypt` and `kms:GenerateDataKey` on that key.

## Policy
<a name="usage-system-tables-example-policy-policy"></a>

Replace the example AWS Region and account ID with your own.

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "ManageSystemTableExportConfiguration",
            "Effect": "Allow",
            "Action": [
                "datazone:GetSystemTableExportConfiguration",
                "datazone:PutSystemTableExportConfiguration"
            ],
            "Resource": "*"
        },
        {
            "Sid": "CreateSystemTableBucket",
            "Effect": "Allow",
            "Action": [
                "s3tables:CreateTableBucket",
                "s3tables:PutTableBucketPolicy"
            ],
            "Resource": "arn:aws:s3tables:{{us-east-1}}:{{123456789012}}:bucket/aws-sagemaker-unified-studio"
        }
    ]
}
```

## Details
<a name="usage-system-tables-example-policy-details"></a>
+ **`datazone:GetSystemTableExportConfiguration` and `datazone:PutSystemTableExportConfiguration`**: Read and change the domain's system table configuration.
+ **`s3tables:CreateTableBucket` and `s3tables:PutTableBucketPolicy`**: Create the table bucket the first time the integration is turned on in the account and Region.

After the table bucket exists, Amazon SageMaker Unified Studio creates the namespace and tables through a service trust relationship. The principal doesn't need permissions to create namespaces or tables.