-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
122 additions
and
29 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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: CI Tests | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
id: setup-python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Install and start LocalStack | ||
env: | ||
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} | ||
run: | | ||
docker pull localstack/localstack-pro & | ||
pip install localstack terraform-local | ||
localstack start -d | ||
- name: Run tests | ||
env: | ||
LUMIGO_TRACER_TOKEN: ${{ secrets.LUMIGO_TRACER_TOKEN }} | ||
run: | | ||
make deploy | ||
make invoke |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.terraform* | ||
terraform.tfstate* |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FUNC_NAME ?= func1 | ||
|
||
usage: ## Show this help | ||
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/:.*##\s*/##/g' | awk -F'##' '{ printf "%-20s %s\n", $$1, $$2 }' | ||
|
||
deploy: ## Deploy the sample app | ||
if [ "$$LUMIGO_TRACER_TOKEN" = "" ]; then \ | ||
echo "Please configure the LUMIGO_TRACER_TOKEN environment variable"; \ | ||
exit 1; \ | ||
fi | ||
|
||
cp lambdas/handler.* /tmp/ | ||
(cd /tmp; zip testlambda.zip handler.py handler.js) | ||
|
||
tflocal init | ||
rm -f terraform.tfstate | ||
TF_VAR_LUMIGO_TRACER_TOKEN=$$LUMIGO_TRACER_TOKEN tflocal apply -auto-approve | ||
|
||
invoke: ## Invoke test Lambda function | ||
awslocal lambda invoke --function-name $(FUNC_NAME) /tmp/tmp.out | ||
|
||
hot-reload: ## Start Lambda hot reloading session | ||
awslocal lambda update-function-code --function-name $(FUNC_NAME) --s3-bucket hot-reload --s3-key "$$(pwd)/lambdas" | ||
|
||
.PHONY: deploy hot-reload |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { DynamoDB } = require('@aws-sdk/client-dynamodb'); | ||
const { SQS } = require('@aws-sdk/client-sqs'); | ||
|
||
exports.handler = async (event) => { | ||
console.log(JSON.stringify(event)); | ||
|
||
const ddb = new DynamoDB(); | ||
const result = await ddb.scan({TableName: "test"}); | ||
console.log("DynamoDB result", result); | ||
|
||
const sqs = new SQS(); | ||
const params = {QueueUrl: "http://localhost:4566/000000000000/test", MessageBody: "test 123"}; | ||
const result2 = await sqs.sendMessage(params); | ||
console.log("SQS result", result2); | ||
|
||
return "Hello from LocalStack!"; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def handler(*args, **kwargs): | ||
print("Debug output from Lambda function") |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
variable "LUMIGO_TRACER_TOKEN" { | ||
type = string | ||
} | ||
|
||
resource "aws_dynamodb_table" "test" { | ||
hash_key = "id" | ||
billing_mode = "PAY_PER_REQUEST" | ||
name = "test" | ||
|
||
attribute { | ||
name = "id" | ||
type = "S" | ||
} | ||
} | ||
|
||
resource "aws_sqs_queue" "test" { | ||
name = "test" | ||
} | ||
|
||
resource "aws_lambda_function" "func1" { | ||
function_name = "func1" | ||
role = "arn:aws:iam::000000000000:role/r1" | ||
handler = "handler.handler" | ||
runtime = "nodejs18.x" | ||
layers = ["arn:aws:lambda:us-east-1:114300393969:layer:lumigo-node-tracer:252"] | ||
# Python layer: arn:aws:lambda:us-east-1:114300393969:layer:lumigo-python-tracer:252 | ||
filename = "/tmp/testlambda.zip" | ||
timeout = 30 | ||
environment { | ||
variables = { | ||
"AWS_LAMBDA_EXEC_WRAPPER": "/opt/lumigo_wrapper", | ||
"LUMIGO_DEBUG": "true", | ||
"LUMIGO_PROPAGATE_W3": "true", | ||
"LUMIGO_TRACER_TOKEN": var.LUMIGO_TRACER_TOKEN | ||
} | ||
} | ||
} |