Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 如何在一个命令中为整个vpc或所有区域启用GCP流量日志?_Google Cloud Platform_Gcloud - Fatal编程技术网

Google cloud platform 如何在一个命令中为整个vpc或所有区域启用GCP流量日志?

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

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 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--不启用流量日志;完成