如何在java中使用UpdateEventSourceMappingRequest?

How to use UpdateEventSourceMappingRequest in java?

我正在尝试使用这样的东西:

UpdateEventSourceMappingRequest request = new UpdateEventSourceMappingRequest()
        .withFunctionName("arn:aws:lambda:us-east-1:9999999999:function:"+functionName)
        .withEnabled(false);

但是我收到一个错误,因为我必须使用 .withUUID(uuid):

UpdateEventSourceMappingRequest request = new UpdateEventSourceMappingRequest()
        .withUUID(uuid))
        .withFunctionName("arn:aws:lambda:us-east-1:9999999999:function:"+functionName)
        .withEnabled(false);

我不知道如何获取 uuid 的值(来自 aws lambda 的 uuid)。

你能帮我解决我的问题吗?

您需要提供事件源映射的 UUID 标识符才能更新它(此字段为 mandatory)。 Update-request 无意创建它。 当您创建事件源映射时 (here) - aws 应该 return 带有 UUID 标识符的响应,然后您可以在更新请求中使用它。

这是我创建的解决方案:

       String strUUID = "";
       ListEventSourceMappingsRequest requestList = new ListEventSourceMappingsRequest()
                .withEventSourceArn("arn:aws:sqs:us-east-1:9999999999:test");
        
        ListEventSourceMappingsResult result = awsLambda.listEventSourceMappings(requestList);
        List<EventSourceMappingConfiguration> eventSourceMappings = result.getEventSourceMappings();
        
        for (EventSourceMappingConfiguration eventLambda : eventSourceMappings) {
            strUUID = eventLambda.getUUID();
        }
        
        System.out.println("Output UUID " + strUUID);

我们必须使用触发 aws lambda 的 SQS 的 ARN。