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

add lambda url support for Java plugin #243

Merged
merged 4 commits into from
Nov 8, 2023
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ 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.5.0] - 2023-11-08
### Added
- LambdaUrlConfig java annotation has been added to the aws-syndicate mvn plugin.
### Changed
- deployment-configuration-processor version bumped to 1.9.0.

# [1.4.0] - 2023-09-29
- Add EventBridge Scheduler support
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.7.0</version>
<version>1.9.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.7.0</version>
<version>1.9.0</version>
<configuration>
<packages>
<package>com.aws.syndicate.demo</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.8.0</version>
<version>1.9.0</version>
</parent>

<artifactId>deployment-configuration-annotations</artifactId>
<version>1.8.0</version>
<version>1.9.0</version>
<packaging>jar</packaging>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.syndicate.deployment.annotations;

import com.syndicate.deployment.model.lambda.url.AuthType;
import com.syndicate.deployment.model.lambda.url.InvokeMode;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Created by Roman Ivanov on 2023-11-07
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface LambdaUrlConfig {

AuthType authType() default AuthType.NONE;

InvokeMode invokeMode() default InvokeMode.BUFFERED;

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.syndicate.deployment.model.events.EventSourceItem;
import com.syndicate.deployment.model.lambda.url.UrlConfig;

import java.security.InvalidParameterException;
import java.util.Arrays;
Expand Down Expand Up @@ -111,6 +112,9 @@ public class LambdaConfiguration {
@JsonProperty("resource_group")
private String resourceGroup;

@JsonProperty("url_config")
private UrlConfig urlConfig;

public String getName() {
return name;
}
Expand Down Expand Up @@ -256,6 +260,10 @@ public void setSnapStart(LambdaSnapStart snapStart) {
this.snapStart = snapStart;
}

public void setUrlConfig(UrlConfig urlConfig) {
this.urlConfig = urlConfig;
}

public static class Builder {

private final LambdaConfiguration configuration = new LambdaConfiguration();
Expand Down Expand Up @@ -473,6 +481,7 @@ public String toString() {
", dlResourceType='" + dlResourceType + '\'' +
", tracingMode='" + tracingMode + '\'' +
", alias='" + alias + '\'' +
", urlConfig='" + urlConfig + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.syndicate.deployment.model.lambda.url;

/**
* Created by Roman Ivanov on 2023-11-07
*/
public enum AuthType {

NONE, AWS_IAM

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.syndicate.deployment.model.lambda.url;

/**
* Created by Roman Ivanov on 2023-11-07
*/
public enum InvokeMode {

BUFFERED, RESPONSE_STREAM

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.syndicate.deployment.model.lambda.url;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Created by Roman Ivanov on 2023-11-07
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class UrlConfig {

@JsonProperty("auth_type")
private final AuthType authType;

@JsonProperty("invoke_mode")
private final InvokeMode invokeMode;

public UrlConfig(AuthType authType, InvokeMode invokeMode) {
this.authType = authType;
this.invokeMode = invokeMode;
}

public AuthType getAuthType() {
return authType;
}

public InvokeMode getInvokeMode() {
return invokeMode;
}

@Override
public String toString() {
return "UrlConfig{" +
"authType=" + authType +
", invokeMode=" + invokeMode +
'}';
}

}
4 changes: 2 additions & 2 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.8.0</version>
<version>1.9.0</version>
</parent>

<artifactId>deployment-configuration-maven-plugin</artifactId>
<version>1.8.0</version>
<version>1.9.0</version>
<packaging>maven-plugin</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@

package com.syndicate.deployment.factories;

import com.syndicate.deployment.annotations.LambdaUrlConfig;
import com.syndicate.deployment.annotations.lambda.LambdaConcurrency;
import com.syndicate.deployment.annotations.lambda.LambdaHandler;
import com.syndicate.deployment.annotations.lambda.LambdaProvisionedConcurrency;
import com.syndicate.deployment.annotations.resources.DeadLetterConfiguration;
import com.syndicate.deployment.model.DependencyItem;
import com.syndicate.deployment.model.DeploymentRuntime;
import com.syndicate.deployment.model.LambdaConfiguration;
import com.syndicate.deployment.model.ProvisionedConcurrency;
import com.syndicate.deployment.model.ResourceType;
import com.syndicate.deployment.model.TracingMode;
import com.syndicate.deployment.model.events.EventSourceItem;
import com.syndicate.deployment.model.lambda.url.UrlConfig;

import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -97,6 +98,11 @@ public static LambdaConfiguration createLambdaConfiguration(String version, Clas
lambdaConfiguration.setDlResourceType(deadLetterConfiguration.resourceType().getServiceName());
}

LambdaUrlConfig lambdaUrlConfig = lambdaClass.getDeclaredAnnotation(LambdaUrlConfig.class);
if (lambdaUrlConfig != null) {
lambdaConfiguration.setUrlConfig(new UrlConfig(lambdaUrlConfig.authType(), lambdaUrlConfig.invokeMode()));
}

return lambdaConfiguration;
}

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.8.0</version>
<version>1.9.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.4.0',
version='1.5.0',
packages=find_packages(),
include_package_data=True,
install_requires=[
Expand Down