解析参数“--change-batch”时出错:预期:“=”,收到:“”用于输入:

Error parsing parameter '--change-batch': Expected: '=', received: ' ' for input:

我想更新 CNAME 记录。当我 运行 下面的 powershell 脚本时,我得到 Error parsing parameter '--change-batch': Expected: '=', received: ' ' for input:。我在 for another aws command. I verified that I am using file:// as suggested there. I also saw another 中看到了类似的错误,并且我确认我没有前面或后面的双引号或单引号。我能够验证 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

我能够直接使用 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.\"}]}}]}'

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

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