設定 Privileged Access Manager 設定

Privileged Access Manager (PAM) 設定可讓您自動執行核准工作流程,並自訂組織、資料夾和專案的電子郵件通知偏好設定。Privileged Access Manager 設定管理員可以啟用自動核准功能,將服務帳戶、代理身分和 workload identity pool 中的身分指定為授權的合格核准者。您也可以針對特定 Privileged Access Manager 事件和角色,關閉資源層級的電子郵件,或停用所有通知。根據預設,資料夾和專案會透過資源階層繼承設定,除非您設定覆寫。

事前準備

如要取得設定 Privileged Access Manager 設定所需的權限,請要求管理員授予您下列 IAM 角色:

  • 設定專案、資料夾或組織:組織的 PAM 設定管理員 (roles/privilegedaccessmanager.settingsAdmin)
  • 查看專案、資料夾或組織的設定:專案、資料夾或組織的 PAM 設定檢視者 (roles/privilegedaccessmanager.settingsViewer)

這些預先定義的角色具備設定 Privileged Access Manager 所需的權限。如要查看確切的必要權限,請展開「Required permissions」(必要權限) 部分:

所需權限

必須具備下列權限,才能調整 Privileged Access Manager 設定:

  • 調整設定: privilegedaccessmanager.settings.update
  • 查看設定:
    • privilegedaccessmanager.settings.get
    • privilegedaccessmanager.settings.fetchEffective

自動核准

控制台

  1. 前往「Privileged Access Manager」頁面。

    前往 Privileged Access Manager

  2. 選取組織、資料夾或專案。

  3. 按一下「設定」分頁標籤。 在「設定來源」部分,系統預設會選取「沿用上層設定」。

  4. 如要覆寫子項資源從父項資源繼承的設定,請在「Automated approvals」(自動核准) 區段中選取「Override inheritance」(覆寫繼承)。

  5. 如要啟用自動核准功能,請將「啟用代理身分和服務帳戶做為核准者」切換鈕設為開啟,然後按一下「儲存」。

gcloud

gcloud alpha pam settings update 指令會設定其他 Privileged Access Manager。

使用下列任何指令資料前,請先替換以下項目:

  • RESOURCE_TYPE:選用。要更新設定的資源類型。請使用 organization、folder 或 project 值。
  • RESOURCE_ID:與 RESOURCE_TYPE 搭配使用。要管理授權的 Google Cloud專案、資料夾或組織 ID。專案 ID 是英數字串,例如 my-project。 資料夾和組織 ID 則為數字,例如 123456789012。
  • SA_AS_APPROVER:serviceAccountApproverSettings 欄位中的布林值,指出是否允許服務帳戶和代理身分核准授權。預設值為 false。
    • 如果您為 serviceAccountApproverSettings 欄位指定值,系統會將該設定套用至資源。
    • 如果您指定 serviceAccountApproverSettings 欄位,但將其留空,則系統會將預設設定套用至資源。
    • 如果完全未指定 serviceAccountApproverSettings 欄位,資源會沿用父項資源的設定。

    如果停用這項設定,需要服務帳戶或代理身分核准的授權將無法通過核准。如果授權只有服務帳戶或代理身分做為核准者,則這些授權不會生效。

  • request.json:包含修改後設定的檔案。如要建立這個檔案,請取得現有設定,將回應儲存至名為 request.json 的檔案,然後修改該檔案,做為更新要求的主體。您必須在主體中加入 ETAG,才能更新最新版本的設定。

將下列內容儲存至名為 filename.yaml 的檔案:

emailNotificationSettings:
  customNotificationBehavior:
    adminNotifications:
      grantActivated: NOTIFICATION_MODE_1
      grantActivationFailed: DISABLED
      grantEnded: ENABLED
      grantExternallyModified: ENABLED
    approverNotifications:
      pendingApproval: NOTIFICATION_MODE_2
    requesterNotifications:
      entitlementAssigned: ENABLED
      grantActivated: ENABLED
      grantExpired: NOTIFICATION_MODE_3
      grantRevoked: ENABLED
etag:'"ZjlkNWZlMWUtNDlhYS00YjJjAYlzNWYtZWFkNGVjOWU3NWMkBwYRsottW5Md"'
name: RESOURCE_TYPE/RESOURCE_ID/locations/global/settings
serviceAccountApproverSettings:
  enabled: SA_AS_APPROVER

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud alpha pam settings update \
    --location=global \
    --RESOURCE_TYPE=RESOURCE_ID \
    --settings-file FILENAME.yaml

Windows (PowerShell)

gcloud alpha pam settings update `
    --location=global `
    --RESOURCE_TYPE=RESOURCE_ID `
    --settings-file FILENAME.yaml

Windows (cmd.exe)

gcloud alpha pam settings update ^
    --location=global ^
    --RESOURCE_TYPE=RESOURCE_ID ^
    --settings-file FILENAME.yaml

您應該會收到類似以下的回應:

Parsed [location] resource: RESOURCE_TYPE/RESOURCE_ID/locations/global
Request issued for: [global]
Updated location [global].
createTime: '2025-05-18T10:10:10.101010101Z'
emailNotificationSettings:
  customNotificationBehavior:
    adminNotifications:
      grantActivated: ENABLED
      grantActivationFailed: DISABLED
      grantEnded: ENABLED
      grantExternallyModified: ENABLED
    approverNotifications:
      pendingApproval: ENABLED
    requesterNotifications:
      entitlementAssigned: ENABLED
      grantActivated: ENABLED
      grantExpired: ENABLED
      grantRevoked: ENABLED
etag: "ZjlkNWZlMWUtNDlhYS00YjJjAYlzNWYtZWFkNGVjOWU3NWMkBwYRsottW5Md1"
name: RESOURCE_TYPE/RESOURCE_ID/locations/global/settings
serviceAccountApproverSettings:
  enabled: true
updateTime: '2025-05-18T10:10:40.101010101Z'

REST

Privileged Access Manager API 的 updateSettings 方法會設定其他 Privileged Access Manager。

使用任何要求資料之前,請先修改下列項目的值:

  • SCOPE:要更新設定的組織、資料夾或專案,格式為 organizations/ORGANIZATION_ID、folders/FOLDER_ID 或 projects/PROJECT_ID。專案 ID 是英數字串,例如 my-project。資料夾和組織 ID 則為數字,例如 123456789012。
  • UPDATED_FIELDS:以半形逗號分隔的清單,列出設定中需要更新的欄位。例如:emailNotificationSettings,serviceAccountApproverSettings。

    如要更新所有可修改的欄位,請將更新遮罩設為 *。

  • SA_AS_APPROVER:serviceAccountApproverSettings 欄位中的布林值,指出是否允許服務帳戶和代理身分核准授權。預設值為 false。
    • 如果您為 serviceAccountApproverSettings 欄位指定值,系統會將該設定套用至資源。
    • 如果您指定 serviceAccountApproverSettings 欄位,但將其留空,則系統會將預設設定套用至資源。
    • 如果完全未指定 serviceAccountApproverSettings 欄位,資源會沿用父項資源的設定。

    如果停用這項設定,需要服務帳戶或代理身分核准的授權將無法通過核准。如果授權只有服務帳戶或代理身分做為核准者,則這些授權不會生效。

  • request.json:包含修改後設定的檔案。如要建立這個檔案,請取得現有設定,將回應儲存至名為 request.json 的檔案,然後修改該檔案,做為更新要求的主體。您必須在主體中加入 ETAG,才能更新最新版本的設定。

HTTP 方法和網址:

PATCH https://privilegedaccessmanager.googleapis.com/v1beta/SCOPE/locations/global/settings?updateMask=UPDATED_FIELDS

JSON 要求主體:

{
  "emailNotificationSettings": {
    "customNotificationBehavior": {
      "adminNotifications": {
        "grantActivated": "NOTIFICATION_MODE_1",
        "grantActivationFailed": "DISABLED",
        "grantEnded": "ENABLED",
        "grantExternallyModified": "ENABLED"
      },
      "approverNotifications": {
        "pendingApproval": "NOTIFICATION_MODE_2"
      },
      "requesterNotifications": {
        "entitlementAssigned": "ENABLED",
        "grantActivated": "ENABLED",
        "grantExpired": "NOTIFICATION_MODE_3",
        "grantRevoked": "ENABLED"
      }
    }
  },
  "etag": "\"ZjlkNWZlMWUtNDlhYS00YjJjAYlzNWYtZWFkNGVjOWU3NWMkBwYRsottW5Md\"",
  "name": "SCOPE/locations/global/settings",
  "serviceAccountApproverSettings": {
    "enabled": SA_AS_APPROVER
  }
}

請展開以下其中一個選項,以傳送要求:

您應該會收到如下的 JSON 回覆:


{
  "name": "SCOPE/locations/global/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.privilegedaccessmanager.v1beta.OperationMetadata",
    "createTime": "2024-03-25T01:55:02.544562950Z",
    "target": "SCOPE/locations/global/settings",
    "verb": "update",
    "requestedCancellation": false,
    "apiVersion": "v1beta"
  },
  "done": false
}


如要查看更新作業的進度,可以向下列端點傳送 GET 要求:

https://privilegedaccessmanager.googleapis.com/v1beta/SCOPE/locations/global/operations/OPERATION_ID

向下列端點傳送 GET 要求,列出所有作業:

https://privilegedaccessmanager.googleapis.com/v1beta/SCOPE/locations/global/operations

Terraform

您可以使用 Terraform 調整 Privileged Access Manager 設定。詳情請參閱 Terraform 說明文件中的 google_privileged_access_manager_settings。

自訂通知偏好設定

控制台

  1. 前往「Privileged Access Manager」頁面。

    前往 Privileged Access Manager

  2. 選取組織、資料夾或專案。

  3. 按一下 [設定] 標籤。

  4. 在「通知」部分,系統預設會選取「沿用上層設定」。

    下表列出預設通知偏好設定:

    事件 管理員 要求者 核准者
    已指派授權 - ✓ -
    授權需要核准 - - ✓
    授予項目已啟用 ✓ ✓ -
    授予項目遭拒 - ✓ -
    授予項目已過期 - ✓ -
    補助已結束 ✓ ✓ -
    撤銷授權 - ✓ -
    授予項目已從外部修改 ✓ ✓ -
    授予項目啟用失敗 ✓ ✓ -
  5. 如要覆寫從上層繼承的設定,請開啟「Send notifications for the following events」(針對下列事件傳送通知) 切換鈕。

  6. 如要停用所需 PAM 事件和角色的通知,請取消勾選對應的核取方塊,然後按一下「Save」(儲存)。

  7. 如要停用所有通知,請清除「Send notifications for the following events」(針對下列事件傳送通知),然後按一下「Save」(儲存)。

gcloud

gcloud alpha pam settings update 指令會設定其他 Privileged Access Manager。

使用下列任何指令資料前,請先替換以下項目:

  • RESOURCE_TYPE:選用。要更新設定的資源類型。請使用 organization、folder 或 project 值。
  • RESOURCE_ID:與 RESOURCE_TYPE 搭配使用。要管理授權的 Google Cloud專案、資料夾或組織 ID。專案 ID 是英數字串,例如 my-project。 資料夾和組織 ID 則為數字,例如 123456789012。
  • NOTIFICATION_MODE:在 emailNotificationSettings 欄位中,使用 ENABLED 傳送活動通知電子郵件,或使用 DISABLED 避免傳送。
    • 如果您為 emailNotificationSettings 欄位指定值,系統會將該設定套用至資源。
    • 如果您指定 emailNotificationSettings 欄位,但將其留空,則系統會將預設設定套用至資源。
    • 如果完全未指定 emailNotificationSettings 欄位,資源會沿用父項資源的設定。
  • request.json:包含修改後設定的檔案。如要建立這個檔案,請取得現有設定,將回應儲存至名為 request.json 的檔案,然後修改該檔案,做為更新要求的主體。您必須在主體中加入 ETAG,才能更新最新版本的設定。

將下列內容儲存至名為 filename.yaml 的檔案:

emailNotificationSettings:
  customNotificationBehavior:
    adminNotifications:
      grantActivated: NOTIFICATION_MODE_1
      grantActivationFailed: DISABLED
      grantEnded: ENABLED
      grantExternallyModified: ENABLED
    approverNotifications:
      pendingApproval: NOTIFICATION_MODE_2
    requesterNotifications:
      entitlementAssigned: ENABLED
      grantActivated: ENABLED
      grantExpired: NOTIFICATION_MODE_3
      grantRevoked: ENABLED
etag:'"ZjlkNWZlMWUtNDlhYS00YjJjAYlzNWYtZWFkNGVjOWU3NWMkBwYRsottW5Md"'
name: RESOURCE_TYPE/RESOURCE_ID/locations/global/settings
serviceAccountApproverSettings:
  enabled: SA_AS_APPROVER

執行下列指令:

Linux、macOS 或 Cloud Shell

gcloud alpha pam settings update \
    --location=global \
    --RESOURCE_TYPE=RESOURCE_ID \
    --settings-file FILENAME.yaml

Windows (PowerShell)

gcloud alpha pam settings update `
    --location=global `
    --RESOURCE_TYPE=RESOURCE_ID `
    --settings-file FILENAME.yaml

Windows (cmd.exe)

gcloud alpha pam settings update ^
    --location=global ^
    --RESOURCE_TYPE=RESOURCE_ID ^
    --settings-file FILENAME.yaml

您應該會收到類似以下的回應:

Parsed [location] resource: RESOURCE_TYPE/RESOURCE_ID/locations/global
Request issued for: [global]
Updated location [global].
createTime: '2025-05-18T10:10:10.101010101Z'
emailNotificationSettings:
  customNotificationBehavior:
    adminNotifications:
      grantActivated: ENABLED
      grantActivationFailed: DISABLED
      grantEnded: ENABLED
      grantExternallyModified: ENABLED
    approverNotifications:
      pendingApproval: ENABLED
    requesterNotifications:
      entitlementAssigned: ENABLED
      grantActivated: ENABLED
      grantExpired: ENABLED
      grantRevoked: ENABLED
etag: "ZjlkNWZlMWUtNDlhYS00YjJjAYlzNWYtZWFkNGVjOWU3NWMkBwYRsottW5Md1"
name: RESOURCE_TYPE/RESOURCE_ID/locations/global/settings
serviceAccountApproverSettings:
  enabled: true
updateTime: '2025-05-18T10:10:40.101010101Z'

REST

Privileged Access Manager API 的 updateSettings 方法會設定其他 Privileged Access Manager。

使用任何要求資料之前,請先修改下列項目的值:

  • SCOPE:要更新設定的組織、資料夾或專案,格式為 organizations/ORGANIZATION_ID、folders/FOLDER_ID 或 projects/PROJECT_ID。專案 ID 是英數字串,例如 my-project。資料夾和組織 ID 則為數字,例如 123456789012。
  • UPDATED_FIELDS:以半形逗號分隔的清單,列出設定中需要更新的欄位。例如:emailNotificationSettings,serviceAccountApproverSettings。

    如要更新所有可修改的欄位,請將更新遮罩設為 *。

  • NOTIFICATION_MODE:在 emailNotificationSettings 欄位中,使用 ENABLED 傳送活動通知電子郵件,或使用 DISABLED 避免傳送。
    • 如果您為 emailNotificationSettings 欄位指定值,系統會將該設定套用至資源。
    • 如果您指定 emailNotificationSettings 欄位,但將其留空,則系統會將預設設定套用至資源。
    • 如果完全未指定 emailNotificationSettings 欄位,資源會沿用父項資源的設定。
  • request.json:包含修改後設定的檔案。如要建立這個檔案,請取得現有設定,將回應儲存至名為 request.json 的檔案,然後修改該檔案,做為更新要求的主體。您必須在主體中加入 ETAG,才能更新最新版本的設定。

HTTP 方法和網址:

PATCH https://privilegedaccessmanager.googleapis.com/v1beta/SCOPE/locations/global/settings?updateMask=UPDATED_FIELDS

JSON 要求主體:

{
  "emailNotificationSettings": {
    "customNotificationBehavior": {
      "adminNotifications": {
        "grantActivated": "NOTIFICATION_MODE_1",
        "grantActivationFailed": "DISABLED",
        "grantEnded": "ENABLED",
        "grantExternallyModified": "ENABLED"
      },
      "approverNotifications": {
        "pendingApproval": "NOTIFICATION_MODE_2"
      },
      "requesterNotifications": {
        "entitlementAssigned": "ENABLED",
        "grantActivated": "ENABLED",
        "grantExpired": "NOTIFICATION_MODE_3",
        "grantRevoked": "ENABLED"
      }
    }
  },
  "etag": "\"ZjlkNWZlMWUtNDlhYS00YjJjAYlzNWYtZWFkNGVjOWU3NWMkBwYRsottW5Md\"",
  "name": "SCOPE/locations/global/settings",
  "serviceAccountApproverSettings": {
    "enabled": SA_AS_APPROVER
  }
}

請展開以下其中一個選項,以傳送要求:

您應該會收到如下的 JSON 回覆:


{
  "name": "SCOPE/locations/global/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.privilegedaccessmanager.v1beta.OperationMetadata",
    "createTime": "2024-03-25T01:55:02.544562950Z",
    "target": "SCOPE/locations/global/settings",
    "verb": "update",
    "requestedCancellation": false,
    "apiVersion": "v1beta"
  },
  "done": false
}


如要查看更新作業的進度,可以向下列端點傳送 GET 要求:

https://privilegedaccessmanager.googleapis.com/v1beta/SCOPE/locations/global/operations/OPERATION_ID

向下列端點傳送 GET 要求,列出所有作業:

https://privilegedaccessmanager.googleapis.com/v1beta/SCOPE/locations/global/operations

Terraform

您可以使用 Terraform 調整 Privileged Access Manager 設定。詳情請參閱 Terraform 說明文件中的 google_privileged_access_manager_settings。

後續步驟