-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabled RDS Certs for Oracle DB (#2473)
Co-authored-by: AbdulRehman Faraj <arfaraj@amazon.com>
- Loading branch information
1 parent
d0376e4
commit c8371be
Showing
2 changed files
with
37 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,42 @@ | ||
FROM public.ecr.aws/lambda/java:11 | ||
|
||
# Install necessary tools | ||
RUN yum update -y && yum install -y curl perl openssl | ||
|
||
ENV truststore=${LAMBDA_TASK_ROOT}/rds-truststore.jks | ||
ENV storepassword=federationStorePass | ||
|
||
# Download and process the RDS certificate | ||
RUN curl -sS "https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem" > ${LAMBDA_TASK_ROOT}/global-bundle.pem && \ | ||
awk 'split_after == 1 {n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1}{print > "rds-ca-" n ".pem"}' < ${LAMBDA_TASK_ROOT}/global-bundle.pem | ||
|
||
# Import certificates into the truststore | ||
RUN for CERT in rds-ca-*; do \ | ||
alias=$(openssl x509 -noout -text -in $CERT | perl -ne 'next unless /Subject:/; s/.*(CN=|CN = )//; print') && \ | ||
echo "Importing $alias" && \ | ||
keytool -import -file ${CERT} -alias "${alias}" -storepass ${storepassword} -keystore ${truststore} -noprompt && \ | ||
rm $CERT; \ | ||
done | ||
|
||
# Clean up | ||
RUN rm ${LAMBDA_TASK_ROOT}/global-bundle.pem | ||
|
||
# Optional: List the content of the trust store (for verification) | ||
RUN echo "Trust store content is: " && \ | ||
keytool -list -v -keystore "$truststore" -storepass ${storepassword} | grep Alias | cut -d " " -f3- | while read alias; do \ | ||
expiry=$(keytool -list -v -keystore "$truststore" -storepass ${storepassword} -alias "${alias}" | grep Valid | perl -ne 'if(/until: (.*?)\n/) { print "$1\n"; }'); \ | ||
echo " Certificate ${alias} expires in '$expiry'"; \ | ||
done | ||
|
||
# Copy function code and runtime dependencies from Maven layout | ||
COPY target/athena-oracle-2022.47.1.jar ${LAMBDA_TASK_ROOT} | ||
# Unpack the jar | ||
RUN jar xf athena-oracle-2022.47.1.jar | ||
|
||
# Clean up JAR | ||
RUN rm ${LAMBDA_TASK_ROOT}/athena-oracle-2022.47.1.jar | ||
|
||
# Command can be overwritten by providing a different command in the template directly. | ||
# No need to specify here (already defined in .yaml file because legacy and connections use different) | ||
# Set the CMD to your handler by removing the following comment for manual testing | ||
# CMD [ "com.amazonaws.athena.connectors.oracle.OracleCompositeHandler" ] |
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