搭配使用 Terraform 與 Apigee

HashiCorp Terraform 是一種基礎架構即程式碼 (IaC) 工具,可用於透過程式碼佈建及設定 Apigee。

搭配 Apigee 使用 Terraform 時,您會建立 Terraform 檔案,描述要佈建或使用的功能設定。當您 套用設定時,Terraform 會建立執行計畫,並執行設定 Apigee 所需的作業。

本頁彙整了 Apigee 適用的 Terraform 功能。如要瞭解如何搭配使用 Terraform 和 Google Cloud,請參閱 Terraform on Google Cloud 說明文件

事前準備

如要為 Apigee 專案設定 Terraform,請按照下列步驟操作:

  1. 準備開發環境,可以是 Cloud Shell 或本機殼層:

    Cloud Shell

    如要使用已設定 gcloud CLI 和 Terraform 的線上終端機,請啟用 Cloud Shell。

    頁面底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。工作階段可能要幾秒鐘的時間才能初始化。

    請注意,Cloud Shell 已整合 Terraform。

    本機殼層

    如要使用本機開發環境,請按照下列步驟操作:

    1. 安裝 Google Cloud CLI。

    2. 若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI

    3. 執行下列指令,初始化 gcloud CLI:

      gcloud init
    4. 安裝 Terraform
  2. 確認專案已啟用計費功能 Google Cloud

  3. 啟用 Cloud Resource Manager 和 Identity and Access Management (IAM) API:

    啟用 API 時所需的角色

    如要啟用 API,您需要具備服務使用情形管理員 IAM 角色 (roles/serviceusage.serviceUsageAdmin),其中包含 serviceusage.services.enable 權限。瞭解如何授予角色

    gcloud services enable cloudresourcemanager.googleapis.com  iam.googleapis.com
  4. 請確認 Google Cloud 專案未新增 Google Cloud Platform - Resource Location Restriction organization policy constraint

Apigee 的 Terraform 資源

下表列出您可透過 Apigee 的 Terraform 資源管理的功能。這份清單可能未列出所有項目。如要查看 Apigee 的所有 Terraform 資源,請前往 Google Cloud Platform Cloud Foundation Fabric GitHub 存放區,以及 HashiCorp Google Provider 的 Apigee 說明文件。請務必查看這些資源, 瞭解最新功能。

Apigee 功能 Terraform 支援摘要 更多資訊
佈建 Apigee 使用 Terraform 佈建 Apigee 執行個體。 佈建選項
佈建 Apigee API 中心 使用 Terraform 設定及管理 API 中心。 使用 Terraform 佈建 API 中心
設定 Advanced API Security 設定風險評估安全設定檔和監控條件 (第 2 版)

設定濫用行為偵測排除清單
設定安全防護動作
使用 Terraform 設定 Advanced API Security