{"id":16284439,"url":"https://github.com/nuest/aws-lambda-kvp-minimal-java","last_synced_at":"2025-04-09T00:05:20.318Z","repository":{"id":146971085,"uuid":"236755503","full_name":"nuest/aws-lambda-kvp-minimal-java","owner":"nuest","description":"A minimal example to deploy a HTTP GET-based KVP API written in Java on AWS Lambda","archived":false,"fork":false,"pushed_at":"2021-04-26T19:55:38.000Z","size":25,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-14T18:49:00.633Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nuest.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":"2020-01-28T14:34:14.000Z","updated_at":"2020-02-03T11:50:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"21670f52-9cea-459b-bcff-5e4135214213","html_url":"https://github.com/nuest/aws-lambda-kvp-minimal-java","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuest%2Faws-lambda-kvp-minimal-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuest%2Faws-lambda-kvp-minimal-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuest%2Faws-lambda-kvp-minimal-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nuest%2Faws-lambda-kvp-minimal-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nuest","download_url":"https://codeload.github.com/nuest/aws-lambda-kvp-minimal-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247947859,"owners_count":21023066,"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":[],"created_at":"2024-10-10T19:19:32.596Z","updated_at":"2025-04-09T00:05:20.284Z","avatar_url":"https://github.com/nuest.png","language":"Java","readme":"# aws-lambda-kvp-minimal-java\n\nA minimal example to deploy a HTTP GET-based KVP API written in Java on AWS Lambda.\nThe Java code make one external request and can also return an SVG image (because those are two breakthrough that I needed).\n\n## Build and deploy\n\nBuild deployment file manually and configure using AWS Cloud Console:\n\nGo to `/LambdaAPI`.\n\n```bash\nmvn clean package shade:shade\n```\n\n- [Create function](https://eu-central-1.console.aws.amazon.com/lambda/home?region=eu-central-1) _from scratch_\n  - Function name: `minimal-kvp`\n  - Runtime: `Java 8`\n  - Use _\"Create a new role with basic Lambda permissions\"_\n  - Upload jar file: `target/aws-lambda-kvp-0.1.0-SNAPSHOT.jar`\n  - Configure handler: `de.ifgi.nuest.awslambda.kvp.APIHandler::handleRequest`\n- Create API in the [API Gateway Console](https://console.aws.amazon.com/apigateway)\n  - REST API, \"New API\"\n    - Name: `Minimal REST API`\n    - Resources\n      - Proxy resource: YES\n      - Name: `API`\n      - Path: `{proxy+}`\n      - Enable API Gateway CORS: YES\n    - _/{proxy+} - ANY - Setup_\n      - Integration type: `Lambda Function Proxy`\n      - Lambda Function: `minimal-kvp`\n      - \"give API Gateway permission\"\n    - _Method Test_ from API Gateway configuration now possible\n      - Path e.g., `/api/v1`\n      - Query strings e.g., `param1=hello\u0026param2=world`\n      - Headers e.g., `x-user-request: Test`\n      - Log excerpt:\n        ```\n        Execution log for request 89d139db-4eec-4bc3-94bb-50678599bcd9\n        Mon Feb 03 09:54:45 UTC 2020 : Starting execution for request: 89d139db-4eec-4bc3-94bb-50678599bcd9\n        Mon Feb 03 09:54:45 UTC 2020 : HTTP Method: GET, Resource Path: /api/v1\n        Mon Feb 03 09:54:45 UTC 2020 : Method request path: {proxy=api/v1}\n        Mon Feb 03 09:54:45 UTC 2020 : Method request query string: {param1=hello, param2=world}\n        Mon Feb 03 09:54:45 UTC 2020 : Method request headers: {x-user-request= Test}\n        [...]\n        Mon Feb 03 09:54:46 UTC 2020 : Received response. Status: 200, Integration latency: 353 ms\n        Mon Feb 03 09:54:46 UTC 2020 : Endpoint response headers: {Date=Mon, 03 Feb 2020 09:54:46 GMT, Content-Type=application/json, Content-Length=96, Connection=keep-alive, x-amzn-RequestId=aa3064d0-a11a-4eda-a5d5-bb1d9d91cf68, x-amzn-Remapped-Content-Length=0, X-Amz-Executed-Version=$LATEST, X-Amzn-Trace-Id=root=1-5e37ede5-40a3c3575576772bbf19725c;sampled=0}\n        Mon Feb 03 09:54:46 UTC 2020 : Endpoint response body before transformations: {\"headers\":{\"x-handled-by\":\"GET by Params\"},\"body\":\"Hello, thanks for asking!\",\"statusCode\":200}\n        Mon Feb 03 09:54:46 UTC 2020 : Method response body after transformations: Hello, thanks for asking!\n        Mon Feb 03 09:54:46 UTC 2020 : Method response headers: {x-handled-by=GET by Params, X-Amzn-Trace-Id=Root=1-5e37ede5-40a3c3575576772bbf19725c;Sampled=0}\n        Mon Feb 03 09:54:46 UTC 2020 : Successfully completed execution\n        Mon Feb 03 09:54:46 UTC 2020 : Method completed with status: 200\n        ```\n- Deploy API \"/{proxy+}\" via Actions \u003e Deploy in Amazon API Gateway\n  - Stage name: `public`\n  - Note the Invoke URL, e.g. https://n10fvc22kj.execute-api.eu-central-1.amazonaws.com/public\n  - Try out the URL\n    - https://n10fvc22kj.execute-api.eu-central-1.amazonaws.com/public/api/v1/hello=world\n    - `curl -X PUT 'https://n10fvc22kj.execute-api.eu-central-1.amazonaws.com/public/api/v1/hello=world?param=my-value' -H 'content-type: plain/text'`\n    - `curl -X PUT 'https://n10fvc22kj.execute-api.eu-central-1.amazonaws.com/public/api/v1/svg?hello=world\u0026param=my-value'`\n    - https://n10fvc22kj.execute-api.eu-central-1.amazonaws.com/public/api/v1/svg?hello=world\u0026param=my-valuu\n\n## [WIP] Deploy with [SAM](https://aws.amazon.com/serverless/sam/)\n\n```bash\n# configure AWS credentials:\n# aws configure\n\nsam build\n\n# uses .toml file created via sam deploy --guided\nsam deploy\n```\n\n**Local testing**\n\n```bash\nsam local start-lambda\n```\n\n\n\n## Resources\n\n- https://www.baeldung.com/aws-lambda-api-gateway\n  - https://github.com/eugenp/tutorials/tree/master/aws-lambda\n\n## License\n\nThis repository is Copyright 2019 Daniel Nüst and published under GPL v3 license.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuest%2Faws-lambda-kvp-minimal-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnuest%2Faws-lambda-kvp-minimal-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnuest%2Faws-lambda-kvp-minimal-java/lists"}