首页 > 解决方案 > 使用 aws cli 向 aws api 网关添加标签

问题描述

我正在尝试使用 aws cli 将标签添加到现有的 restApi。

试过

aws apigateway update-rest-api --rest-api-id ${rest_api_id} --patch-operations op=add,path=/tags/keytest,value='testvalue'

并得到

An error occurred (BadRequestException) when calling the UpdateRestApi operation: Invalid patch path /tags/keytest

提前致谢

标签: amazon-web-servicesaws-api-gatewayaws-clirest

解决方案


您需要使用tag-resource方法而不是update-rest-api

aws apigateway tag-resource --resource-arn your-api-gateway-arn --tags tag-name=tag-value

api网关的arn格式可以在这里找到

编辑:这将更新阶段标签。


推荐阅读