【问题标题】:Error parsing parameter '--change-batch': Expected: '=', received: ' ' for input:解析参数“--change-batch”时出错:预期:“=”,接收到:“”用于输入:
【发布时间】:2020-08-19 19:38:36
【问题描述】:

我想更新 CNAME 记录。当我运行下面的 powershell 脚本时,我得到了Error parsing parameter '--change-batch': Expected: '=', received: ' ' for input:。我看到 here 中提到的另一个 aws 命令的类似错误。我确认我正在使用file://,正如那里所建议的那样。我还看到了另一个post,我确认我没有前面或后面的双引号或单引号。我能够验证 json 数据并确保该文件存在于同一目录中。我不知道发生了什么。任何帮助表示赞赏。我的powershell脚本如下。

$json = '{"Changes": [{"Action": "UPSERT","ResourceRecordSet": {"Name": "dev.mydns.com","Type": "CNAME","TTL": 300,"ResourceRecords": [{"Value": "s-########1.server.transfer.us-east-1.amazonaws.com."}]}},{"Action": "UPSERT","ResourceRecordSet": {"Name": "qa.mydns.com","Type": "CNAME","TTL": 300,"ResourceRecords": [{"Value": "s-########2.server.transfer.us-east-1.amazonaws.com"}]}},{"Action": "UPSERT","ResourceRecordSet": {"Name": "uat.mydns.com","Type": "CNAME","TTL": 300,"ResourceRecords": [{"Value": "s-########3.server.transfer.us-east-1.amazonaws.com."}]}}]}'
$json | Out-File "route_update.json"

#I was able to get the file content and print using below commands

<#
$jsondata = Get-Content -Raw -Path route_update.json 
Write-Host $jsondata
#>

aws route53 change-resource-record-sets --hosted-zone-id <ZoneId> --change-batch file://route_update.json

【问题讨论】:

  • 正如错误所说,它需要 = 而不是空格:--change-batch=file://route_update.json
  • @MathiasR.Jessen:这不是真的。我从aws documentation 中选择了上面的示例。

标签: powershell aws-cli amazon-route53


【解决方案1】:

如果要使用 JSON 文件,相对路径(macOS/Linux)的格式为;

--change-batch file://./dnsUpdates.json

【讨论】:

  • 这与问题无关。
  • 是的。有这个确切的错误,这个答案修复了它。
【解决方案2】:

我可以直接使用 json 字符串。

aws route53 change-resource-record-sets --hosted-zone-id <ZoneId> --change-batch '{\"Changes\": [{\"Action\": \"UPSERT\",\"ResourceRecordSet\": {\"Name\": \"dev.mydns.com\",\"Type\": \"CNAME\",\"TTL\": 300,\"ResourceRecords\": [{\"Value\": \"s-########1.server.transfer.us-east-1.amazonaws.com.\"}]}}]}'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-06
    • 1970-01-01
    • 2020-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-16
    • 2020-06-12
    相关资源
    最近更新 更多