Skip to content

Commit 06341eb

Browse files
committed
Update serverless-external-storage.md
1 parent d18be3f commit 06341eb

File tree

1 file changed

+97
-95
lines changed

1 file changed

+97
-95
lines changed

tidb-cloud/serverless-external-storage.md

Lines changed: 97 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ summary: Learn how to configure Amazon Simple Storage Service (Amazon S3) access
55

66
# Configure External Storage Access for TiDB Serverless
77

8-
If you want import data from or export data to external storage in TiDB Serverless, you need to configure cross-account access. This document describes how to configure access to an external storage, including Amazon Simple Storage Service (Amazon S3), Google Cloud Storage (GCS) and Azure Blob Storage for TiDB Serverless.
8+
If you want import data from or export data to an external storage in TiDB Serverless, you need to configure cross-account access. This document describes how to configure access to an external storage, including Amazon Simple Storage Service (Amazon S3), Google Cloud Storage (GCS) and Azure Blob Storage for TiDB Serverless.
99

1010
If you need to configure these external storages for TiDB Dedicated, see [Configure Amazon S3 Access and GCS Access for TiDB Dedicated](/tidb-cloud/config-s3-and-gcs-access.md).
1111

1212
## Configure Amazon S3 access
1313

14-
To allow TiDB Serverless to access your Amazon S3 bucket, you need to configure the bucket access for TiDB Serverless. You can use either of the following methods to configure the bucket access:
14+
To allow a iDB Serverless cluster to access your Amazon S3 bucket, you need to configure the bucket access for TiDB Serverless. You can use either of the following methods to configure the bucket access:
1515

1616
- Use an AWS access key: use the access key of an IAM user to access your Amazon S3 bucket.
1717
- Use a Role ARN: use a Role ARN to access your Amazon S3 bucket.
@@ -25,31 +25,31 @@ Take the following steps to create one:
2525

2626
1. Open the **Import & Export** page for your target cluster.
2727

28-
1. Log in to the [TiDB Cloud console](https://tidbcloud.com/) and navigate to the [**Clusters**](https://tidbcloud.com/console/clusters) page of your project.
28+
1. Log in to the [TiDB Cloud console](https://tidbcloud.com/) and navigate to the [**Clusters**](https://tidbcloud.com/console/clusters) page of your project.
2929

30-
2. Click the name of your target cluster to go to its overview page, and then click **Import & Export** in the left navigation pane.
30+
2. Click the name of your target cluster to go to its overview page, and then click **Import & Export** in the left navigation pane.
3131

3232
2. Open the `Add New ARN` pop-up window.
3333

34-
1. Click **Import from S3** or **Export to Amazon S3** according to your needs.
34+
1. Click **Import from S3** or **Export to Amazon S3** according to your needs.
3535

36-
2. Fill in the `Folder URI` or `File URI` according to the instructions.
36+
2. Fill in the `Folder URI` or `File URI` according to the instructions.
3737

38-
3. Choose **AWS Role ARN** and click **Click here to create new one with AWS CloudFormation** to open the **Add New ARN** pop-up window.
38+
3. Choose **AWS Role ARN** and click **Click here to create new one with AWS CloudFormation** to open the **Add New ARN** pop-up window.
3939

4040
3. Create a role ARN with AWS CloudFormation Template.
4141

42-
1. Click **AWS Console with CloudFormation Template** in the **Add New ARN** pop-up window.
42+
1. Click **AWS Console with CloudFormation Template** in the **Add New ARN** pop-up window.
4343

44-
2. Log in to the AWS and you will be redirected to the AWS CloudFormation Template page.
44+
2. Log in to the AWS and you will be redirected to the AWS CloudFormation Template page.
4545

46-
3. Fill in the **Role Name**.
46+
3. Fill in the **Role Name**.
4747

48-
4. Acknowledge to create a new role and click **Create stack** to create the role ARN.
48+
4. Acknowledge to create a new role and click **Create stack** to create the role ARN.
4949

50-
5. After the CloudFormation stack is executed, you can find the Role ARN value in the **Outputs** tab.
50+
5. After the CloudFormation stack is executed, you can find the Role ARN value in the **Outputs** tab.
5151

52-
![img.png](/media/tidb-cloud/serverless-external-storage/serverless-role-arn.png)
52+
![img.png](/media/tidb-cloud/serverless-external-storage/serverless-role-arn.png)
5353

5454

5555
</div>
@@ -64,95 +64,95 @@ Take the following steps to create one:
6464

6565
2. In the AWS Management Console, create a managed policy for your Amazon S3 bucket.
6666

67-
1. Sign in to the AWS Management Console and open the Amazon S3 console at [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/).
67+
1. Sign in to the AWS Management Console and open the Amazon S3 console at [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/).
6868

69-
2. In the **Buckets** list, choose the name of your bucket with the source data, and then click **Copy ARN** to get your S3 bucket ARN (for example, `arn:aws:s3:::tidb-cloud-source-data`). Take a note of the bucket ARN for later use.
69+
2. In the **Buckets** list, choose the name of your bucket with the source data, and then click **Copy ARN** to get your S3 bucket ARN (for example, `arn:aws:s3:::tidb-cloud-source-data`). Take a note of the bucket ARN for later use.
7070

71-
![Copy bucket ARN](/media/tidb-cloud/copy-bucket-arn.png)
71+
![Copy bucket ARN](/media/tidb-cloud/copy-bucket-arn.png)
7272

73-
3. Open the IAM console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/), click **Policies** in the navigation pane on the left, and then click **Create Policy**.
73+
3. Open the IAM console at [https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/), click **Policies** in the navigation pane on the left, and then click **Create Policy**.
7474

75-
![Create a policy](/media/tidb-cloud/aws-create-policy.png)
75+
![Create a policy](/media/tidb-cloud/aws-create-policy.png)
7676

77-
4. On the **Create policy** page, click the **JSON** tab.
77+
4. On the **Create policy** page, click the **JSON** tab.
7878

79-
5. Copy the following access policy template and paste it to the policy text field.
80-
81-
```json
82-
{
83-
"Version": "2012-10-17",
84-
"Statement": [
85-
{
86-
"Sid": "VisualEditor0",
87-
"Effect": "Allow",
88-
"Action": [
89-
"s3:GetObject",
90-
"s3:GetObjectVersion",
91-
"s3:PutObject"
92-
],
93-
"Resource": "<Your S3 bucket ARN>/<Directory of your source data>/*"
94-
},
95-
{
96-
"Sid": "VisualEditor1",
97-
"Effect": "Allow",
98-
"Action": [
99-
"s3:ListBucket",
100-
"s3:GetBucketLocation"
101-
],
102-
"Resource": "<Your S3 bucket ARN>"
103-
}
104-
]
105-
}
106-
```
107-
108-
In the policy text field, update the following configurations to your own values.
109-
110-
- `"Resource": "<Your S3 bucket ARN>/<Directory of the source data>/*"`
111-
112-
For example, if your source data is stored in the root directory of the `tidb-cloud-source-data` bucket, use `"Resource": "arn:aws:s3:::tidb-cloud-source-data/*"`. If your source data is stored in the `mydata` directory of the bucket, use `"Resource": "arn:aws:s3:::tidb-cloud-source-data/mydata/*"`. Make sure that `/*` is added to the end of the directory so TiDB Cloud can access all files in this directory.
113-
114-
- `"Resource": "<Your S3 bucket ARN>"`
115-
116-
For example, `"Resource": "arn:aws:s3:::tidb-cloud-source-data"`.
117-
118-
- If you have enabled AWS Key Management Service key (SSE-KMS) with customer-managed key encryption, make sure the following configuration is included in the policy. `"arn:aws:kms:ap-northeast-1:105880447796:key/c3046e91-fdfc-4f3a-acff-00597dd3801f"` is a sample KMS key of the bucket.
119-
120-
```
121-
{
122-
"Sid": "AllowKMSkey",
123-
"Effect": "Allow",
124-
"Action": [
125-
"kms:Decrypt"
126-
],
127-
"Resource": "arn:aws:kms:ap-northeast-1:105880447796:key/c3046e91-fdfc-4f3a-acff-00597dd3801f"
128-
}
129-
```
130-
131-
If the objects in your bucket have been copied from another encrypted bucket, the KMS key value needs to include the keys of both buckets. For example, `"Resource": ["arn:aws:kms:ap-northeast-1:105880447796:key/c3046e91-fdfc-4f3a-acff-00597dd3801f","arn:aws:kms:ap-northeast-1:495580073302:key/0d7926a7-6ecc-4bf7-a9c1-a38f0faec0cd"]`.
132-
133-
6. Click **Next: Tags**, add a tag of the policy (optional), and then click **Next:Review**.
134-
135-
7. Set a policy name, and then click **Create policy**.
79+
5. Copy the following access policy template and paste it to the policy text field.
80+
81+
```json
82+
{
83+
"Version": "2012-10-17",
84+
"Statement": [
85+
{
86+
"Sid": "VisualEditor0",
87+
"Effect": "Allow",
88+
"Action": [
89+
"s3:GetObject",
90+
"s3:GetObjectVersion",
91+
"s3:PutObject"
92+
],
93+
"Resource": "<Your S3 bucket ARN>/<Directory of your source data>/*"
94+
},
95+
{
96+
"Sid": "VisualEditor1",
97+
"Effect": "Allow",
98+
"Action": [
99+
"s3:ListBucket",
100+
"s3:GetBucketLocation"
101+
],
102+
"Resource": "<Your S3 bucket ARN>"
103+
}
104+
]
105+
}
106+
```
107+
108+
In the policy text field, update the following configurations to your own values.
109+
110+
- `"Resource": "<Your S3 bucket ARN>/<Directory of the source data>/*"`
111+
112+
For example, if your source data is stored in the root directory of the `tidb-cloud-source-data` bucket, use `"Resource": "arn:aws:s3:::tidb-cloud-source-data/*"`. If your source data is stored in the `mydata` directory of the bucket, use `"Resource": "arn:aws:s3:::tidb-cloud-source-data/mydata/*"`. Make sure that `/*` is added to the end of the directory so TiDB Cloud can access all files in this directory.
113+
114+
- `"Resource": "<Your S3 bucket ARN>"`
115+
116+
For example, `"Resource": "arn:aws:s3:::tidb-cloud-source-data"`.
117+
118+
- If you have enabled AWS Key Management Service key (SSE-KMS) with customer-managed key encryption, make sure the following configuration is included in the policy. `"arn:aws:kms:ap-northeast-1:105880447796:key/c3046e91-fdfc-4f3a-acff-00597dd3801f"` is a sample KMS key of the bucket.
119+
120+
```
121+
{
122+
"Sid": "AllowKMSkey",
123+
"Effect": "Allow",
124+
"Action": [
125+
"kms:Decrypt"
126+
],
127+
"Resource": "arn:aws:kms:ap-northeast-1:105880447796:key/c3046e91-fdfc-4f3a-acff-00597dd3801f"
128+
}
129+
```
130+
131+
- If the objects in your bucket have been copied from another encrypted bucket, the KMS key value needs to include the keys of both buckets. For example, `"Resource": ["arn:aws:kms:ap-northeast-1:105880447796:key/c3046e91-fdfc-4f3a-acff-00597dd3801f","arn:aws:kms:ap-northeast-1:495580073302:key/0d7926a7-6ecc-4bf7-a9c1-a38f0faec0cd"]`.
132+
133+
6. Click **Next: Tags**, add a tag of the policy (optional), and then click **Next:Review**.
134+
135+
7. Set a policy name, and then click **Create policy**.
136136

137137
3. In the AWS Management Console, create an access role for TiDB Cloud and get the role ARN.
138138

139-
1. In the [IAM console](https://console.aws.amazon.com/iam/), click **Roles** in the navigation pane on the left, and then click **Create role**.
139+
1. In the [IAM console](https://console.aws.amazon.com/iam/), click **Roles** in the navigation pane on the left, and then click **Create role**.
140140

141-
![Create a role](/media/tidb-cloud/aws-create-role.png)
141+
![Create a role](/media/tidb-cloud/aws-create-role.png)
142142

143-
2. To create a role, fill in the following information:
143+
2. To create a role, fill in the following information:
144144

145-
- Under **Trusted entity type**, select **AWS account**.
146-
- Under **An AWS account**, select **Another AWS account**, and then paste the TiDB Cloud account ID to the **Account ID** field.
147-
- Under **Options**, click **Require external ID (Best practice when a third party will assume this role)**, and then paste the TiDB Cloud External ID to the **External ID** field. If the role is created without "Require external ID", once the configuration is done for one TiDB cluster in a project, all TiDB clusters in that project can use the same Role ARN to access your Amazon S3 bucket. If the role is created with the account ID and external ID, only the corresponding TiDB cluster can access the bucket.
145+
- Under **Trusted entity type**, select **AWS account**.
146+
- Under **An AWS account**, select **Another AWS account**, and then paste the TiDB Cloud account ID to the **Account ID** field.
147+
- Under **Options**, click **Require external ID (Best practice when a third party will assume this role)**, and then paste the TiDB Cloud External ID to the **External ID** field. If the role is created without "Require external ID", once the configuration is done for one TiDB cluster in a project, all TiDB clusters in that project can use the same Role ARN to access your Amazon S3 bucket. If the role is created with the account ID and external ID, only the corresponding TiDB cluster can access the bucket.
148148

149-
3. Click **Next** to open the policy list, choose the policy you just created, and then click **Next**.
149+
3. Click **Next** to open the policy list, choose the policy you just created, and then click **Next**.
150150

151-
4. Under **Role details**, set a name for the role, and then click **Create role** in the lower-right corner. After the role is created, the list of roles is displayed.
151+
4. Under **Role details**, set a name for the role, and then click **Create role** in the lower-right corner. After the role is created, the list of roles is displayed.
152152

153-
5. In the list of roles, click the name of the role that you just created to go to its summary page, and then you can get the role ARN.
153+
5. In the list of roles, click the name of the role that you just created to go to its summary page, and then you can get the role ARN.
154154

155-
![Copy AWS role ARN](/media/tidb-cloud/aws-role-arn.png)
155+
![Copy AWS role ARN](/media/tidb-cloud/aws-role-arn.png)
156156

157157
</div>
158158

@@ -182,15 +182,16 @@ To allow TiDB Serverless to access your GCS bucket, you need to configure the GC
182182
Take the following steps to configure a service account key:
183183

184184
1. Create a service account with needed permission in the Google Cloud [service account page](https://console.cloud.google.com/iam-admin/serviceaccounts). For more information, see [Creating a service account](https://cloud.google.com/iam/docs/creating-managing-service-accounts).
185-
1. Enter a service account name.
186-
2. Enter a description of the service account (Optional).
187-
3. Click **CREATE AND CONTINUE** to create the service account and continue the next step.
188-
4. In the `Grant this service account access to project`, choose the [IAM roles](https://cloud.google.com/iam/docs/understanding-roles) with needed permission. For example, TiDB Serverless export needs a role with `storage.objects.create` permission.
189-
5. Click **Continue** to the next step.
190-
6. Optional: In the `Grant users access to this service account`, choose members that need to [attach the service account to other resources](https://cloud.google.com/iam/docs/attach-service-accounts).
191-
7. Click **Done** to finish creating the service account.
192185

193-
![img.png](/media/tidb-cloud/serverless-external-storage/gcs-service-account.png)
186+
1. Enter a service account name.
187+
2. Enter a description of the service account (Optional).
188+
3. Click **CREATE AND CONTINUE** to create the service account and continue the next step.
189+
4. In the `Grant this service account access to project`, choose the [IAM roles](https://cloud.google.com/iam/docs/understanding-roles) with needed permission. For example, TiDB Serverless export needs a role with `storage.objects.create` permission.
190+
5. Click **Continue** to the next step.
191+
6. Optional: In the `Grant users access to this service account`, choose members that need to [attach the service account to other resources](https://cloud.google.com/iam/docs/attach-service-accounts).
192+
7. Click **Done** to finish creating the service account.
193+
194+
![img.png](/media/tidb-cloud/serverless-external-storage/gcs-service-account.png)
194195

195196
2. Click the service account and then click the **ADD KEY** button in the `KEYS` page to create a service account key.
196197

@@ -217,12 +218,13 @@ Take the following steps to configure a service SAS token:
217218
![img.png](/media/tidb-cloud/serverless-external-storage/azure-sas.png)
218219

219220
3. In the `Shared access signature` page, create a service SAS token with needed permissions as follows. For more information, see [Create a service SAS token](https://docs.microsoft.com/en-us/azure/storage/common/storage-sas-overview).
221+
220222
1. Choose the `Blob` service under the `Allowed services` section.
221223
2. Choose the `Container` and `Object` under the `Allowed Resource types` section.
222224
3. Choose the permission under the `Allowed permissions` section as you needed. For example: TiDB Serverless exports needs `Read` and `Write` permission.
223225
4. Adjust the `Start and expiry date/time` as you needed.
224226
5. You can keep other settings as default.
225227

226-
![img.png](/media/tidb-cloud/serverless-external-storage/azure-create-sas.png)
228+
![img.png](/media/tidb-cloud/serverless-external-storage/azure-create-sas.png)
227229

228230
4. Click the **Generate SAS and connection string** button to generate the SAS token.

0 commit comments

Comments
 (0)