List of usage examples for com.amazonaws.services.lambda AWSLambda updateFunctionCode
UpdateFunctionCodeResult updateFunctionCode(UpdateFunctionCodeRequest updateFunctionCodeRequest);
Updates a Lambda function's code.
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();/* w ww .ja v a 2 s .com*/ 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"); }/*ww w . j av a2 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();//ww w.j a v a2 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"); }// w ww . j ava 2 s . c o 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()); }