本頁面說明如何在 Cloud Shell 和本機殼層中安裝 Terraform。Google Cloud Cloud Shell 是一種互動式殼層環境,可讓您透過網路瀏覽器,學習及實驗 Google CloudGoogle Cloud ,並管理專案和資源。
如需搭配使用 Terraform 和 Google Cloud的入門指南,請參閱 Terraform for Google Cloud 快速入門導覽課程。
Cloud Shell
如要使用已設定 gcloud CLI 和 Terraform 的線上終端機,請啟動 Cloud Shell:
頁面底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。工作階段可能要幾秒鐘的時間才能初始化。
執行下列指令,確認 Terraform 是否可用:
terraform
畫面會顯示如下的輸出內容:
Usage: terraform [global options] <subcommand> [args] The available commands for execution are listed below. The primary workflow commands are given first, followed by less common or more advanced commands. Main commands: init Prepare your working directory for other commands validate Check whether the configuration is valid plan Show changes required by the current configuration apply Create or update infrastructure destroy Destroy previously-created infrastructure
如要搭配使用 Terraform 和 Google Cloud,請確保在 Google Cloud中完成下列工作:
- 建立或擁有 Google Cloud 專案。
- 啟用 Google Cloud 專案的計費功能。
- 啟用 API,以便使用Google Cloud 所需服務。
- 為 Terraform 設定驗證方法。
本機殼層
按照 Terraform 提供的安裝說明操作。
執行下列指令,確認 Terraform 是否可用:
terraform
畫面會顯示如下的輸出內容:
Usage: terraform [global options] <subcommand> [args] The available commands for execution are listed below. The primary workflow commands are given first, followed by less common or more advanced commands. Main commands: init Prepare your working directory for other commands validate Check whether the configuration is valid plan Show changes required by the current configuration apply Create or update infrastructure destroy Destroy previously-created infrastructure
如要搭配使用 Terraform 和 Google Cloud,請確保在 Google Cloud中完成下列工作:
- 建立或擁有 Google Cloud 專案。
- 啟用 Google Cloud 專案的計費功能。
- 啟用 API,以便使用Google Cloud 所需服務。
- 為 Terraform 設定驗證方法。