Example usage for com.amazonaws.services.lambda.model UpdateFunctionCodeRequest UpdateFunctionCodeRequest

List of usage examples for com.amazonaws.services.lambda.model UpdateFunctionCodeRequest UpdateFunctionCodeRequest

Introduction

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

Prototype

UpdateFunctionCodeRequest

Source Link

Usage

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

License:Apache License

private UpdateFunctionCodeResult updateFunctionConfigurationResult() {
    LambdaFunction lambdaFunction = (LambdaFunction) lambdaFunctionProvider
            .getFunction(description.getAccount(), description.getRegion(), description.getFunctionName());

    AWSLambda client = getLambdaClient();

    UpdateFunctionCodeRequest request = new UpdateFunctionCodeRequest()
            .withFunctionName(lambdaFunction.getFunctionArn()).withPublish(description.getPublish())
            .withS3Bucket(description.getS3Bucket()).withS3Key(description.getS3Key());

    UpdateFunctionCodeResult result = client.updateFunctionCode(request);
    updateTaskStatus("Finished Updating of AWS Lambda Function Code Operation...");

    return result;
}

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

License:Apache License

private void updateFunctionCode(AWSLambda lambda) throws IOException {
    // to enable conventionMappings feature
    File zipFile = getZipFile();//  www. j a  v  a  2  s .  co  m
    S3File s3File = getS3File();

    UpdateFunctionCodeRequest request = new UpdateFunctionCodeRequest().withFunctionName(getFunctionName());
    if (zipFile != null) {
        try (RandomAccessFile raf = new RandomAccessFile(getZipFile(), "r");
                FileChannel channel = raf.getChannel()) {
            MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
            buffer.load();
            request = request.withZipFile(buffer);
        }
    } else {
        // assume s3File is not null
        request = request.withS3Bucket(s3File.getBucketName()).withS3Key(s3File.getKey())
                .withS3ObjectVersion(s3File.getObjectVersion());
    }
    UpdateFunctionCodeResult updateFunctionCode = lambda.updateFunctionCode(request);
    getLogger().info("Update Lambda function requested: {}", updateFunctionCode.getFunctionArn());
}

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

License:Apache License

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

    if (functionName == null) {
        throw new GradleException("functionName is required");
    }//w  w w .j a  v  a2 s  .  c  om

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

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

    UpdateFunctionCodeRequest request = new UpdateFunctionCodeRequest().withFunctionName(getFunctionName());
    if (zipFile != null) {
        try (RandomAccessFile raf = new RandomAccessFile(getZipFile(), "r");
                FileChannel channel = raf.getChannel()) {
            MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
            buffer.load();
            request = request.withZipFile(buffer);
        }
    } else {
        // assume s3File is not null
        s3File.validate();
        request = request.withS3Bucket(s3File.getBucketName()).withS3Key(s3File.getKey())
                .withS3ObjectVersion(s3File.getObjectVersion());
    }
    UpdateFunctionCodeResult updateFunctionCode = lambda.updateFunctionCode(request);
    getLogger().info("Update Lambda function requested: {}", updateFunctionCode.getFunctionArn());
}

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

License:BSD License

private void updateFunctionCode(AWSLambda lambda) throws IOException {
    UpdateFunctionCodeRequest request = new UpdateFunctionCodeRequest().withFunctionName(getFunctionName());
    if (zipFile != null) {
        try (RandomAccessFile raf = new RandomAccessFile(getZipFile(), "r");
                FileChannel channel = raf.getChannel()) {
            MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
            buffer.load();/*from  w ww. j  a  v  a 2  s  .c  o m*/
            request = request.withZipFile(buffer);
        }
    } else {
        // assume s3File is not null
        request = request.withS3Bucket(s3File.getBucketName()).withS3Key(s3File.getKey())
                .withS3ObjectVersion(s3File.getObjectVersion());
    }
    UpdateFunctionCodeResult updateFunctionCode = lambda.updateFunctionCode(request);
    getLogger().info("Update Lambda function requested: {}", updateFunctionCode.getFunctionArn());
}

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

License:BSD License

@TaskAction
public void updateFunctionCode() 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  ww w . ja  va  2  s  .co  m

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

    UpdateFunctionCodeRequest request = new UpdateFunctionCodeRequest().withFunctionName(getFunctionName());
    if (zipFile != null) {
        try (RandomAccessFile raf = new RandomAccessFile(getZipFile(), "r");
                FileChannel channel = raf.getChannel()) {
            MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
            buffer.load();
            request = request.withZipFile(buffer);
        }
    } else {
        // assume s3File is not null
        s3File.validate();
        request = request.withS3Bucket(s3File.getBucketName()).withS3Key(s3File.getKey())
                .withS3ObjectVersion(s3File.getObjectVersion());
    }
    UpdateFunctionCodeResult updateFunctionCode = lambda.updateFunctionCode(request);
    getLogger().info("Update Lambda function requested: {}", updateFunctionCode.getFunctionArn());
}