

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

# 在 中匯入 AWS Glue DataBrew 配方 AWS Glue Studio
<a name="glue-studio-data-preparation-import-recipe"></a>

 在 中 AWS Glue DataBrew，配方是一組資料轉換步驟。 AWS Glue DataBrew 配方會說明如何轉換已讀取的資料，且不描述讀取資料的位置和方法，以及如何寫入資料。此項在 AWS Glue Studio 的來源和目標節點中設定。如需配方的詳細資訊，請參閱[建立和使用 AWS Glue DataBrew 配方。 ](https://docs.aws.amazon.com/databrew/latest/dg/recipes.html)

 若要在 中使用 AWS Glue DataBrew 配方AWS Glue Studio，請從在 中建立配方開始 AWS Glue DataBrew。如果您已擁有要使用的配方，則可略過此步驟。

## 的 IAM 許可 AWS Glue DataBrew
<a name="glue-studio-databrew-permissions"></a>

 本主題提供的資訊可協助您了解 IAM 管理員在 AWS Identity and Access Management (IAM) 政策中可用於資料準備配方轉換的動作和資源。

 如需 中安全性的其他資訊 AWS Glue，請參閱[存取管理](https://docs.aws.amazon.com/glue/latest/dg/security.html)。

**注意**  
 下表列出使用者在匯入現有 AWS Glue DataBrew 配方時所需的許可。


**「資料準備配方」轉換動作**  

| Action | Description | 
| --- | --- | 
| databrew:ListRecipes | 准許擷取 AWS Glue DataBrew 配方。 | 
| databrew:ListRecipeVersions | 准許擷取 AWS Glue DataBrew 配方版本。 | 
| databrew:DescribeRecipe | 准許擷取 AWS Glue DataBrew 配方描述。 | 



 您用於存取此功能的角色應具有允許數個 AWS Glue DataBrew 動作的政策。您可以使用包含必要動作的 `AWSGlueConsoleFullAccess` 政策，或將下列內嵌政策新增至您的角色，來實現此目的：

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "databrew:ListRecipes",
        "databrew:ListRecipeVersions",
        "databrew:DescribeRecipe"
      ],
      "Resource": [
        "*"
      ]
    }
  ]
}
```

------



 若要使用「資料準備配方」轉換，您必須將 `IAM:PassRole` 動作新增至許可政策。


**其他必要許可**  

| Action | Description | 
| --- | --- | 
| iam:PassRole | 授予 IAM 許可，以允許使用者傳遞核准的角色。 | 

如果沒有這些許可，會發生下列錯誤：

```
"errorCode": "AccessDenied"
"errorMessage": "User: arn:aws:sts::account_id:assumed-role/AWSGlueServiceRole is not 
authorized to perform: iam:PassRole on resource: arn:aws:iam::account_id:role/service-role/AWSGlueServiceRole 
because no identity-based policy allows the iam:PassRole action"
```



## 匯入 AWS Glue DataBrew 配方
<a name="glue-studio-databrew-import-steps"></a>

**若要匯入 AWS Glue DataBrew 配方並在 中使用 AWS Glue Studio：**

 如果您有現有的**資料準備配方**節點，而且想要直接在其中編輯配方步驟 AWS Glue Studio，則必須將配方步驟匯入您的 AWS Glue Studio 任務。

1.  使用資料來源啟動 AWS Glue Studio 中的 AWS Glue 任務。

1.  將**資料準備配方**節點新增至任務畫布。  
![\[螢幕擷取畫面顯示「新增節點」模態，其中包含可供選取的資料準備配方。\]](http://docs.aws.amazon.com/zh_tw/glue/latest/dg/images/glue-add-node-data-preparation-recipe.png)

1.  在「轉換」面板中，輸入配方的名稱。

1.  從下拉式清單中選取畫布上的可用節點，以選擇一或多個父節點。

1.  選擇**撰寫配方**。如果**撰寫配方**為灰色，則在選取節點父項且資料預覽工作階段完成之前不可用。  
![\[Author Data Preparation Recipe form with name field and node parents selection dropdown.\]](http://docs.aws.amazon.com/zh_tw/glue/latest/dg/images/glue-author-data-preparation-recipe.png)

1.  資料框架會載入並顯示有關來源資料的詳細資訊。

    選取**更多動作**圖示，然後選擇**匯入配方**。  
![\[Data preparation interface showing "Build your Recipe" with an "Add step" button.\]](http://docs.aws.amazon.com/zh_tw/glue/latest/dg/images/glue-dataframe-import-recipe.png)

1.  使用「匯入配方」精靈來完成步驟。在步驟 1 中，搜尋您的配方，選取其，然後選擇**下一步**。  
![\[Import recipe interface showing two recipes, with one selected for import.\]](http://docs.aws.amazon.com/zh_tw/glue/latest/dg/images/import-recipe-step-1.png)

1.  在步驟 2 中，選擇您的匯入選項。您可以選擇「將新配方附加至現有配方」或「覆寫現有配方」。選擇**下一步**。  
![\[Import recipe interface showing selected recipe, version, and two imported steps.\]](http://docs.aws.amazon.com/zh_tw/glue/latest/dg/images/import-recipe-step-2.png)

1.  在步驟 3 中，驗證配方步驟。匯入 AWS Glue DataBrew 配方後，您可以直接編輯此配方 AWS Glue Studio。  
![\[Recipe import interface showing two steps and a validation progress indicator.\]](http://docs.aws.amazon.com/zh_tw/glue/latest/dg/images/import-recipe-step-3.png)  
![\[Import recipe interface showing validated steps for sorting and formatting data.\]](http://docs.aws.amazon.com/zh_tw/glue/latest/dg/images/import-recipe-step-3-validated-2.png)

1.  之後，這些步驟將作為 AWS Glue 任務的一部分匯入。在**任務詳細資訊**索引標籤中進行必要的組態變更，例如命名任務和視需要調整配置的容量。選擇**儲存**以儲存您的任務和配方。
**注意**  
 JOIN、UNION、GROUP\$1BY、PIVOT、UNPIVOT、TRANSPOSE 不支援配方匯入，也不適用於配方撰寫模式。

1.  (選用) 視需要新增其他轉換節點來完成撰寫任務，並新增資料目標節點。

    如果您在匯入配方之後重新排序步驟， 會對這些步驟 AWS Glue 執行驗證。例如，如果您重新命名然後刪除資料欄，而且在頂端移動了刪除步驟，則重新命名步驟會無效。然後，您可以編輯步驟來修正驗證錯誤。