本頁面說明如何查看及實施建議,為違反管理員強制執行的 constraints/sql.restrictPublicIp 組織政策的執行個體停用公開 IP 存取權。這項政策會限制執行個體的公開 IP 設定。如果執行個體在強制執行限制時已有公開 IP 存取權,就會違反政策。這項建議稱為「停用公開 IP」。
這項建議工具每天都會偵測違反 constraints/sql.restrictPublicIp 組織政策的執行個體,並提供洞察資訊和建議,協助您提升執行個體安全性。您可以使用 Google Cloud 控制台、gcloud CLI 或 Recommender API,查看這些執行個體的洞察和詳細建議。
如要進一步瞭解組織政策,請參閱「Cloud SQL 組織政策」。
事前準備
必要角色和權限
如要取得查看及使用洞察和建議的權限,請確認您具備必要的 Identity and Access Management (IAM) 角色。
| Tasks | 角色 |
|---|---|
| 查看建議 |
recommender.cloudsqlViewer 或 cloudsql.admin。 |
| 套用建議 |
cloudsql.editor
或 cloudsql.admin。
|
列出建議
如要列出建議,請按照下列步驟操作:
控制台
如要列出執行個體安全性的建議,請按照下列步驟操作:
前往「Cloud SQL 執行個體」頁面。
查看執行個體表格中的「Issues」(問題) 欄。
或者,請按照下列步驟操作:
前往「Active Assist」。
詳情請參閱「探索建議」。
在「所有建議」資訊卡中,按一下「安全性」。
gcloud
執行 gcloud recommender recommendations list 指令,如下所示:
gcloud recommender recommendations list \ --project=PROJECT_ID \ --location=LOCATION \ --recommender=google.cloudsql.instance.SecurityRecommender \ --filter=recommenderSubtype=DISABLE_PUBLIC_IP_TO_MEET_ORG_POLICY
更改下列內容:
- PROJECT_ID:專案 ID。
- LOCATION:執行個體所在的區域,例如 us-central1。
API
呼叫 recommendations.list 方法,如下所示:
GET https://recommender.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/recommenders/google.cloudsql.instance.SecurityRecommender/recommendations?filter=recommenderSubtype=DISABLE_PUBLIC_IP_TO_MEET_ORG_POLICY
更改下列內容:
- PROJECT_ID:專案 ID。
- LOCATION:執行個體所在的區域,例如
us-central1。
查看洞察資料和詳細建議
如要查看洞察資料和詳細建議,請按照下列步驟操作:
控制台
列出建議後,請點選其中一項。建議面板隨即顯示,其中包含洞察資料和詳細建議。
gcloud
執行 gcloud recommender insights list 指令,如下所示:
gcloud recommender insights list \ --project=PROJECT_ID \ --location=LOCATION \ --insight-type=google.cloudsql.instance.SecurityInsight \ --filter=insightSubtype=ORG_POLICY_TO_RESTRICT_PUBLIC_IP_VIOLATED
更改下列內容:
- PROJECT_ID:專案 ID。
- LOCATION:執行個體所在的區域,例如
us-central1。
API
呼叫 insights.list 方法,如下所示:
GET https://recommender.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/insightTypes/google.cloudsql.instance.SecurityInsight/insights?filter=insightSubtype=ORG_POLICY_TO_RESTRICT_PUBLIC_IP_VIOLATED
更改下列內容:
- PROJECT_ID:專案 ID。
- LOCATION:執行個體所在的區域,例如
us-central1。
套用最佳化建議
控制台
如要採行最佳化建議,請按照下列步驟操作:
按一下「Manage instance IP assignment」(管理執行個體 IP 指派作業)。
將用戶端設為使用私人 IP 連線至執行個體。
gcloud
如要採行最佳化建議,請按照下列步驟操作:
將用戶端設為使用私人 IP 連線至執行個體。
API
如要採行最佳化建議,請按照下列步驟操作:
將用戶端設為使用私人 IP 連線至執行個體。