Example usage for com.amazonaws.services.lambda.model CreateFunctionRequest setCode

List of usage examples for com.amazonaws.services.lambda.model CreateFunctionRequest setCode

Introduction

In this page you can find the example usage for com.amazonaws.services.lambda.model CreateFunctionRequest setCode.

Prototype


public void setCode(FunctionCode code) 

Source Link

Document

The code for the function.

Usage

From source file:com.netflix.spinnaker.clouddriver.lambda.deploy.ops.CreateLambdaAtomicOperation.java

License:Apache License

private CreateFunctionResult createFunction() {
    FunctionCode code = new FunctionCode().withS3Bucket(description.getProperty("s3bucket").toString())
            .withS3Key(description.getProperty("s3key").toString());

    Map<String, String> objTag = new HashMap<>();
    for (Map<String, String> tags : description.getTags()) {
        for (Entry<String, String> entry : tags.entrySet()) {
            objTag.put(entry.getKey(), entry.getValue());
        }//from w w w  .j  a v  a2s.c  om
    }

    AWSLambda client = getLambdaClient();

    CreateFunctionRequest request = new CreateFunctionRequest();
    request.setFunctionName(description.getFunctionName());
    request.setDescription(description.getDescription());
    request.setHandler(description.getHandler());
    request.setMemorySize(description.getMemory());
    request.setPublish(description.getPublish());
    request.setRole(description.getRole());
    request.setRuntime(description.getRuntime());
    request.setTimeout(description.getTimeout());

    request.setCode(code);
    request.setTags(objTag);

    CreateFunctionResult result = client.createFunction(request);
    updateTaskStatus("Finished Creation of AWS Lambda Function Operation...");

    return result;
}