

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

# 開始使用 Aurora 零 ETL 整合
<a name="zero-etl.setting-up"></a>

在建立零 ETL 整合之前，請先使用必要的參數和許可設定 Aurora 資料庫叢集和資料倉儲。安裝期間，您將完成以下步驟：

1. [建立自訂資料庫叢集參數群組。](#zero-etl.parameters)

1. [建立來源資料庫叢集](#zero-etl.create-cluster)。

1. [為 Amazon Redshift 建立目標資料倉儲](#zero-etl-setting-up.data-warehouse)或[建立目標 Amazon SageMaker Lakehouse](#zero-etl-setting-up.sagemaker)。

完成這些任務後，請繼續 [建立與 Amazon Redshift 的 Aurora 零 ETL 整合](zero-etl.creating.md) 或 [建立與 Amazon SageMaker 資料湖倉的 Aurora 零 ETL 整合](zero-etl.creating-smlh.md)。

您可以使用 AWS SDKs 為您自動化設定程序。如需詳細資訊，請參閱[使用 AWS SDKs 設定整合](#zero-etl.setup-sdk)。

**提示**  
您可以在建立整合時讓 RDS 為您完成這些設定步驟，而不用手動執行這些步驟。若要立即開始建立整合，請參閱 [建立與 Amazon Redshift 的 Aurora 零 ETL 整合](zero-etl.creating.md)。

對於步驟 3，您可以選擇根據您的需求建立目標資料倉儲 (步驟 3a) 或目標湖房 (步驟 3b)：
+ 如果您需要使用 SQL 型分析的傳統資料倉儲功能，請選擇資料倉儲。
+ 如果您需要機器學習功能，並想要將湖房功能用於資料科學和 ML 工作流程，請選擇 Amazon SageMaker Lakehouse。

## 步驟 1：建立自訂資料庫叢集參數群組。
<a name="zero-etl.parameters"></a>

Aurora 零 ETL 整合需要控制複寫之資料庫叢集參數的特定值。具體而言，Aurora MySQL 需要*增強型 binlog* (`aurora_enhanced_binlog`)，而 Aurora PostgreSQL 需要*增強型邏輯複寫* (`aurora.enhanced_logical_replication`)。

若要設定二進位記錄或邏輯複寫，您必須先建立自訂資料庫叢集參數群組，然後將其與來源資料庫叢集建立關聯。

**Aurora MySQL (aurora-mysql8.0 系列）**：
+ `aurora_enhanced_binlog=1`
+ `binlog_backup=0`
+ `binlog_format=ROW`
+ `binlog_replication_globaldb=0`
+ `binlog_row_image=full`
+ `binlog_row_metadata=full`

此外，請確定 `binlog_transaction_compression` 參數*未*設定為 `ON`，且 `binlog_row_value_options` 參數*未*設定為 `PARTIAL_JSON`。

如需 Aurora MySQL 增強型 binlog 的詳細資訊，請參閱 [設定 Aurora MySQL 的增強型 binlog](AuroraMySQL.Enhanced.binlog.md)。

**Aurora PostgreSQL (aurora-postgresql16 系列）：**
+ `rds.logical_replication=1`
+ `aurora.enhanced_logical_replication=1`
+ `aurora.logical_replication_backup=0`
+ `aurora.logical_replication_globaldb=0`

即使 `REPLICA IDENTITY FULL` 未啟用，啟用增強型邏輯複寫 (`aurora.enhanced_logical_replication`) 仍一律會將所有資料欄值寫入預寫日誌 (WAL)。這可能會增加來源資料庫叢集的 IOPS。

**重要**  
如果您啟用或停用 `aurora.enhanced_logical_replication` 資料庫叢集參數，主要資料庫執行個體會讓所有邏輯複寫槽失效。這會停止從來源到目標的複寫，而且您必須在主要資料庫執行個體上重新建立複寫槽。為了防止中斷，請在複寫期間保持參數狀態一致。

## 步驟 2：選取或建立來源資料庫叢集
<a name="zero-etl.create-cluster"></a>

在建立自訂資料庫叢集參數群組之後，請選擇或建立 Aurora 資料庫叢集。此叢集將是複寫至目標資料倉儲之資料的來源。您可以指定一個資料庫叢集，其會使用佈建的資料庫執行個體或 Aurora serverless 資料庫執行個體做為來源。如需建立資料庫叢集的指示，請參閱 [建立 Amazon Aurora 資料庫叢集](Aurora.CreateInstance.md) 或 [建立使用 Aurora serverless 的資料庫叢集](aurora-serverless-v2.create.md)。

資料庫必須執行支援的資料庫引擎版本。如需支援的版本的清單，請參閱[零 ETL 整合的支援區域和 Aurora 資料庫引擎](Concepts.Aurora_Fea_Regions_DB-eng.Feature.Zero-ETL.md)。

當您建立資料庫時，在**其他組態**下，將預設**資料庫叢集參數群組**變更為您在上一個步驟中建立的自訂參數群組。

**注意**  
如果您在已建立叢集*之後*將參數群組與資料庫叢集建立關聯，則必須將叢集中的主要資料庫執行個體重新開機以套用變更，然後才能建立零 ETL 整合。如需相關指示，請參閱 [重新啟動 Amazon Aurora 資料庫叢集或 Amazon Aurora 資料庫執行個體](USER_RebootCluster.md)。

## 步驟 3a：建立目標資料倉儲
<a name="zero-etl-setting-up.data-warehouse"></a>

在建立來源資料庫叢集之後，您必須建立並設定目標資料倉儲。資料倉儲必須符合下列需求：
+ 使用具有至少兩個節點的 RA3 節點類型，或 Redshift Serverless。
+ 已加密 (如果使用已佈建的叢集)。如需詳細資訊，請參閱 [Amazon Redshift 資料庫加密](https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-db-encryption.html)。

如需建立資料倉儲的指示，請參閱[建立叢集](https://docs.aws.amazon.com/redshift/latest/mgmt/create-cluster) (適用於佈建的叢集)，或[使用命名空間建立工作群組](https://docs.aws.amazon.com/redshift/latest/mgmt/serverless-console-workgroups-create-workgroup-wizard.html) (適用於 Redshift Serverless)。

### 在資料倉儲上啟用區分大小寫
<a name="zero-etl-setting-up.case-sensitivity"></a>

若要成功整合，必須為資料倉儲啟用區分大小寫參數 ([https://docs.aws.amazon.com/redshift/latest/dg/r_enable_case_sensitive_identifier.html](https://docs.aws.amazon.com/redshift/latest/dg/r_enable_case_sensitive_identifier.html))。依預設，所有佈建的叢集和 Redshift Serverless 工作群組上都會停用區分大小寫。

若要啟用區分大小寫，請根據您的資料倉儲類型執行下列步驟：
+ **佈建的叢集** – 若要在佈建的叢集上啟用區分大小寫，請建立已啟用 `enable_case_sensitive_identifier` 參數的自訂參數群組。接著，將該參數群組與叢集建立關聯。如需指示，請參閱[使用主控台管理參數群組](https://docs.aws.amazon.com/redshift/latest/mgmt/managing-parameter-groups-console.html)或[使用 AWS CLI設定參數值](https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-parameter-groups.html#configure-parameters-using-the-clil)。
**注意**  
在將自訂參數群組與叢集建立關聯之後，請記得重新啟動該叢集。
+ **無伺服器工作群組** - 若要在 Redshift Serverless 工作群組上啟用區分大小寫，您必須使用 AWS CLI。Amazon Redshift 主控台目前不支援修改 Redshift Serverless 參數值。傳送下列 [update-workgroup](https://docs.aws.amazon.com/cli/latest/reference/redshift-serverless/update-workgroup.html) 要求：

  ```
  aws redshift-serverless update-workgroup \
    --workgroup-name {{target-workgroup}} \
    --config-parameters parameterKey=enable_case_sensitive_identifier,parameterValue=true
  ```

  在修改工作群組的參數值之後，您不需要重新啟動該工作群組。

### 設定資料倉儲的授權
<a name="zero-etl.setup-auth"></a>

在建立資料倉儲之後，您必須將來源 Aurora 資料庫叢集設定為授權的整合來源。如需指示，請參閱[設定 Amazon Redshift 資料倉儲的授權](https://docs.aws.amazon.com/redshift/latest/mgmt/zero-etl-using.setting-up.html#zero-etl-using.redshift-iam)。

## 使用 AWS SDKs 設定整合
<a name="zero-etl.setup-sdk"></a>

您可以執行下列 Python 指令碼來為您自動設定所需的資源，而不用手動設定每個資源。程式碼範例使用 [適用於 Python (Boto3) 的 AWS SDK](https://boto3.amazonaws.com/v1/documentation/api/latest/index.html) 建立來源 Amazon Aurora 資料庫叢集和目標資料倉儲，每個都具有必要的參數值。然後，在資料庫之間建立零 ETL 整合之前，它會等待資料庫可用。您可以根據您需要設定的資源來註解不同的函數。

若要安裝所需的相依性，請執行下列命令：

```
pip install boto3
pip install time
```

在指令碼中，選擇性地修改來源、目標和參數群組的名稱。最終函數會在設定資源後建立名為 `my-integration` 的整合。

### Python 程式碼範例
<a name="zero-etl.setup-sdk-python"></a>

------
#### [ Aurora MySQL ]

```
import boto3
import time

# Build the client using the default credential configuration.
# You can use the CLI and run 'aws configure' to set access key, secret
# key, and default Region.

rds = boto3.client('rds')
redshift = boto3.client('redshift')
sts = boto3.client('sts')

source_cluster_name = 'my-source-cluster' # A name for the source cluster
source_param_group_name = 'my-source-param-group' # A name for the source parameter group
target_cluster_name = 'my-target-cluster' # A name for the target cluster
target_param_group_name = 'my-target-param-group' # A name for the target parameter group

def create_source_cluster(*args):
    """Creates a source Aurora MySQL DB cluster"""

    response = rds.create_db_cluster_parameter_group(
        DBClusterParameterGroupName=source_param_group_name,
        DBParameterGroupFamily='aurora-mysql8.0',
        Description='For Aurora MySQL binary logging'
    )
    print('Created source parameter group: ' + response['DBClusterParameterGroup']['DBClusterParameterGroupName'])

    response = rds.modify_db_cluster_parameter_group(
        DBClusterParameterGroupName=source_param_group_name,
        Parameters=[
            {
                'ParameterName': 'aurora_enhanced_binlog',
                'ParameterValue': '1',
                'ApplyMethod': 'pending-reboot'
            },
            {
                'ParameterName': 'binlog_backup',
                'ParameterValue': '0',
                'ApplyMethod': 'pending-reboot'
            },
            {
                'ParameterName': 'binlog_format',
                'ParameterValue': 'ROW',
                'ApplyMethod': 'pending-reboot'
            },
            {
                'ParameterName': 'binlog_replication_globaldb',
                'ParameterValue': '0',
                'ApplyMethod': 'pending-reboot'
            },
            {
                'ParameterName': 'binlog_row_image',
                'ParameterValue': 'full',
                'ApplyMethod': 'pending-reboot'
            },
            {
                'ParameterName': 'binlog_row_metadata',
                'ParameterValue': 'full',
                'ApplyMethod': 'pending-reboot'
            }
        ]
    )
    print('Modified source parameter group: ' + response['DBClusterParameterGroupName'])

    response = rds.create_db_cluster(
        DBClusterIdentifier=source_cluster_name,
        DBClusterParameterGroupName=source_param_group_name,
        Engine='aurora-mysql',
        EngineVersion='8.0.mysql_aurora.3.05.2',
        DatabaseName='myauroradb',
        MasterUsername='{{username}}',
        MasterUserPassword='{{Password01**}}'
    )
    print('Creating source cluster: ' + response['DBCluster']['DBClusterIdentifier'])
    source_arn = (response['DBCluster']['DBClusterArn'])
    create_target_cluster(target_cluster_name, source_arn, target_param_group_name)

    response = rds.create_db_instance(
        DBInstanceClass='db.r6g.2xlarge',
        DBClusterIdentifier=source_cluster_name,
        DBInstanceIdentifier=source_cluster_name + '-instance',
        Engine='aurora-mysql'
    )
    return(response)

def create_target_cluster(target_cluster_name, source_arn, target_param_group_name):
    """Creates a target Redshift cluster"""

    response = redshift.create_cluster_parameter_group(
        ParameterGroupName=target_param_group_name,
        ParameterGroupFamily='redshift-1.0',
        Description='For Aurora MySQL zero-ETL integrations'
    )
    print('Created target parameter group: ' + response['ClusterParameterGroup']['ParameterGroupName'])

    response = redshift.modify_cluster_parameter_group(
        ParameterGroupName=target_param_group_name,
        Parameters=[
            {
                'ParameterName': 'enable_case_sensitive_identifier',
                'ParameterValue': 'true'
            }
        ]
    )
    print('Modified target parameter group: ' + response['ParameterGroupName'])

    response = redshift.create_cluster(
        ClusterIdentifier=target_cluster_name,
        NodeType='ra3.4xlarge',
        NumberOfNodes=2,
        Encrypted=True,
        MasterUsername='{{username}}',
        MasterUserPassword='{{Password01**}}',
        ClusterParameterGroupName=target_param_group_name
    )
    print('Creating target cluster: ' + response['Cluster']['ClusterIdentifier'])
    
    # Retrieve the target cluster ARN
    response = redshift.describe_clusters(
        ClusterIdentifier=target_cluster_name
    )
    target_arn = response['Clusters'][0]['ClusterNamespaceArn']

    # Retrieve the current user's account ID
    response = sts.get_caller_identity()
    account_id = response['Account']

    # Create a resource policy specifying cluster ARN and account ID
    response = redshift.put_resource_policy(
        ResourceArn=target_arn,
        Policy='''
        {
            \"Version\":\"2012-10-17\",		 	 	 
            \"Statement\":[
                {\"Effect\":\"Allow\",
                \"Principal\":{
                    \"Service\":\"redshift.amazonaws.com\"
                },
                \"Action\":[\"redshift:AuthorizeInboundIntegration\"],
                \"Condition\":{
                    \"StringEquals\":{
                        \"aws:SourceArn\":\"%s\"}
                    }
                },
                {\"Effect\":\"Allow\",
                \"Principal\":{
                    \"AWS\":\"arn:aws:iam::%s:root\"},
                \"Action\":\"redshift:CreateInboundIntegration\"}
            ]
        }
        ''' % (source_arn, account_id)
    )
    return(response)

def wait_for_cluster_availability(*args):
    """Waits for both clusters to be available"""

    print('Waiting for clusters to be available...')

    response = rds.describe_db_clusters(
        DBClusterIdentifier=source_cluster_name
    )
    source_status = response['DBClusters'][0]['Status']
    source_arn = response['DBClusters'][0]['DBClusterArn']

    response = rds.describe_db_instances(
        DBInstanceIdentifier=source_cluster_name + '-instance'
    )
    source_instance_status = response['DBInstances'][0]['DBInstanceStatus']

    response = redshift.describe_clusters(
        ClusterIdentifier=target_cluster_name
    )
    target_status = response['Clusters'][0]['ClusterStatus']
    target_arn = response['Clusters'][0]['ClusterNamespaceArn']

    # Every 60 seconds, check whether the clusters are available.
    if source_status != 'available' or target_status != 'available' or  source_instance_status != 'available':
        time.sleep(60)
        response = wait_for_cluster_availability(
            source_cluster_name, target_cluster_name)
    else:
        print('Clusters available. Ready to create zero-ETL integration.')
        create_integration(source_arn, target_arn)
        return

def create_integration(source_arn, target_arn):
    """Creates a zero-ETL integration using the source and target clusters"""

    response = rds.create_integration(
        SourceArn=source_arn,
        TargetArn=target_arn,
        IntegrationName='{{my-integration}}'
    )
    print('Creating integration: ' + response['IntegrationName'])
    
def main():
    """main function"""
    create_source_cluster(source_cluster_name, source_param_group_name)
    wait_for_cluster_availability(source_cluster_name, target_cluster_name)

if __name__ == "__main__":
    main()
```

------
#### [ Aurora PostgreSQL ]

```
import boto3
import time

# Build the client using the default credential configuration.
# You can use the CLI and run 'aws configure' to set access key, secret
# key, and default Region.

rds = boto3.client('rds')
redshift = boto3.client('redshift')
sts = boto3.client('sts')

source_cluster_name = 'my-source-cluster' # A name for the source cluster
source_param_group_name = 'my-source-param-group' # A name for the source parameter group
target_cluster_name = 'my-target-cluster' # A name for the target cluster
target_param_group_name = 'my-target-param-group' # A name for the target parameter group

def create_source_cluster(*args):
    """Creates a source Aurora PostgreSQL DB cluster"""

    response = rds.create_db_cluster_parameter_group(
        DBClusterParameterGroupName=source_param_group_name,
        DBParameterGroupFamily='aurora-postgresql16',
        Description='For Aurora PostgreSQL logical replication'
    )
    print('Created source parameter group: ' + response['DBClusterParameterGroup']['DBClusterParameterGroupName'])

    response = rds.modify_db_cluster_parameter_group(
        DBClusterParameterGroupName=source_param_group_name,
        Parameters=[
            {
                'ParameterName': 'rds.logical_replication',
                'ParameterValue': '1',
                'ApplyMethod': 'pending-reboot'
            },
            {
                'ParameterName': 'aurora.enhanced_logical_replication',
                'ParameterValue': '1',
                'ApplyMethod': 'pending-reboot'
            },
            {
                'ParameterName': 'aurora.logical_replication_backup',
                'ParameterValue': '0',
                'ApplyMethod': 'pending-reboot'
            },
            {
                'ParameterName': 'aurora.logical_replication_globaldb',
                'ParameterValue': '0',
                'ApplyMethod': 'pending-reboot'
            }
        ]
    )
    print('Modified source parameter group: ' + response['DBClusterParameterGroupName'])

    response = rds.create_db_cluster(
        DBClusterIdentifier=source_cluster_name,
        DBClusterParameterGroupName=source_param_group_name,
        Engine='aurora-postgresql',
        EngineVersion='16.4.aurora-postgresql',
        DatabaseName='mypostgresdb',
        MasterUsername='{{username}}',
        MasterUserPassword='{{Password01}}**'
    )
    print('Creating source cluster: ' + response['DBCluster']['DBClusterIdentifier'])
    source_arn = (response['DBCluster']['DBClusterArn'])
    create_target_cluster(target_cluster_name, source_arn, target_param_group_name)

    response = rds.create_db_instance(
        DBInstanceClass='db.r6g.2xlarge',
        DBClusterIdentifier=source_cluster_name,
        DBInstanceIdentifier=source_cluster_name + '-instance',
        Engine='aurora-postgresql'
    )
    return(response)

def create_target_cluster(target_cluster_name, source_arn, target_param_group_name):
    """Creates a target Redshift cluster"""

    response = redshift.create_cluster_parameter_group(
        ParameterGroupName=target_param_group_name,
        ParameterGroupFamily='redshift-1.0',
        Description='For Aurora PostgreSQL zero-ETL integrations'
    )
    print('Created target parameter group: ' + response['ClusterParameterGroup']['ParameterGroupName'])

    response = redshift.modify_cluster_parameter_group(
        ParameterGroupName=target_param_group_name,
        Parameters=[
            {
                'ParameterName': 'enable_case_sensitive_identifier',
                'ParameterValue': 'true'
            }
        ]
    )
    print('Modified target parameter group: ' + response['ParameterGroupName'])

    response = redshift.create_cluster(
        ClusterIdentifier=target_cluster_name,
        NodeType='ra3.4xlarge',
        NumberOfNodes=2,
        Encrypted=True,
        MasterUsername='{{username}}',
        MasterUserPassword='{{Password01**}}',
        ClusterParameterGroupName=target_param_group_name
    )
    print('Creating target cluster: ' + response['Cluster']['ClusterIdentifier'])
    
    # Retrieve the target cluster ARN
    response = redshift.describe_clusters(
        ClusterIdentifier=target_cluster_name
    )
    target_arn = response['Clusters'][0]['ClusterNamespaceArn']

    # Retrieve the current user's account ID
    response = sts.get_caller_identity()
    account_id = response['Account']

    # Create a resource policy specifying cluster ARN and account ID
    response = redshift.put_resource_policy(
        ResourceArn=target_arn,
        Policy='''
        {
            \"Version\":\"2012-10-17\",		 	 	 
            \"Statement\":[
                {\"Effect\":\"Allow\",
                \"Principal\":{
                    \"Service\":\"redshift.amazonaws.com\"
                },
                \"Action\":[\"redshift:AuthorizeInboundIntegration\"],
                \"Condition\":{
                    \"StringEquals\":{
                        \"aws:SourceArn\":\"%s\"}
                    }
                },
                {\"Effect\":\"Allow\",
                \"Principal\":{
                    \"AWS\":\"arn:aws:iam::%s:root\"},
                \"Action\":\"redshift:CreateInboundIntegration\"}
            ]
        }
        ''' % (source_arn, account_id)
    )
    return(response)

def wait_for_cluster_availability(*args):
    """Waits for both clusters to be available"""

    print('Waiting for clusters to be available...')

    response = rds.describe_db_clusters(
        DBClusterIdentifier=source_cluster_name
    )
    source_status = response['DBClusters'][0]['Status']
    source_arn = response['DBClusters'][0]['DBClusterArn']

    response = rds.describe_db_instances(
        DBInstanceIdentifier=source_cluster_name + '-instance'
    )
    source_instance_status = response['DBInstances'][0]['DBInstanceStatus']

    response = redshift.describe_clusters(
        ClusterIdentifier=target_cluster_name
    )
    target_status = response['Clusters'][0]['ClusterStatus']
    target_arn = response['Clusters'][0]['ClusterNamespaceArn']

    # Every 60 seconds, check whether the clusters are available.
    if source_status != 'available' or target_status != 'available' or  source_instance_status != 'available':
        time.sleep(60)
        response = wait_for_cluster_availability(
            source_cluster_name, target_cluster_name)
    else:
        print('Clusters available. Ready to create zero-ETL integration.')
        create_integration(source_arn, target_arn)
        return

def create_integration(source_arn, target_arn):
    """Creates a zero-ETL integration using the source and target clusters"""

    response = rds.create_integration(
        SourceArn=source_arn,
        TargetArn=target_arn,
        IntegrationName='{{my-integration}}'
    )
    print('Creating integration: ' + response['IntegrationName'])
    
def main():
    """main function"""
    create_source_cluster(source_cluster_name, source_param_group_name)
    wait_for_cluster_availability(source_cluster_name, target_cluster_name)

if __name__ == "__main__":
    main()
```

------

## 步驟 3b：建立 Amazon SageMaker Lakehouse 零 ETL 整合的 AWS Glue 目錄
<a name="zero-etl-setting-up.sagemaker"></a>

與 Amazon SageMaker Lakehouse 建立零 ETL 整合時，您必須在其中建立 AWS Glue 受管目錄 AWS Lake Formation。目標目錄必須是 Amazon Redshift 受管目錄。若要建立 Amazon Redshift 受管目錄，請先建立 `AWSServiceRoleForRedshift` 服務連結角色。在 Lake Formation 主控台中，將 `AWSServiceRoleForRedshift` 新增為唯讀管理員。

如需有關先前任務的詳細資訊，請參閱下列主題。
+ 如需有關建立 Amazon Redshift 受管目錄的詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的[在 AWS Glue Data Catalog中建立 Amazon Redshift 受管目錄](https://docs.aws.amazon.com/lake-formation/latest/dg/create-rms-catalog.html)。
+ 如需 Amazon Redshift 服務連結角色的詳細資訊，請參閱《Amazon Redshift 管理指南》**中的[使用 Amazon Redshift 的服務連結角色](https://docs.aws.amazon.com/redshift/latest/mgmt/using-service-linked-roles.html)。
+ 如需 Lake Formation 唯讀管理員許可的詳細資訊，請參閱《AWS Lake Formation 開發人員指南》**中的 [Lake Formation 角色和 IAM 許可參考](https://docs.aws.amazon.com/lake-formation/latest/dg/permissions-reference.html)。

### 設定目標 AWS Glue 目錄的許可
<a name="zero-etl-setting-up.sagemaker-permissions"></a>

在建立零 ETL 整合的目標目錄之前，您必須建立 Lake Formation 目標建立角色和 AWS Glue 資料傳輸角色。使用 Lake Formation 目標建立角色來建立目標目錄。建立目標目錄時，請在**從引擎存取區段**的 **IAM 角色**欄位中輸入 Glue 資料傳輸角色。

#### Lake Formation 目標建立角色
<a name="zero-etl-setting-up.target-creation-role"></a>

目標建立角色必須是 Lake Formation 管理員，且需要下列許可。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "lakeformation:RegisterResource",
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "s3:PutEncryptionConfiguration",
                "iam:PassRole",
                "glue:CreateCatalog",
                "glue:GetCatalog",
                "s3:PutBucketTagging",
                "s3:PutLifecycleConfiguration",
                "s3:PutBucketPolicy",
                "s3:CreateBucket",
                "redshift-serverless:CreateNamespace",
                "s3:DeleteBucket",
                "s3:PutBucketVersioning",
                "redshift-serverless:CreateWorkgroup"
            ],
            "Resource": [
                "arn:aws:glue:*:{{111122223333}}:catalog",
                "arn:aws:glue:*:{{111122223333}}:catalog/*",
                "arn:aws:s3:::*",
                "arn:aws:redshift-serverless:*:{{111122223333}}:workgroup/*",
                "arn:aws:redshift-serverless:*:{{111122223333}}:namespace/*",
                "arn:aws:iam::{{111122223333}}:role/GlueDataCatalogDataTransferRole"
            ]
        }
    ]
}
```

------

目標建立角色必須具有下列信任關係。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "glue.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        },
        {
          "Effect": "Allow",
          "Principal": {
            "AWS": "arn:aws:iam::{{111122223333}}:user/Username"
          },
          "Action": "sts:AssumeRole"
        }
    ]
}
```

------

#### Glue 資料傳輸角色
<a name="zero-etl-setting-up.glue-data-transfer-role"></a>

MySQL 目錄操作需要 Glue 資料傳輸角色，且必須具有下列許可。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "DataTransferRolePolicy",
            "Effect": "Allow",
            "Action": [
                "kms:GenerateDataKey",
                "kms:Decrypt",
                "glue:GetCatalog",
                "glue:GetDatabase"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}
```

------

Glue 資料傳輸角色必須具有下列信任關係。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": [
                    "glue.amazonaws.com",
                    "redshift.amazonaws.com"
                ]
            },
            "Action": "sts:AssumeRole"
        }
    ]
}
```

------

## 後續步驟
<a name="zero-etl.setup-next"></a>

透過來源 Aurora 資料庫叢集和 Amazon Redshift 目標資料倉儲或 Amazon SageMaker Lakehouse，您可以建立零 ETL 整合並複寫資料。如需說明，請參閱[建立與 Amazon Redshift 的 Aurora 零 ETL 整合](zero-etl.creating.md)。