我正在审查防火墙规则。规则似乎是由标签附加的,有没有办法识别没有相应资源的防火墙规则?
对象“ 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