{"id":18573133,"url":"https://github.com/localstack-samples/sample-lambda-neo4j","last_synced_at":"2026-02-14T12:02:57.515Z","repository":{"id":226066674,"uuid":"767529893","full_name":"localstack-samples/sample-lambda-neo4j","owner":"localstack-samples","description":"Integrating a local Lambda function with Neo4j using LocalStack","archived":false,"fork":false,"pushed_at":"2025-02-02T01:20:19.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-02T02:22:04.031Z","etag":null,"topics":["graph-database","lambda","localstack","neo4j","neo4j-lambda","serverless"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/localstack-samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-05T13:11:18.000Z","updated_at":"2025-02-02T01:20:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"e3917db0-e28c-43ce-ad5c-1a722fb2387a","html_url":"https://github.com/localstack-samples/sample-lambda-neo4j","commit_stats":null,"previous_names":["localstack-samples/sample-lambda-neo4j"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localstack-samples%2Fsample-lambda-neo4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localstack-samples%2Fsample-lambda-neo4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localstack-samples%2Fsample-lambda-neo4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localstack-samples%2Fsample-lambda-neo4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/localstack-samples","download_url":"https://codeload.github.com/localstack-samples/sample-lambda-neo4j/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239309239,"owners_count":19617848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graph-database","lambda","localstack","neo4j","neo4j-lambda","serverless"],"created_at":"2024-11-06T23:08:07.594Z","updated_at":"2025-11-01T17:30:32.131Z","avatar_url":"https://github.com/localstack-samples.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Integrating a local Lambda function with Neo4j using LocalStack\n\n| Key          | Value                                                                                         |\n| ------------ | --------------------------------------------------------------------------------------------- |\n| Environment  | LocalStack, AWS                                                                                    |\n| Services     | Lambda, CloudWatch                                                           |\n| Integrations | SAM                                                                                           |\n| Categories   | Serverless; Databases                                       |\n| Level        | Beginner                                                                                      |\n| GitHub       | [Repository link](https://github.com/localstack-samples/sample-lambda-neo4j) |\n\n## Introduction\n\nThis sample application will guide you through the process of integrating a local Lambda function with a local Neo4j database using LocalStack. We will use the Serverless Application Model (SAM) to deploy the Lambda function and spin a local Neo4j database using Docker. We will also use the AWS CLI to invoke the Lambda function and execute a sample query on the Neo4j database.\n\n## Prerequisites\n\n- [LocalStack Auth Token](https://docs.localstack.cloud/getting-started/auth-token/)\n- [Serverless Application Model](https://docs.localstack.cloud/user-guide/integrations/aws-sam/) with the [`samlocal`](https://github.com/localstack/aws-sam-cli-local) installed.\n- [AWS CLI](https://docs.localstack.cloud/user-guide/integrations/aws-cli/) with the [`awslocal` wrapper](https://docs.localstack.cloud/user-guide/integrations/aws-cli/#localstack-aws-cli-awslocal).\n- [Python 3.10](https://www.python.org/downloads/) \u0026 `pip`\n- [Docker Compose](https://docs.docker.com/compose/install/)\n\nStart LocalStack Pro with the `LOCALSTACK_AUTH_TOKEN` pre-configured:\n\n```shell\nexport LOCALSTACK_AUTH_TOKEN=\u003cyour-auth-token\u003e\ndocker-compose up\n```\n\nThe Docker Compose file will start LocalStack Pro and a local Neo4j database. The `LOCALSTACK_AUTH_TOKEN` environment variable is required to activate the LocalStack Pro features, such as Lambda Layers in this example.\n\n## Instructions\n\n### Installing the dependencies\n\nYou can install the dependencies using the following command:\n\n```shell\ncd function\npip install --target ../package/python -r requirements.txt\n```\n\n### Building the application\n\nTo build the SAM application, run the following command from the root directory of the application:\n\n```shell\nsamlocal build\n```\n\nIf you see a `Build Succeeded` message, you can proceed to the next step.\n\n\n### Deploying the application\n\nTo deploy the SAM application, run the following command:\n\n```shell\nsamlocal deploy --guided\n```\n\nThe above command will create a new managed S3 bucket to store the artifacts of the SAM application. If you want to use an existing S3 bucket, you can use the `--s3-bucket` flag to specify the bucket name. Before being deployed, the CloudFormation changeset will be displayed in the terminal. If you want to deploy the application without confirmation, you can use the `--no-confirm-changeset` flag.\n\n### Updating the Lambda function configuration\n\nYou need to update the Lambda function configuration to use the Neo4j environment variables. You can do this by running the following command:\n\n```shell\nexport NEO4J_PASSWORD=neo4j-harsh-test\nexport NEO4J_URI=bolt://neo4j:7687\nexport NEO4J_USERNAME=neo4j\nFUNCTION=$(awslocal cloudformation describe-stack-resource --stack-name sam-app --logical-resource-id function --query 'StackResourceDetail.PhysicalResourceId' --output text)\nawslocal lambda update-function-configuration \\\n    --function-name $FUNCTION \\\n    --environment \"Variables={NEO4J_USERNAME=$NEO4J_USERNAME,NEO4J_PASSWORD=$NEO4J_PASSWORD,NEO4J_URI=$NEO4J_URI}\"\n```\n\n### Invoking the Lambda function\n\nYou can invoke the Lambda function using the following command:\n\n```shell\nawslocal lambda invoke \\\n    --function-name $FUNCTION \\\n    --payload file://event.json \\\n    --cli-binary-format raw-in-base64-out out.json\n```\n\nThe following output would be displayed in the terminal:\n\n```json\n{\n    \"StatusCode\": 200,\n    \"ExecutedVersion\": \"$LATEST\"\n}\n```\n\nYou can see the following in the `out.json` file:\n\n```json\n{\"TotalCodeSize\": 29662331, \"FunctionCount\": 1}\n```\n\n### Cleaning up\n\nTo clean up the resources created by the SAM application, run the following command:\n\n```shell\ndocker-compose down\n```\n\nLocalStack is ephemeral, and all the resources will be deleted once the LocalStack process is stopped.\n\n### GitHub Action\n\nThis application sample hosts an example GitHub Action workflow that starts up LocalStack, builds the Lambda functions, and deploys the infrastructure on the runner. \n\nYou can find the workflow in the `.github/workflows/main.yml` file. To run the workflow, you can fork this repository and push a commit to the `main` branch.\n\n## License\n\n[Apache 2.0](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalstack-samples%2Fsample-lambda-neo4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flocalstack-samples%2Fsample-lambda-neo4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalstack-samples%2Fsample-lambda-neo4j/lists"}