如何在AWS ApiGateway中为AWS APIGateway阶段设置CloudWatch设置
问题描述:
,使用JAVA API部署新阶段后,如何使用Java API而不是通过aws控制台启用CloudWatch设置?如何在AWS ApiGateway中为AWS APIGateway阶段设置CloudWatch设置
对于create-stage,我可以CreateStage
输出下获得的MethodSetting
的CloudWatch的设置,但是当我创建的阶段,我不能设置设置或创建部署。
答
你应该能够用patch request到update-stage operation
这里来更新你的舞台在CloudWatch的设置是一个示例代码段(我没有实际测试过这一点;但基本原则应该工作):
AmazonApiGateway apiGateway = ...;
UpdateStageRequest req = new UpdateStageRequest().withRestApiId(<api-id>).
withStageName(<stage-name>).
withPatchOperations(
new PatchOperation().withPath("*/*/metrics/enabled")
.withOp("replace")
.withValue("true"));
apiGateway.upate(req);
谢谢,它的工作原理,但为什么aws更喜欢使用补丁操作,而不是其他更明显的api – Jie