Example usage for com.amazonaws.services.lambda AWSLambda getFunction

List of usage examples for com.amazonaws.services.lambda AWSLambda getFunction

Introduction

In this page you can find the example usage for com.amazonaws.services.lambda AWSLambda getFunction.

Prototype

GetFunctionResult getFunction(GetFunctionRequest getFunctionRequest);

Source Link

Document

Returns information about the function or function version, with a link to download the deployment package that's valid for 10 minutes.

Usage

From source file:jp.classmethod.aws.gradle.lambda.AWSLambdaMigrateFunctionTask.java

License:Apache License

@TaskAction
public void createOrUpdateFunction() throws FileNotFoundException, IOException {
    // to enable conventionMappings feature
    String functionName = getFunctionName();
    File zipFile = getZipFile();//from www  . ja v  a 2s  .  co m
    S3File s3File = getS3File();

    if (functionName == null) {
        throw new GradleException("functionName is required");
    }

    if ((zipFile == null && s3File == null) || (zipFile != null && s3File != null)) {
        throw new GradleException("exactly one of zipFile or s3File is required");
    }
    if (s3File != null) {
        s3File.validate();
    }

    AWSLambdaPluginExtension ext = getProject().getExtensions().getByType(AWSLambdaPluginExtension.class);
    AWSLambda lambda = ext.getClient();

    try {
        GetFunctionResult getFunctionResult = lambda
                .getFunction(new GetFunctionRequest().withFunctionName(functionName));
        FunctionConfiguration config = getFunctionResult.getConfiguration();
        if (config == null) {
            config = new FunctionConfiguration().withRuntime(Runtime.Nodejs);
        }

        updateFunctionCode(lambda);
        updateFunctionConfiguration(lambda, config);
    } catch (ResourceNotFoundException e) {
        getLogger().warn(e.getMessage());
        getLogger().warn("Creating function... {}", functionName);
        createFunction(lambda);
    }
}

From source file:org.xmlsh.aws.gradle.lambda.AWSLambdaMigrateFunctionTask.java

License:BSD License

@TaskAction
public void createOrUpdateFunction() throws FileNotFoundException, IOException {
    // to enable conventionMappings feature
    String functionName = getFunctionName();

    if (functionName == null)
        throw new GradleException("functionName is required");

    if ((zipFile == null && s3File == null) || (zipFile != null && s3File != null)) {
        throw new GradleException("exactly one of zipFile or s3File is required");
    }/*from w ww  .ja v a  2 s. com*/
    if (s3File != null) {
        s3File.validate();
    }

    AWSLambdaPluginExtension ext = getProject().getExtensions().getByType(AWSLambdaPluginExtension.class);
    AWSLambda lambda = ext.getClient();

    try {
        GetFunctionResult getFunctionResult = lambda
                .getFunction(new GetFunctionRequest().withFunctionName(functionName));
        updateStack(lambda, getFunctionResult);
    } catch (ResourceNotFoundException e) {
        getLogger().warn(e.getMessage());
        getLogger().warn("Creating function... {}", functionName);
        createFunction(lambda);
    }
}