新增和編輯叢集的資源型政策 - Amazon Aurora DSQL

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

新增和編輯叢集的資源型政策

將資源型政策新增至現有叢集
  1. 登入 AWS 管理主控台,並在 https://https://console.aws.amazon.com/dsql/ 開啟 Aurora DSQL 主控台。

  2. 從叢集清單中選擇叢集,以開啟叢集詳細資訊頁面。

  3. 選擇許可索引標籤。

  4. 資源型政策區段中,選擇新增政策

  5. 在 JSON 編輯器中輸入您的政策文件。您可以使用編輯陳述式新增陳述式來建置您的政策。

  6. 選擇 Add Policy (新增政策)

編輯現有的資源型政策
  1. 登入 AWS 管理主控台,並在 https://https://console.aws.amazon.com/dsql/ 開啟 Aurora DSQL 主控台。

  2. 從叢集清單中選擇叢集,以開啟叢集詳細資訊頁面。

  3. 選擇許可索引標籤。

  4. 資源型政策區段中,選擇編輯

  5. 在 JSON 編輯器中修改政策文件。您可以使用編輯陳述式新增陳述式來更新您的政策。

  6. 選擇儲存變更

使用 put-cluster-policy命令來連接新政策或更新叢集上的現有政策:

aws dsql put-cluster-policy --identifier your_cluster_id --policy '{ "Version": "2012-10-17", "Statement": [{ "Effect": "Deny", "Principal": {"AWS": "*"}, "Resource": "*", "Action": ["dsql:DbConnect", "dsql:DbConnectAdmin"], "Condition": { "Null": { "aws:SourceVpc": "true" } } }] }'
Python
import boto3 import json client = boto3.client('dsql') policy = { "Version": "2012-10-17", "Statement": [{ "Effect": "Deny", "Principal": {"AWS": "*"}, "Resource": "*", "Action": ["dsql:DbConnect", "dsql:DbConnectAdmin"], "Condition": { "Null": {"aws:SourceVpc": "true"} } }] } response = client.put_cluster_policy( identifier='your_cluster_id', policy=json.dumps(policy) )
Java
import software.amazon.awssdk.services.dsql.DsqlClient; import software.amazon.awssdk.services.dsql.model.PutClusterPolicyRequest; DsqlClient client = DsqlClient.create(); String policy = """ { "Version": "2012-10-17", "Statement": [{ "Effect": "Deny", "Principal": {"AWS": "*"}, "Resource": "*", "Action": ["dsql:DbConnect", "dsql:DbConnectAdmin"], "Condition": { "Null": {"aws:SourceVpc": "true"} } }] } """; PutClusterPolicyRequest request = PutClusterPolicyRequest.builder() .identifier("your_cluster_id") .policy(policy) .build(); client.putClusterPolicy(request);