Google cloud platform 如何在一个命令中为整个vpc或所有区域启用GCP流量日志?
Bash命令--为整个VPC或具有VPC的所有区域启用流量记录简单Bash脚本可查询具有VPC的所有区域,并通过循环启用流量记录Google cloud platform 如何在一个命令中为整个vpc或所有区域启用GCP流量日志?,google-cloud-platform,gcloud,Google Cloud Platform,Gcloud,Bash命令--为整个VPC或具有VPC的所有区域启用流量记录简单Bash脚本可查询具有VPC的所有区域,并通过循环启用流量记录 a=( $(gcloud compute networks subnets list --filter="<VPC NAME>" --format="csv(region)")); a=("${a[@]:1}"); for i in "${a[@]}"; do gcloud c
a=( $(gcloud compute networks subnets list --filter="<VPC NAME>" --format="csv(region)")); a=("${a[@]:1}"); for i in "${a[@]}"; do gcloud compute networks subnets update <VPC NAME> --region=$i --enable-flow-logs; done
a=($(gcloud计算网络子网列表--filter=“”--format=“csv(区域)”);a=(“${a[@]:1}”);对于“${a[@]}”中的i;gcloud计算网络子网是否更新--区域=$i--启用流量日志;完成
记住,在大多数情况下,用VPC示例默认名称替换上面的2个“VPC名称”实例
可以使用--no enable flow logging关闭整个vpc的流量记录
a=( $(gcloud compute networks subnets list --filter="<VPC NAME>" --format="csv(region)")); a=("${a[@]:1}"); for i in "${a[@]}"; do gcloud compute networks subnets update <VPC NAME> --region=$i --no-enable-flow-logs; done
a=($(gcloud计算网络子网列表--filter=“”--format=“csv(区域)”);a=(“${a[@]:1}”);对于“${a[@]}”中的i;gcloud计算网络子网是否更新--区域=$i--不启用流量日志;完成