如何从AWS API将字符串参数传递给AWS lambda函数?

时间:2017-10-06 09:11:11

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

public String handleRequest(String input, Context context) {
    context.getLogger().log("Input: " + input);

    @SuppressWarnings("serial")
    Hashtable<String, String> htAWSServices = 
            new Hashtable <String, String> (){{
                put("Compute","For Compute - please insert like Compute1/.../Compute6");
                put("Compute1","AWS Lambda(Compute)");
                put("Compute2","AWS EC2(Compute)");
                put("Compute3","AWS EC2 Container Service(Compute)");
                put("Compute4","AWS Lightsail(Compute)");
                put("Compute5","AWS Elastic Beanstalk(Compute)");
                put("Compute6","AWS Batch(Compute)");

                put("Analytics","For Analytics - please insert like Analytics1/.../Analytics8");
                put("Analytics1","AWS Athena(Analytics)");
                put("Analytics2","AWS EMR(Analytics)");
                put("Analytics3","AWS CloudSearch(Analytics)");
                put("Analytics4","AWS Elasticsearch Service(Analytics)");
                put("Analytics5","AWS Kinesis(Analytics)");
                put("Analytics6","AWS Data Pipeline(Analytics)");
                put("Analytics7","AWS QuickSight(Analytics)");
                put("Analytics8","AWS Glue(Analytics)");
            }};

    String stOutput = "";
    String stValue = htAWSServices.get(input);

    if (stValue == null)
        stOutput = "Hello from Lambda!, "+input+"!";
    else
        stOutput = "Hello AWS has "+stValue+"!";
    return stOutput;
}

现在我将API网关中的键值传递给Lambda函数吗?

0 个答案:

没有答案