使用 aws cli 向 aws api 网关添加标签

Add a tag to aws api gateway using aws cli

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

尝试过

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

提前致谢

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

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

可以找到api网关的arn格式

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