Skip to content

Commit

Permalink
Set Java 11 as default and enable Java version specification via dock…
Browse files Browse the repository at this point in the history
…er build arguments
  • Loading branch information
Jithendar12 committed Dec 26, 2024
1 parent 30568ce commit 2f98290
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
15 changes: 12 additions & 3 deletions athena-snowflake/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
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}

# Unpack the jar
RUN jar xf athena-snowflake.zip

# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "com.amazonaws.athena.connectors.snowflake.SnowflakeMuxCompositeHandler" ]
# Set the CMD to your handler
CMD [ "com.amazonaws.athena.connectors.snowflake.SnowflakeMuxCompositeHandler" ]
10 changes: 0 additions & 10 deletions athena-snowflake/athena-snowflake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
18 changes: 13 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
<description>The Amazon Athena Query Federation SDK allows you to customize Amazon Athena with your own code.</description>
<url>https://github.com/awslabs/aws-athena-query-federation</url>
<properties>
<!-- Uncomment to target java 8 -->
<!--<maven.compiler.release>8</maven.compiler.release>-->
<!-- Uncomment to target java 11 -->
<!--<maven.compiler.release>11</maven.compiler.release>-->
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.plugin.version>3.13.0</maven.compiler.plugin.version>
<!--- to meet engine version 1.12.533-->
<aws-sdk-v2.version>2.29.29</aws-sdk-v2.version>
Expand Down Expand Up @@ -387,11 +383,23 @@
</plugins>
</build>
<profiles>
<profile>
<id>java8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.release>8</maven.compiler.release>
</properties>
</profile>
<profile>
<id>java17</id>
<activation>
<jdk>17</jdk>
</activation>
<properties>
<maven.compiler.release>17</maven.compiler.release>
</properties>
<build>
<plugins>
<plugin>
Expand Down

0 comments on commit 2f98290

Please sign in to comment.