

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

# 步驟 3：執行及測試配方
<a name="gettingstarted-cookbooks-test-recipe"></a>

**重要**  
 AWS OpsWorks Stacks 此服務已於 2024 年 5 月 26 日終止，並已針對新客戶和現有客戶停用。我們強烈建議客戶盡快將其工作負載遷移至其他解決方案。如果您對遷移有任何疑問，請透過 [AWS re：Post](https://repost.aws/) 或透過 [AWS Premium Support](https://aws.amazon.com/support) 聯絡 AWS 支援 團隊。

從 Stacks OpsWorks 複製到執行個體的技術指南中執行並測試`default`配方。您可能還記得，此為在配方執行時於日誌中顯示簡易訊息的單行配方。

**執行配方**

1. 在服務導覽窗格中，選擇 **Stack (堆疊)**。即會顯示 **MyCookbooksDemoStack** 頁面。

1. 選擇 **Run Command (執行命令)**。即會顯示 **Run Command (執行命令)** 頁面。

1. 針對 **Command (命令)**，選擇 **Execute Recipes (執行配方)**。

1. 針對 **Recipes to execute (要執行的配方)**，輸入 **opsworks\$1cookbook\$1demo::default**。

   **opsworks\$1cookbook\$1demo** 為在 `metadata.rb` 檔案中定義的技術指南名稱。**default** 為要執行的配方名稱，即技術指南的 `recipes` 子目錄中 `default.rb` 檔案的名稱，不帶副檔名。

1. 保留下列預設值：
   + **Comment (註解)** (空白)
   + **Advanced (進階)**、**Custom Chef JSON (自訂 Chef JSON)** (空白)
   + **Instances (執行個體)** (已核取 **Select all (全選)**，已核取 **MyCookbooksDemoLayer**，已核取 **cookbooks-demo1**)

1. 選擇 **Execute Recipes (執行配方)**。即會顯示 **Running command execute\$1recipes (執行 execute\$1recipes 命令)** 頁面。在 **Status (狀態)** 變更為 **successful (成功)** 前請不要繼續。此程序可能需要花費幾分鐘，敬請耐心等待。

**檢查配方的結果**

1. 在 **Running command execute\$1recipes (執行 execute\$1recipes 命令)** 頁面顯示時，針對 **cookbooks-demo1** 的 **Log (日誌)**，選擇 **show (顯示)**。即會顯示 **execute\$1recipes** 日誌頁面。

1. 向下捲動日誌，尋找與下列內容相似的項目：

   ```
   [2015-11-13T19:14:39+00:00] INFO: ********** Hello, World! **********
   ```

您已成功執行您的第一個配方！在[下一個步驟](gettingstarted-cookbooks-install-package.md)中，您會透過新增在執行個體上安裝套件的配方，來更新您的技術指南。