Terraform 是一種基礎架構即程式碼 (IaC) 工具,可讓您使用程式碼佈建及設定 Apigee。
搭配 Apigee 使用 Terraform 時,您會建立 Terraform 檔案,描述要佈建或使用的功能設定。您 套用設定時,Terraform 會建立執行計畫,並執行設定 Apigee 所需的作業。
本頁摘要說明 Apigee 適用的 Terraform 功能。如要瞭解如何搭配使用 Terraform 和 Google Cloud,請參閱 Terraform on Google Cloud 說明文件。
事前準備
如要為 Apigee 專案設定 Terraform,請按照下列步驟操作:
-
準備開發環境,可以是 Cloud Shell 或本機殼層:
Cloud Shell
如要使用已設定 gcloud CLI 和 Terraform 的線上終端機,請啟用 Cloud Shell。
頁面底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。工作階段可能要幾秒鐘的時間才能初始化。
請注意,Cloud Shell 已整合 Terraform。
本機殼層
如要使用本機開發環境,請按照下列步驟操作:
-
Install the Google Cloud CLI.
-
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init - 安裝 Terraform。
Verify that billing is enabled for your Google Cloud project.
Enable the Cloud Resource Manager and Identity, Access Management (IAM) APIs:
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM
role (roles/serviceusage.serviceUsageAdmin), which contains the
serviceusage.services.enable permission. Learn how to grant
roles.
gcloud services enable cloudresourcemanager.googleapis.comiam.googleapis.com
Google Cloud Platform - Resource Location Restriction 機構政策限制。適用於 Apigee 的 Terraform 資源
下表列出可透過 Apigee 的 Terraform 資源管理的功能。請注意,這份清單僅列出部分示例。如要查看 Apigee 的所有 Terraform 資源,請前往 Apigee Terraform GitHub 存放區。請務必前往 GitHub 存放區查看最新功能。
| Apigee 功能 | Terraform 支援摘要 | 更多資訊 |
|---|---|---|
| 佈建 Apigee | 使用 Terraform 佈建 Apigee 執行個體。 | 佈建選項 |
| 佈建 Apigee API 中心 | 使用 Terraform 設定及管理 API 中心。 | 使用 Terraform 佈建 API 中心 |
| 設定 Advanced API Security | 設定安全性動作,以及風險評估 v2 的部分項目。 | 使用 Terraform 設定 Advanced API Security |