From a6902f223f7832caee606fec52ce493df65d55ec Mon Sep 17 00:00:00 2001 From: Jithendar12 Date: Thu, 26 Dec 2024 16:38:16 +0530 Subject: [PATCH] Set Java 11 as default and enable Java version specification via docker build arguments --- athena-snowflake/Dockerfile | 10 +++++++++- athena-snowflake/athena-snowflake.yaml | 10 ---------- pom.xml | 18 +++++++++++++----- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/athena-snowflake/Dockerfile b/athena-snowflake/Dockerfile index 82940ff28a..afffececef 100644 --- a/athena-snowflake/Dockerfile +++ b/athena-snowflake/Dockerfile @@ -1,4 +1,12 @@ -FROM public.ecr.aws/lambda/java:17 +# Argument for Java version, defaulting to 11 +ARG JAVA_VERSION=11 +# Use the specified version of Java +FROM public.ecr.aws/lambda/java:${JAVA_VERSION} + +# Argument for Java tool options, defaulting to an empty string +ARG JAVA_TOOL_OPTIONS="" +# Set the JAVA_TOOL_OPTIONS environment variable for Java 17 +ENV JAVA_TOOL_OPTIONS=${JAVA_TOOL_OPTIONS} # Copy function code and runtime dependencies from Maven layout COPY target/athena-snowflake.zip ${LAMBDA_TASK_ROOT} diff --git a/athena-snowflake/athena-snowflake.yaml b/athena-snowflake/athena-snowflake.yaml index 640d3404c7..7b86121621 100644 --- a/athena-snowflake/athena-snowflake.yaml +++ b/athena-snowflake/athena-snowflake.yaml @@ -54,21 +54,12 @@ Parameters: Description: "(Optional) An IAM policy ARN to use as the PermissionsBoundary for the created Lambda function's execution role" Default: '' Type: String - JavaVersion: - Description: "(Optional) Specify the Java version for the Lambda function. Default is '17'; use '11' for Java 11 or '8' for Java 8." - Type: String - AllowedValues: - - "17" - - "11" - - "8" - Default: "17" Conditions: HasPermissionsBoundary: !Not [ !Equals [ !Ref PermissionsBoundaryARN, "" ] ] HasSecurityGroups: !Not [ !Equals [ !Join ["", !Ref SecurityGroupIds], "" ] ] HasSubnets: !Not [ !Equals [ !Join ["", !Ref SubnetIds], "" ] ] IsRegionBAH: !Equals [!Ref "AWS::Region", "me-south-1"] IsRegionHKG: !Equals [!Ref "AWS::Region", "ap-east-1"] - IsJava17: !Equals [!Ref JavaVersion, "17"] Resources: JdbcConnectorConfig: Type: 'AWS::Serverless::Function' @@ -79,7 +70,6 @@ Resources: spill_bucket: !Ref SpillBucket spill_prefix: !Ref SpillPrefix default: !Ref DefaultConnectionString - JAVA_TOOL_OPTIONS: !If [IsJava17, "--add-opens=java.base/java.nio=ALL-UNNAMED", !Ref "AWS::NoValue"] FunctionName: !Ref LambdaFunctionName PackageType: "Image" ImageUri: !Sub diff --git a/pom.xml b/pom.xml index fbb14673b4..01010db816 100644 --- a/pom.xml +++ b/pom.xml @@ -9,11 +9,7 @@ The Amazon Athena Query Federation SDK allows you to customize Amazon Athena with your own code. https://github.com/awslabs/aws-athena-query-federation - - - - - 17 + 11 3.13.0 2.29.29 @@ -387,11 +383,23 @@ + + java8 + + 1.8 + + + 8 + + java17 17 + + 17 +