Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add lambda architecture support to java plugin #282

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

# [1.12.0] - 2024-01-30
### Added
- The @LambdaHandler annotation for Java plugin improved to support the lambda 'architecture' management
- The Java example 'java-layer-url' extended to use Lambda architecture management
### Changed
- The deployment-configuration-processor version bumped to 1.11.0

# [1.11.0] - 2024-01-26
- Implemented lambda function processor architecture type management

Expand Down
4 changes: 2 additions & 2 deletions examples/java/demo-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<dependency>
<groupId>net.sf.aws-syndicate</groupId>
<artifactId>deployment-configuration-annotations</artifactId>
<version>1.10.0</version>
<version>1.11.0</version>
</dependency>
</dependencies>

Expand All @@ -48,7 +48,7 @@
<plugin>
<groupId>net.sf.aws-syndicate</groupId>
<artifactId>deployment-configuration-maven-plugin</artifactId>
<version>1.10.0</version>
<version>1.11.0</version>
<configuration>
<packages>
<package>com.aws.syndicate.demo</package>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.syndicate.deployment.annotations.LambdaUrlConfig;
import com.syndicate.deployment.annotations.lambda.LambdaHandler;
import com.syndicate.deployment.annotations.lambda.LambdaLayer;
import com.syndicate.deployment.model.Architecture;
import com.syndicate.deployment.model.ArtifactExtension;
import com.syndicate.deployment.model.DeploymentRuntime;
import com.syndicate.deployment.model.lambda.url.AuthType;
Expand All @@ -22,7 +23,9 @@
@LambdaHandler(
lambdaName = "hello-lambda",
roleName = "hello-lambda-role",
layers = {"sdk-layer"}
layers = {"sdk-layer"},
runtime = DeploymentRuntime.JAVA11,
architecture = Architecture.ARM64
)
@LambdaLayer(
layerName = "sdk-layer",
Expand Down
11 changes: 3 additions & 8 deletions examples/java/demo-layer-url/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,14 @@

<properties>
<maven-shade-plugin.version>3.2.0</maven-shade-plugin.version>
<deployment-configuration-annotations.version>1.10.0</deployment-configuration-annotations.version>
<syndicate.java.plugin.version>1.11.0</syndicate.java.plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<src.dir>jsrc/main/java</src.dir>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
<!--AWS dependencies-->
<dependency>
<groupId>com.amazonaws</groupId>
Expand All @@ -38,7 +33,7 @@
<dependency>
<groupId>net.sf.aws-syndicate</groupId>
<artifactId>deployment-configuration-annotations</artifactId>
<version>${deployment-configuration-annotations.version}</version>
<version>${syndicate.java.plugin.version}</version>
</dependency>
<!--Custom dependencies (for sdk layer)-->
<dependency>
Expand All @@ -63,7 +58,7 @@
<plugin>
<groupId>net.sf.aws-syndicate</groupId>
<artifactId>deployment-configuration-maven-plugin</artifactId>
<version>${deployment-configuration-annotations.version}</version>
<version>${syndicate.java.plugin.version}</version>
<configuration>
<packages>
<package>com.aws.lambda</package>
Expand Down
4 changes: 2 additions & 2 deletions plugin/deployment-configuration-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>net.sf.aws-syndicate</groupId>
<artifactId>deployment-configuration-processor</artifactId>
<version>1.10.0</version>
<version>1.11.0</version>
</parent>

<artifactId>deployment-configuration-annotations</artifactId>
<version>1.10.0</version>
<version>1.11.0</version>
<packaging>jar</packaging>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.syndicate.deployment.annotations.DeploymentResource;
import com.syndicate.deployment.model.DeploymentRuntime;
import com.syndicate.deployment.model.Architecture;
import com.syndicate.deployment.model.LambdaSnapStart;
import com.syndicate.deployment.model.RegionScope;
import com.syndicate.deployment.model.TracingMode;
Expand Down Expand Up @@ -47,6 +48,8 @@

DeploymentRuntime runtime() default DeploymentRuntime.JAVA8;

Architecture architecture() default Architecture.X86_64;

int timeout() default 300;

int memory() default 1024;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2018 EPAM Systems, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.syndicate.deployment.model;

import com.fasterxml.jackson.annotation.JsonValue;

/**
* Created by Roman Ivanov on 1/29/2024.
*/
public enum Architecture {

X86_64("x86_64"),
ARM64("arm64");

private final String name;

Architecture(String name) {
this.name = name;
}

@JsonValue
public String getName() {
return name;
}

@Override
public String toString() {
return "Architecture{" +
"name='" + name + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public class LambdaConfiguration {
@JsonProperty("runtime")
private DeploymentRuntime runtime;

@JsonProperty("architecture")
private Architecture architecture;

@JsonProperty("iam_role_name")
private String role;

Expand Down Expand Up @@ -163,6 +166,10 @@ public DeploymentRuntime getRuntime() {
return runtime;
}

public Architecture getArchitecture() {
return architecture;
}

public String getRole() {
return role;
}
Expand Down Expand Up @@ -328,6 +335,12 @@ public Builder withRuntime(DeploymentRuntime deploymentRuntime) {
return this;
}

public Builder withArchitecture(Architecture architecture) {
Objects.requireNonNull(architecture, "Architecture cannot be null");
configuration.architecture = architecture;
return this;
}

public Builder withRole(String role) {
Objects.requireNonNull(role, "Role cannot be null");
configuration.role = role;
Expand Down Expand Up @@ -437,6 +450,7 @@ public LambdaConfiguration build() {
Objects.requireNonNull(configuration.packageName, "Package name cannot be null");
Objects.requireNonNull(configuration.resourceType, "ResourceType cannot be null");
Objects.requireNonNull(configuration.runtime, "DeploymentRuntime cannot be null");
Objects.requireNonNull(configuration.architecture, "Architecture cannot be null");
Objects.requireNonNull(configuration.role, "Role cannot be null");
if (configuration.memory <= 0) {
throw new InvalidParameterException("Memory cannot be negative or 0");
Expand Down Expand Up @@ -468,6 +482,7 @@ public String toString() {
", concurrentExecutions=" + concurrentExecutions +
", resourceType=" + resourceType +
", runtime=" + runtime +
", architecture=" + architecture +
", role='" + role + '\'' +
", memory=" + memory +
", timeout=" + timeout +
Expand Down
6 changes: 3 additions & 3 deletions plugin/deployment-configuration-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>net.sf.aws-syndicate</groupId>
<artifactId>deployment-configuration-processor</artifactId>
<version>1.10.0</version>
<version>1.11.0</version>
</parent>

<artifactId>deployment-configuration-maven-plugin</artifactId>
<version>1.10.0</version>
<version>1.11.0</version>
<packaging>maven-plugin</packaging>

<properties>
Expand All @@ -28,7 +28,7 @@
<dependency>
<groupId>net.sf.aws-syndicate</groupId>
<artifactId>deployment-configuration-annotations</artifactId>
<version>1.10.0</version>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public static LambdaConfiguration createLambdaConfiguration(String version, Clas
.withRegionScope(lambdaHandler.regionScope()).withPackageName(packageName)
.withMemory(lambdaHandler.memory()).withTimeout(lambdaHandler.timeout())
.withRuntime(lambdaHandler.runtime()).withResourceType(ResourceType.LAMBDA)
.withArchitecture(lambdaHandler.architecture())
.withDependencies(dependencies).withEventSources(events)
.withVariables(variables).withSubnetIds(lambdaHandler.subnetsIds())
.withSecurityGroupIds(lambdaHandler.securityGroupIds())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public void testSyndicateGoalExecuted() throws Exception {
.withPath(folder.getRoot().getAbsolutePath())
.withRole("lr_get_notification_content")
.withRuntime(DeploymentRuntime.JAVA8)
.withArchitecture(Architecture.X86_64)
.withVersion("1.0.0")
.withTimeout(300)
.withDependencies(Collections.singleton(new DependencyItem.Builder()
Expand Down Expand Up @@ -190,6 +191,7 @@ public void testSyndicateGoalExecuted() throws Exception {
.withPath(folder.getRoot().getAbsolutePath())
.withRole("lr_get_notification_content")
.withRuntime(DeploymentRuntime.JAVA8)
.withArchitecture(Architecture.X86_64)
.withVersion("1.0.0")
.withTimeout(300)
.withDependencies(Collections.singleton(new DependencyItem.Builder()
Expand Down
2 changes: 1 addition & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.sf.aws-syndicate</groupId>
<artifactId>deployment-configuration-processor</artifactId>
<version>1.10.0</version>
<version>1.11.0</version>
<packaging>pom</packaging>

<name>aws-syndicate</name>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

setup(
name='aws-syndicate',
version='1.11.0',
version='1.12.0',
packages=find_packages(),
include_package_data=True,
install_requires=[
Expand Down
2 changes: 1 addition & 1 deletion syndicate/core/generators/contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

<properties>
<maven-shade-plugin.version>3.2.0</maven-shade-plugin.version>
<deployment-configuration-annotations.version>1.10.0</deployment-configuration-annotations.version>
<deployment-configuration-annotations.version>1.11.0</deployment-configuration-annotations.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down