Skip to content

Commit

Permalink
Uml 3723 golang lambda to run in localstack (#3003)
Browse files Browse the repository at this point in the history
* UML-3619 Convert incoming LPAs to combined format (repository layer)

* UML-3723 running event receiver in localstack with the use of make up
  • Loading branch information
allenannom authored Dec 12, 2024
1 parent 0370dee commit c1047bf
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
14 changes: 11 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ services:
REGION: eu-west-1
AWS_ACCESS_KEY_ID: 'devkey'
AWS_SECRET_ACCESS_KEY: 'secretdevkey'
depends_on:
- localstack
volumes:
- ./lambda-functions/upload-statistics/app:/function/app
- ./lambda-functions/.aws-lambda-rie:/aws-lambda
Expand All @@ -267,19 +269,25 @@ services:
# ---------------------------
# Lambda for ingestion from MLPA

event-reciever-lambda:
container_name: event-reciever
event-receiver-lambda:
container_name: event-receiver
build:
context: ./lambda-functions/event-receiver
dockerfile: Dockerfile
environment:
AWS_LAMBDA_SERVER_PORT: '8080'
AWS_LAMBDA_RUNTIME_API: 'localhost:8080'
ENVIRONMENT: local
REGION: eu-west-1
AWS_ACCESS_KEY_ID: 'devkey'
AWS_SECRET_ACCESS_KEY: 'secretdevkey'
volumes:
- ./lambda-functions/event-reciever/app:/function/app
- ./lambda-functions/event-receiver/app:/function/app
- ./lambda-functions/.aws-lambda-rie:/aws-lambda
entrypoint:
- /aws-lambda/aws-lambda-rie
command:
- ./main
ports:
- 9008:8080

Expand Down
7 changes: 4 additions & 3 deletions lambda-functions/event-receiver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ COPY go.mod go.sum ./
RUN go mod download

COPY app/ ./

RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o /go/bin/ingestion ./

FROM scratch AS production

COPY --from=base /go/bin/ingestion ingestion
WORKDIR /var/task

COPY --from=base /go/bin/ingestion ./main

ENTRYPOINT ["./ingestion"]
ENTRYPOINT ["./main"]
22 changes: 22 additions & 0 deletions lambda-functions/event-receiver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Event Receiver

The stats table is uploaded with historical stats from csv by a one time run script.

This uploads to the stats table, the Cloudwatch Metric Statistics about the use of the Use a Lasting Power of Attorney service.

### Testing the lambda image locally

As the lambda is built from an image, this can be spun up to test in dev environment.

Bring up the lambda locally

```
make build
```

# To test lambda
The curl follows a set command to invoke lambda functions as below

```
curl -XPOST "http://localhost:9008/2015-03-31/functions/function/invocations" -d '{}'
```
Empty file modified lambda-functions/event-receiver/app/main.go
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion lambda-functions/upload-statistics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ By default the script uses a mock JSON response object instead of pulling from a
Bring up the lambda locally

```
make build_all
make build
```

# To test lambda
Expand Down

0 comments on commit c1047bf

Please sign in to comment.