List of usage examples for com.amazonaws.services.lambda.model UpdateFunctionCodeRequest withS3Bucket
public UpdateFunctionCodeRequest withS3Bucket(String s3Bucket)
An Amazon S3 bucket in the same AWS Region as your function.
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();/* w ww . j a va 2 s . c o 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"); }//from ww w .j a v a 2 s .c o m 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();// www.java 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 w w w .j av a2 s . c om 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()); }