Skip to content

Commit 23dd0b4

Browse files
committed
Add lambda entrypoint to determine AUTOGRAPH_ROOT_HASH
1 parent 3677d36 commit 23dd0b4

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

docker-compose.yml

-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ services:
8282
- AUTOGRAPH_KEY=19zd4w3xirb5syjgdx8atq6g91m03bdsmzjifs2oddivswlu9qs
8383
# set a non-empty value to use the lambda handler
8484
- LAMBDA_TASK_ROOT=/usr/local/bin/
85-
- AUTOGRAPH_ROOT_HASH
8685
ports:
8786
- "9000:8080"
8887
links:
@@ -103,7 +102,6 @@ services:
103102
- AUTOGRAPH_KEY=19zd4w3xirb5syjgdx8atq6g91m03bdsmzjifs2oddivswlu9qs
104103
# set a non-empty value to use the lambda handler
105104
- LAMBDA_TASK_ROOT=/usr/local/bin/
106-
- AUTOGRAPH_ROOT_HASH
107105
ports:
108106
- "9001:8080"
109107
links:

tools/autograph-monitor/Dockerfile.lambda-emulator

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ FROM autograph-app
22

33
USER root
44

5-
RUN cp /app/src/autograph/bin/test_monitor.sh /usr/local/bin/test_monitor.sh
5+
ADD test_monitor.sh /usr/local/bin/test_monitor.sh
66
RUN curl -Lo /usr/local/bin/aws-lambda-rie \
7-
https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie \
8-
&& \
9-
chmod +x /usr/local/bin/aws-lambda-rie /usr/local/bin/test_monitor.sh
7+
https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && \
8+
chmod +x /usr/local/bin/aws-lambda-rie
9+
10+
# Use an entrypoint to determine the AUTOGRAPH_ROOT_HASH
11+
COPY lambda-setup-entrypoint.sh /usr/local/bin/lambda-setup-entrypoint.sh
12+
ENTRYPOINT ["/usr/local/bin/lambda-setup-entrypoint.sh"]
1013

1114
USER app
12-
CMD ["/usr/local/bin/aws-lambda-rie", "/go/bin/autograph-monitor"]
15+
CMD ["/go/bin/autograph-monitor"]

bin/test_monitor.sh renamed to tools/autograph-monitor/lambda-setup-entrypoint.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export AUTOGRAPH_ROOT_HASH=$(autograph-client -t "$AUTOGRAPH_URL" -listconfig no
88
jq -r '.cacert' | openssl x509 -outform der | openssl dgst -sha256 -hex | \
99
awk '{print $2}' | tr '[:lower:]' '[:upper:]')
1010

11-
# invoke a test monitor run in a lambda monitor
12-
MONITOR_ERROR=$(curl -w '\n' -X POST 'http://localhost:8080/2015-03-31/functions/function/invocations' -d '{}')
13-
test "$MONITOR_ERROR = null"
11+
echo "Autograph instance: $AUTOGRAPH_URL"
12+
echo "Got Root hash: $AUTOGRAPH_ROOT_HASH"
13+
echo "Starting lambda: $@"
14+
/usr/local/bin/aws-lambda-rie "$@"
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
MONITOR_ENDPOINT=${1:-"http://localhost:8080"}
7+
8+
# invoke a test monitor run in a lambda monitor
9+
MONITOR_ERROR=$(curl -w '\n' -X POST "$MONITOR_ENDPOINT/2015-03-31/functions/function/invocations" -d '{}')
10+
test "$MONITOR_ERROR = null"

0 commit comments

Comments
 (0)