forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#14598 from patriot1burke/api-gateway-htt…
…p-event-v2 Upgrade amazon-lambda-http to use API Gateway 2.0 http event
- Loading branch information
Showing
48 changed files
with
1,819 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-amazon-lambda-http-v1-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>quarkus-amazon-lambda-http-v1-deployment</artifactId> | ||
<name>Quarkus - Amazon Lambda HTTP V1 - Deployment</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-core-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-vertx-http-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-amazon-lambda-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-amazon-lambda-http-v1</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-processor</artifactId> | ||
<version>${project.version}</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
83 changes: 83 additions & 0 deletions
83
...ent/src/main/java/io/quarkus/amazon/lambda/http/deployment/AmazonLambdaHttpProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package io.quarkus.amazon.lambda.http.deployment; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
import io.quarkus.amazon.lambda.deployment.LambdaUtil; | ||
import io.quarkus.amazon.lambda.deployment.ProvidedAmazonLambdaHandlerBuildItem; | ||
import io.quarkus.amazon.lambda.http.LambdaHttpHandler; | ||
import io.quarkus.amazon.lambda.http.model.AlbContext; | ||
import io.quarkus.amazon.lambda.http.model.ApiGatewayAuthorizerContext; | ||
import io.quarkus.amazon.lambda.http.model.ApiGatewayRequestIdentity; | ||
import io.quarkus.amazon.lambda.http.model.AwsProxyRequest; | ||
import io.quarkus.amazon.lambda.http.model.AwsProxyRequestContext; | ||
import io.quarkus.amazon.lambda.http.model.AwsProxyResponse; | ||
import io.quarkus.amazon.lambda.http.model.CognitoAuthorizerClaims; | ||
import io.quarkus.amazon.lambda.http.model.ErrorModel; | ||
import io.quarkus.amazon.lambda.http.model.Headers; | ||
import io.quarkus.amazon.lambda.http.model.MultiValuedTreeMap; | ||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.builditem.LaunchModeBuildItem; | ||
import io.quarkus.deployment.builditem.SystemPropertyBuildItem; | ||
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; | ||
import io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem; | ||
import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem; | ||
import io.quarkus.runtime.LaunchMode; | ||
import io.quarkus.vertx.http.deployment.RequireVirtualHttpBuildItem; | ||
import io.vertx.core.file.impl.FileResolver; | ||
|
||
public class AmazonLambdaHttpProcessor { | ||
private static final Logger log = Logger.getLogger(AmazonLambdaHttpProcessor.class); | ||
|
||
@BuildStep | ||
public RequireVirtualHttpBuildItem requestVirtualHttp(LaunchModeBuildItem launchMode) { | ||
return launchMode.getLaunchMode() == LaunchMode.NORMAL ? RequireVirtualHttpBuildItem.MARKER : null; | ||
} | ||
|
||
@BuildStep | ||
public ProvidedAmazonLambdaHandlerBuildItem setHandler() { | ||
return new ProvidedAmazonLambdaHandlerBuildItem(LambdaHttpHandler.class, "AWS Lambda HTTP"); | ||
} | ||
|
||
@BuildStep | ||
public void registerReflectionClasses(BuildProducer<ReflectiveClassBuildItem> reflectiveClassBuildItemBuildProducer) { | ||
reflectiveClassBuildItemBuildProducer | ||
.produce(new ReflectiveClassBuildItem(true, true, true, | ||
AlbContext.class, | ||
ApiGatewayAuthorizerContext.class, | ||
ApiGatewayRequestIdentity.class, | ||
AwsProxyRequest.class, | ||
AwsProxyRequestContext.class, | ||
AwsProxyResponse.class, | ||
CognitoAuthorizerClaims.class, | ||
ErrorModel.class, | ||
Headers.class, | ||
MultiValuedTreeMap.class)); | ||
} | ||
|
||
/** | ||
* Lambda provides /tmp for temporary files. Set vertx cache dir | ||
*/ | ||
@BuildStep | ||
void setTempDir(BuildProducer<SystemPropertyBuildItem> systemProperty) { | ||
systemProperty.produce(new SystemPropertyBuildItem(FileResolver.CACHE_DIR_BASE_PROP_NAME, "/tmp")); | ||
} | ||
|
||
@BuildStep | ||
public void generateScripts(OutputTargetBuildItem target, | ||
BuildProducer<ArtifactResultBuildItem> artifactResultProducer) throws Exception { | ||
String lambdaName = LambdaUtil.artifactToLambda(target.getBaseName()); | ||
|
||
String output = LambdaUtil.copyResource("lambda/bootstrap-example.sh"); | ||
LambdaUtil.writeFile(target, "bootstrap-example.sh", output); | ||
|
||
output = LambdaUtil.copyResource("http/sam.jvm.yaml") | ||
.replace("${lambdaName}", lambdaName); | ||
LambdaUtil.writeFile(target, "sam.jvm.yaml", output); | ||
|
||
output = LambdaUtil.copyResource("http/sam.native.yaml") | ||
.replace("${lambdaName}", lambdaName); | ||
LambdaUtil.writeFile(target, "sam.native.yaml", output); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
extensions/amazon-lambda-http-v1/deployment/src/main/resources/http/sam.jvm.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
Description: AWS Serverless Quarkus HTTP - ${artifactId} | ||
Globals: | ||
Api: | ||
EndpointConfiguration: REGIONAL | ||
BinaryMediaTypes: | ||
- "*/*" | ||
|
||
Resources: | ||
${lambdaName}: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Handler: io.quarkus.amazon.lambda.runtime.QuarkusStreamHandler::handleRequest | ||
Runtime: java11 | ||
CodeUri: function.zip | ||
MemorySize: 512 | ||
Policies: AWSLambdaBasicExecutionRole | ||
Timeout: 15 | ||
Events: | ||
GetResource: | ||
Type: Api | ||
Properties: | ||
Path: /{proxy+} | ||
Method: any | ||
|
||
Outputs: | ||
${lambdaName}Api: | ||
Description: URL for application | ||
Value: !Sub 'https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/' | ||
Export: | ||
Name: ${lambdaName}Api |
Oops, something went wrong.