我如何找到未附加的防火墙规则

问题描述 投票:0回答:1

我正在审查防火墙规则。规则似乎是由标签附加的,有没有办法识别没有相应资源的防火墙规则?

security google-cloud-platform firewall
1个回答
0
投票

对象“ VM实例”和“防火墙规则”具有“网络标签”属性,该属性在逻辑上将它们绑定:

CloudShell:$ gcloud compute instances describe lamp-1-vm --zone=us-central1-f 
...
tags: 
  items:
  - lamp-1-deployment

CloudShell $ gcloud compute firewall-rules describe my-http-enable 
...
targetTags: 
- lamp-1-deployment

您可以使用gcloud和一些shell脚本来构建带有网络标签的防火墙规则列表,以及带有标签的实例列表,然后使用循环查找未使用标签的防火墙规则。

在这里,您会找到一些有用的示例:

Filtering and formatting fun with gcloud, GCP’s command line interface

© www.soinside.com 2019 - 2024. All rights reserved.