{"id":22072784,"url":"https://github.com/zalkarz/serverless-node-lambda","last_synced_at":"2025-03-23T19:25:08.141Z","repository":{"id":221196277,"uuid":"753713233","full_name":"zalkarz/serverless-node-lambda","owner":"zalkarz","description":"Setup Serverless Framework to work with AWS Lambda","archived":false,"fork":false,"pushed_at":"2024-02-06T16:56:58.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T02:48:14.938Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/zalkarz.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}},"created_at":"2024-02-06T16:51:41.000Z","updated_at":"2024-02-06T16:53:24.000Z","dependencies_parsed_at":"2024-02-06T18:07:29.477Z","dependency_job_id":null,"html_url":"https://github.com/zalkarz/serverless-node-lambda","commit_stats":null,"previous_names":["zalkarz/serverless-node-lambda"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalkarz%2Fserverless-node-lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalkarz%2Fserverless-node-lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalkarz%2Fserverless-node-lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalkarz%2Fserverless-node-lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zalkarz","download_url":"https://codeload.github.com/zalkarz/serverless-node-lambda/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245155807,"owners_count":20569766,"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-11-30T21:14:33.974Z","updated_at":"2025-03-23T19:25:08.110Z","avatar_url":"https://github.com/zalkarz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Serverless Framework \n\nFor more details about `Serverless Framework`, please check the official [documentation](https://www.serverless.com/framework/docs/providers/aws).\n\n## Usage\n\n### Pre-Requisites\n1. Install serverless framework globally\n```\n$ npm i -g serverless\n```\n2. Install aws-cli, follow the [official guide](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)\n\n3. Setup Serverless with [aws-cli](https://www.serverless.com/framework/docs/providers/aws/guide/credentials#setup-with-the-aws-cli)\n```\n$ serverless config credentials --provider aws --key \u003cACCESS KEY\u003e --secret \u003cSECRET ACCESS KEY\u003e\n```\n\n4. Install all dependencies\n```\n$ npm install\n```\n\n## Structure \n\n```\n.\n├── configs (configuration folder)\n├── modules (modules folder)\n│   └── sns (module / context)\n│       ├── endpoints (API endpoints)\n│       │   ├── create.js\n│       │   ├── delete.js\n│       │   ├── read.js\n│       │   └── update.js\n│       └── functions (workers / background functions)\n├── package.json\n├── serverless.yml (serverless config)\n├── handlers (functions config)\n│   ├── sns-endpoints.yml (endpoints config)\n├── shared (shared components)\n│   └── lib (shared libraries)\n│       ├── kinesis.js\n│       ├── lambda.js\n│       ├── parsers.js\n│       ├── sqs.js\n│       └── uuid.js\n```\n\n## Functions\n\n### HTTP Trigger Function (API Gateway)\n\n```yml\nfunctions:\n\n  # API Endpoints\n  sns-types:\n    handler: modules/sns/endpoints/read.list #Path to function\n    memorySize: 128 # Lambda Memory Limit\n    timeout: 30 # Lambda Timeout\n    events: \n      - http: # HTTP Trigger \n          path: member/sns\n          method: get\n          integration: lambda\n          # Requires clients to add API keys values in the `x-api-key` header of their request\n          # private: true\n\n```\n\n## Development environment \n\nThis boilerplate uses `serverless-local` plugin and some containers and plugins to emulate the AWS Resources\n\n```bash\ndocker-compose up\n```\nThe applications will start on `http://localhost:3000`\n\n### Dev Plugins\n\nThis boilerplate contains following plugins for local development: \n\n* [serverless-offline](https://github.com/dherault/serverless-offline/issues) - For run API Gateway local and manage plugins\n\n## Production environment\n\n### Deploy full services\n\n```bash\nserverless deploy --stage ${dev or prod}\n```\n\n### Deploy a function \n\n```bash\nserverless deploy function -f sns-types\n```\n\n### Get function logs\n\n```bash\nserverless sns-types -f bananinha -t\n```\n\n### Clean All\n\n```bash\nserverless remove\n```\n\n## Testing\n\n**List of SNS kinds**\n\n```bash\ncurl -X GET \\\n    ${sns-types lambda endoint}\n```\n\n## Custom and Environment Variables\n\n### Custom Items\n\n\u003e Creating and Using custom variables to build dynamic name\n\n```yml\ncustom:\n  secrets: ${file(./configs/${self:provider.stage}.json)}\n```\n\n### Environment Variables\n\n\u003e Building URL Resources using CloudFormation parameters and Custom Variables \n\n```yml\n  #Global Environment variables\n  environment:\n    RDS_DATABASE: ${self:custom.secrets.RDS_DATABASE}\n    RDS_HOSTNAME: ${self:custom.secrets.RDS_HOSTNAME}\n    RDS_PASSWORD: ${self:custom.secrets.RDS_PASSWORD}\n    RDS_USERNAME: ${self:custom.secrets.RDS_USERNAME}\n```\n\n\n\n## Manage AWS Cloudformation with Serverless\n\n### IAM Roles\n\n[IAM Docs](https://serverless.com/framework/docs/providers/aws/guide/iam/)\n\n```yml\n  # Instruct Serverless to use an existing IAM role for all Lambda functions\n  iam:\n    role: ${self:custom.secrets.EXECUTION_ROLE}\n    #deploymentRole: ${self:custom.secrets.DEPLOYMENT_ROLE}\n```\n\n### Manage Infrastructure Components - [Docs](https://serverless.com/framework/docs/providers/aws/guide/resources/#aws-cloudformation-resource-reference)\n\n```yml\n# Infrastrucure - Cloud Formation\nresources:  # CloudFormation template syntax\n```\n\n### VPC\nConfigure the Lambda functions to run inside a VPC\n[VPC docs](https://www.serverless.com/framework/docs/providers/aws/guide/functions#vpc-configuration)\n```yml\n  # If you use VPC then both securityGroupIds and subnetIds are required\n  vpc:\n    securityGroupIds:\n      - ${self:custom.secrets.SECURITY_GROUP_ID}\n    subnetIds:\n      - ${self:custom.secrets.SUBNET1_ID}\n      - ${self:custom.secrets.SUBNET2_ID}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalkarz%2Fserverless-node-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzalkarz%2Fserverless-node-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalkarz%2Fserverless-node-lambda/lists"}