【问题标题】:Google Cloud Firewall - Unrecognized argumentsGoogle Cloud Firewall - 无法识别的参数
【发布时间】:2018-11-02 00:32:41
【问题描述】:

我正在使用 Google Cloud CLI 创建虚拟机,我还需要通过 CLI 创建防火墙规则;

我有一个 bash 脚本,其中包含一些预定义的变量,例如端口、描述等;创建虚拟机,然后为其应用防火墙规则;

应用我使用的规则

gcloud compute firewall-rules create

但我得到的错误是 GCP 文档here中定义的参数

ERROR: (gcloud.compute.firewall-rules.create) unrecognized arguments:
./1541078390.sh: line 84: --allow: command not found
./1541078390.sh: line 86: --source-ranges: command not found
./1541078390.sh: line 87: --priority: command not found

我尝试了不同但相似的方法,我不断得到它们。 我有什么遗漏吗?

脚本的一个例子是

ports="udp:2555"
vm="client"
priority=100
description="Port 2555"

gcloud compute firewall-rules create "${ports%%:*} rule" \ 
    --allow "${ports}" \ (line 84)
    --source-tags "$vm" \ 
    --source-ranges "0.0.0.0/0" \ (line 86)
    --priority "$priority" \(line 87)
    --description "$description" \
    --direction INGRESS

【问题讨论】:

    标签: google-cloud-platform firewall


    【解决方案1】:

    我认为你可能在一些反斜杠之后有空格。确保删除它们后面的所有空格,然后重试。

    根据您的示例,您应该在第 83、85 和 86 行有一个空格

    干杯,

    【讨论】:

      【解决方案2】:

      我找到了发生这种情况的原因。

      在终端中手动执行命令后,它会输出详细的错误,很明显“无法识别”的参数未能通过正则表达式验证。所以我根据错误中的推荐调整了参数语法,它起作用了;

      TL;DR

      “无法识别”的参数格式错误;

      【讨论】:

        猜你喜欢
        • 2021-12-13
        • 1970-01-01
        • 2020-05-05
        • 1970-01-01
        • 2019-07-14
        • 2013-08-09
        • 2015-02-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多