我正在尝试通过 CLI 更新 API 网关实例上的资源策略,但我似乎找不到正确的 JSON 语法。在文档中,它说使用“补丁操作”,据我了解,它需要一串 JSON 来表示策略。我尝试过缩小 JSON、转义 JSON、单引号、无引号,但似乎都不起作用。该文档在补丁操作的值字段中没有实际 JSON 的示例,所以我感觉有点迷失。
我一直在尝试这个命令的变体:
aws apigateway update-rest-api --rest-api-id abcde123 --patch-operations op=replace,path=/policy,value='{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":"*","Action":"execute-api:Invoke","Resource":"arn:aws:execute-api:region:000000000000:*"},{"Effect":"Deny","Principal":"*","Action":"execute-api:Invoke","Resource":"arn:aws:execute-api:region:000000000000:*","Condition":{"StringNotEquals":{"aws:SourceVpce":["vpce-123456789","vpce-987654321"]}}}]}'
我每次都会收到错误消息:
Error parsing parameter '--patch-operations': Expected: '=', received: '{' for input:
相关文档here https://docs.aws.amazon.com/cli/latest/reference/apigateway/update-resource.html.