diff --git a/README.md b/README.md index 5174d4c..fb9b506 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ All of the AWS Lambda configuration parameters may be set within the lambda plug * `lambdaFunctionsJSON` JSON configuration for Lambda Functions. This is preferable configuration. * `timeout` Defaults to 30 seconds. The amount of time in which the function is allowed to run. * `memorySize` Defaults to 1024MB NOTE: Please review the AWS Lambda documentation on this setting as it could have an impact on your billing. +* `memorySize` Defaults to 512MB NOTE: Please review the AWS Lambda documentation on this setting as it could have an impact on your billing. * `vpcSubnetIds` The VPC Subnets that Lambda should use to set up your VPC configuration. Format: "subnet-id (cidr-block) | az name-tag". * `vpcSecurityGroupIds` The VPC Security Groups that Lambda should use to set up your VPC configuration. Format: "sg-id (sg-name) | name-tag". Should be configured. * `publish` This boolean parameter can be used to request AWS Lambda to update the Lambda function and publish a version as an atomic operation. This is global for all functions and won't overwrite publish paramter in provided Lambda configuration. Setting to false will only update $LATEST. @@ -115,6 +116,7 @@ Current configuration of LambdaFunction can be found in LambdaFunction.java. "handler": "no.flowlab.lambda0::test", "timeout": 30, "memorySize": 512, + "ephemeralStorageSize": 512, "keepAlive": 15, "triggers": [ { diff --git a/pom.xml b/pom.xml index cd27b6e..ae96df4 100644 --- a/pom.xml +++ b/pom.xml @@ -48,7 +48,7 @@ - 1.12.68 + 1.12.698 UTF-8 diff --git a/src/main/java/com/github/seanroy/plugins/AbstractLambdaMojo.java b/src/main/java/com/github/seanroy/plugins/AbstractLambdaMojo.java index af8192d..32a269c 100644 --- a/src/main/java/com/github/seanroy/plugins/AbstractLambdaMojo.java +++ b/src/main/java/com/github/seanroy/plugins/AbstractLambdaMojo.java @@ -189,6 +189,15 @@ public abstract class AbstractLambdaMojo extends AbstractMojo { */ @Parameter(property = "memorySize", defaultValue = "1024") public int memorySize; + /** + *

+ * The amount of ephemeral storage, in MB, your Lambda function is given. + * The /tmp temporary filesystem is located in this area. + * The default value is 512 MB. + *

+ */ + @Parameter(property = "ephemeralStorageSize", defaultValue = "512") + public int ephemeralStorageSize; /** *

A list of one or more security groups IDs in your VPC.

*/ @@ -425,6 +434,7 @@ private void initLambdaFunctionsConfiguration() throws MojoExecutionException, I .withDescription(ofNullable(lambdaFunction.getDescription()).orElse("")) .withTimeout(ofNullable(lambdaFunction.getTimeout()).orElse(timeout)) .withMemorySize(ofNullable(lambdaFunction.getMemorySize()).orElse(memorySize)) + .withEphemeralStorageSize(ofNullable(lambdaFunction.getEphemeralStorageSize()).orElse(ephemeralStorageSize)) .withSubnetIds(ofNullable(vpcSubnetIds).orElse(new ArrayList<>())) .withSecurityGroupsIds(ofNullable(vpcSecurityGroupIds).orElse(new ArrayList<>())) .withVersion(version) diff --git a/src/main/java/com/github/seanroy/plugins/DeployLambdaMojo.java b/src/main/java/com/github/seanroy/plugins/DeployLambdaMojo.java index d5dfd00..495b91c 100644 --- a/src/main/java/com/github/seanroy/plugins/DeployLambdaMojo.java +++ b/src/main/java/com/github/seanroy/plugins/DeployLambdaMojo.java @@ -47,6 +47,7 @@ import com.amazonaws.services.lambda.model.CreateFunctionResult; import com.amazonaws.services.lambda.model.DeleteEventSourceMappingRequest; import com.amazonaws.services.lambda.model.Environment; +import com.amazonaws.services.lambda.model.EphemeralStorage; import com.amazonaws.services.lambda.model.EventSourceMappingConfiguration; import com.amazonaws.services.lambda.model.EventSourcePosition; import com.amazonaws.services.lambda.model.FunctionCode; @@ -144,6 +145,7 @@ private boolean shouldUpdate(LambdaFunction lambdaFunction, GetFunctionResult ge .withRole(lambdaFunction.getLambdaRoleArn()) .withTimeout(lambdaFunction.getTimeout()) .withMemorySize(lambdaFunction.getMemorySize()) + .withEphemeralStorage(new EphemeralStorage().withSize(lambdaFunction.getEphemeralStorageSize())) .withRuntime(runtime) .withVpcConfig(getVpcConfig(lambdaFunction)) .withEnvironment(new Environment().withVariables(lambdaFunction.getEnvironmentVariables())); @@ -448,9 +450,10 @@ private boolean isConfigurationChanged(LambdaFunction lambdaFunction, GetFunctio boolean isRoleChanged = isChangeStr.test(config.getRole(), lambdaFunction.getLambdaRoleArn()); boolean isTimeoutChanged = isChangeInt.test(config.getTimeout(), lambdaFunction.getTimeout()); boolean isMemoryChanged = isChangeInt.test(config.getMemorySize(), lambdaFunction.getMemorySize()); + boolean isEphemeralStorageChanged = isChangeInt.test(config.getEphemeralStorage().getSize(), lambdaFunction.getEphemeralStorageSize()); boolean isSecurityGroupIdsChanged = isChangeList.test(vpcConfig.getSecurityGroupIds(), lambdaFunction.getSecurityGroupIds()); boolean isVpcSubnetIdsChanged = isChangeList.test(vpcConfig.getSubnetIds(), lambdaFunction.getSubnetIds()); - return isDescriptionChanged || isHandlerChanged || isRoleChanged || isTimeoutChanged || isMemoryChanged || + return isDescriptionChanged || isHandlerChanged || isRoleChanged || isTimeoutChanged || isMemoryChanged || isEphemeralStorageChanged || isSecurityGroupIdsChanged || isVpcSubnetIdsChanged || isAliasesChanged(lambdaFunction) || isKeepAliveChanged(lambdaFunction) || isScheduleRuleChanged(lambdaFunction); }) @@ -505,6 +508,7 @@ private boolean isAliasesChanged(LambdaFunction lambdaFunction) { .withRuntime(runtime) .withTimeout(ofNullable(lambdaFunction.getTimeout()).orElse(timeout)) .withMemorySize(ofNullable(lambdaFunction.getMemorySize()).orElse(memorySize)) + .withEphemeralStorage(new EphemeralStorage().withSize(ephemeralStorageSize)) .withVpcConfig(getVpcConfig(lambdaFunction)) .withCode(new FunctionCode() .withS3Bucket(s3Bucket) diff --git a/src/main/java/com/github/seanroy/plugins/LambdaFunction.java b/src/main/java/com/github/seanroy/plugins/LambdaFunction.java index 350821f..92d93ad 100644 --- a/src/main/java/com/github/seanroy/plugins/LambdaFunction.java +++ b/src/main/java/com/github/seanroy/plugins/LambdaFunction.java @@ -41,6 +41,10 @@ public class LambdaFunction { *

@see {@link AbstractLambdaMojo}

*/ private Integer memorySize; + /** + *

@see {@link AbstractLambdaMojo}

+ */ + private Integer ephemeralStorageSize; /** *

@see {@link AbstractLambdaMojo}

*/ @@ -138,6 +142,14 @@ public void setMemorySize(Integer memorySize) { this.memorySize = memorySize; } + public Integer getEphemeralStorageSize() { + return ephemeralStorageSize; + } + + public void setEphemeralStorageSize(Integer ephemeralStorageSize) { + this.ephemeralStorageSize = ephemeralStorageSize; + } + public Integer getTimeout() { return timeout; } @@ -257,6 +269,11 @@ public LambdaFunction withMemorySize(Integer memorySize) { this.memorySize = memorySize; return this; } + + public LambdaFunction withEphemeralStorageSize(Integer ephemeralStorageSize) { + this.ephemeralStorageSize = ephemeralStorageSize; + return this; + } public LambdaFunction withSecurityGroupsIds(List securityGroupsIds) { this.securityGroupIds = securityGroupsIds; @@ -339,6 +356,7 @@ public String toString() { .append(", description='").append(description).append('\'') .append(", handler='").append(handler).append('\'') .append(", memorySize=").append(memorySize) + .append(", ephemeralStorageSize=").append(ephemeralStorageSize) .append(", timeout=").append(timeout) .append(", version='").append(version).append('\'') .append(", securityGroupIds=").append(securityGroupIds) diff --git a/src/test/resources/test-projects/basic-test/basic-pom.xml b/src/test/resources/test-projects/basic-test/basic-pom.xml index 7033598..b82c1e1 100644 --- a/src/test/resources/test-projects/basic-test/basic-pom.xml +++ b/src/test/resources/test-projects/basic-test/basic-pom.xml @@ -32,6 +32,7 @@ src/test/resources/test-projects/basic-test/lambda-test-0.0.1-SNAPSHOT.jar 0.1.1-Test 512 + 1024 us-east-1 java8 lambda-function-code @@ -45,6 +46,7 @@ "handler": "com.github.seanroy.lambduh_test::hello_world", "timeout": 30, "memorySize": 512, + "ephemeralStorageSize": 1024, "keepAlive": 2, "triggers": [ { @@ -67,6 +69,7 @@ "handler": "com.github.seanroy.lambduh_test::goodbye_world", "timeout": 45, "memorySize": 256, + "ephemeralStorageSize": 512, "topics": [], "triggers": [] }