{"id":25946006,"url":"https://github.com/p4irin/explore_terraform_localstack_aws_api_gateway_lambda_hello_js","last_synced_at":"2026-06-08T15:32:13.174Z","repository":{"id":276823531,"uuid":"930426733","full_name":"p4irin/explore_terraform_localstack_aws_api_gateway_lambda_hello_js","owner":"p4irin","description":"Use lambda proxy integration to integrate an api method with a lambda function","archived":false,"fork":false,"pushed_at":"2025-02-12T18:16:42.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T09:20:09.462Z","etag":null,"topics":["aws-api-gateway","aws-cli","aws-lambda","explore","localstack","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/p4irin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-02-10T16:06:28.000Z","updated_at":"2025-02-12T18:16:46.000Z","dependencies_parsed_at":"2025-02-10T17:24:38.616Z","dependency_job_id":"d0648cbb-7cd4-45f5-bf89-e9d34d74b754","html_url":"https://github.com/p4irin/explore_terraform_localstack_aws_api_gateway_lambda_hello_js","commit_stats":null,"previous_names":["p4irin/explore_terraform_localstack_aws_api_gateway_lambda_hello_js"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/p4irin/explore_terraform_localstack_aws_api_gateway_lambda_hello_js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_localstack_aws_api_gateway_lambda_hello_js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_localstack_aws_api_gateway_lambda_hello_js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_localstack_aws_api_gateway_lambda_hello_js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_localstack_aws_api_gateway_lambda_hello_js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p4irin","download_url":"https://codeload.github.com/p4irin/explore_terraform_localstack_aws_api_gateway_lambda_hello_js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p4irin%2Fexplore_terraform_localstack_aws_api_gateway_lambda_hello_js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34069489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["aws-api-gateway","aws-cli","aws-lambda","explore","localstack","terraform"],"created_at":"2025-03-04T09:19:51.008Z","updated_at":"2026-06-08T15:32:13.158Z","avatar_url":"https://github.com/p4irin.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Explore Terraform, LocalStack, AWS api gateway, AWS lambda hello javascript function\n\nUse lambda proxy integration to integrate an api method with a lambda function. The lambda function is a javascript function that simply returns the string \"Hello from Lambda!\"\n\nDeploy with\n\n* AWS CLI\n* Terraform\n\n## General steps\n\n1. `$ localstack start`\n1. Create lambda function\n1. Create REST API\n1. Get the id of the root resource\n1. Create a resource using the root as a parent\n1. Add method to resource\n1. Create integration\n1. Create deployment\n1. `$ localstack stop`\n\n## Code\n\nThe javscript code for the lambda function is in `lambda.js`.\n\nzip the file into `function.zip`.\n\n```bash\n$ zip function.zip lambda.js\n...\n$\n```\n\n## AWS CLI\n\n###\n\n```bash\n$ localstack start\n```\n\n### Create the lambda function\n\n```bash\n$ aws --profile localstack lambda create-function \\\n  --function-name apigw-lambda \\\n  --runtime nodejs16.x \\\n  --handler lambda.apiHandler \\\n  --memory-size 128 \\\n  --zip-file fileb://function.zip \\\n  --role arn:aws:iam::111111111111:role/apigw\n```\n\n### Create REST API\n\n```bash\n$ aws --profile localstack apigateway create-rest-api \\\n--name 'API Gateway Lambda integration'\n\n{\n    \"id\": \"fxb6vjawg2\",\n    ...\n}\n```\n\nYou'll need that \"id\" in the next and later steps.\n\nCopy and paste the value of `\"id\"` in the following command\n\n```bash\n$ rest_api_id=fxb6vjawg2\n```\n\n### Get the id of the root resource\n\n```bash\n$ aws --profile localstack apigateway get-resources \\\n--rest-api-id $rest_api_id\n\n{\n    \"items\": [\n        {\n            \"id\": \"edqon7lp3u\",\n            \"path\": \"/\"\n        }\n    ]\n}\n```\n\nYou'll need that root resource id in the next and later steps.\n\nCopy and paste the value of `\"id\"` into this command\n\n```bash\n$ root_resource_id=edqon7lp3u\n```\n\n### Create a resource using the root resource as its parent\n\n```bash\n$ aws --profile localstack apigateway create-resource \\\n  --rest-api-id $rest_api_id \\\n  --parent-id $root_resource_id \\\n  --path-part \"{somethingId}\"\n\n{\n    \"id\": \"a9baesz9x3\",\n    \"parentId\": \"edqon7lp3u\",\n    \"pathPart\": \"{somethingId}\",\n    \"path\": \"/{somethingId}\"\n}\n```\n\nYou'll need the \"id\" of the created resource to add a method to it and integrate it with the lambda function.\n\nCopy and paste into\n\n```bash\n$ resource_id=a9baesz9x3\n```\n\n### Add method to resource\n\n```bash\n$ aws --profile localstack apigateway put-method \\\n  --rest-api-id $rest_api_id \\\n  --resource-id $resource_id \\\n  --http-method GET \\\n  --request-parameters \"method.request.path.somethingId=true\" \\\n  --authorization-type \"NONE\"\n```\n\n### Create integration\n\nIntegrate the resource with the lambda function.\n\n```bash\n$ aws --profile localstack apigateway put-integration \\\n  --rest-api-id $rest_api_id \\\n  --resource-id $resource_id \\\n  --http-method GET \\\n  --type AWS_PROXY \\\n  --integration-http-method POST \\\n  --uri arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:000000000000:function:apigw-lambda/invocations \\\n  --passthrough-behavior WHEN_NO_MATCH\n```\n\n### Create deployment\n\n```bash\n$ aws --profile localstack apigateway create-deployment \\\n  --rest-api-id $rest_api_id \\\n  --stage-name dev\n```\n\n### Verify your API\n\nBy calling it:\n\n```bash\n$ curl -X GET http://${rest_api_id}.execute-api.localhost.localstack.cloud:4566/dev/test\n\n{\"message\":\"Hello from Lambda\"}\n```\n\n###\n\n```bash\n$ localstack stop\n```\n\n## Terraform\n\nRefer to th `*.tf` files.\n\nThe `stage_name` attribute of the `aws_api_gateway_deployment` resource is deprecated. Instead, an explicit `aws_api_gateway_stage` resource is used.\n\nAll dependencies are implicit. Resources are created in correct order.\n\n## References\n\n* [API Gateway on LocalStack Guide](https://docs.localstack.cloud/user-guide/aws/apigateway/)\n* \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4irin%2Fexplore_terraform_localstack_aws_api_gateway_lambda_hello_js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp4irin%2Fexplore_terraform_localstack_aws_api_gateway_lambda_hello_js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp4irin%2Fexplore_terraform_localstack_aws_api_gateway_lambda_hello_js/lists"}