本頁面說明如何在Google Cloud Cloud Shell 和本機殼層中安裝 Terraform。Cloud Shell 是互動式殼層環境,可讓您透過網路瀏覽器學習及實驗 Google Cloud,並管理專案和資源 Google Cloud 。
如需搭配使用 Terraform 和 Google Cloud的入門指南,請參閱「Terraform for Google Cloud 快速入門」。
Cloud Shell
如要使用已設定 gcloud CLI 的線上終端機,請啟用 Cloud Shell:
頁面底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。工作階段可能要幾秒鐘的時間才能初始化。
如要安裝 Terraform CLI,請按照 HashiCorp 的操作說明操作。
您可以自訂環境,在環境啟動時安裝 Terraform CLI,也可以將二進位檔安裝至主目錄,以便在工作階段間保留安裝項目。
執行下列指令,確認 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 計費功能。
- 為您要使用的Google Cloud 服務啟用 API。
- 為 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 專案的計費功能。
- 為您要使用的Google Cloud 服務啟用 API。
- 為 Terraform 設定驗證方法。