如何为AWS APIGateway Stage设置CloudWatch设置

时间:2016-04-25 17:26:17

标签: java amazon-web-services aws-api-gateway amazon-cloudwatch

在AWS ApiGateway中,在使用JAVA api部署新阶段后,如何使用Java API而不是通过aws控制台启用CloudWatch设置?

对于create-stage,我可以在MethodSetting输出下的CreateStage中获取CloudWatch设置,但在创建阶段或创建部署时无法设置设置。

1 个答案:

答案 0 :(得分:1)

您应该能够使用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);