{"id":23338392,"url":"https://github.com/abhirockzz/go-serverless-lambda-demo","last_synced_at":"2026-05-12T07:41:24.912Z","repository":{"id":54397280,"uuid":"509110736","full_name":"abhirockzz/go-serverless-lambda-demo","owner":"abhirockzz","description":"Go for AWS developers - Build a Serverless app with Lambda, DynamoDB and more","archived":false,"fork":false,"pushed_at":"2022-06-30T15:52:18.000Z","size":205,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-13T16:32:33.890Z","etag":null,"topics":["aws","aws-lambda","cdk","dynamodb","go","infrastructure-as-code","nosql","serverless"],"latest_commit_sha":null,"homepage":"","language":"Go","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/abhirockzz.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}},"created_at":"2022-06-30T14:20:27.000Z","updated_at":"2024-06-08T12:51:43.000Z","dependencies_parsed_at":"2022-08-13T14:21:03.224Z","dependency_job_id":null,"html_url":"https://github.com/abhirockzz/go-serverless-lambda-demo","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/abhirockzz%2Fgo-serverless-lambda-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhirockzz%2Fgo-serverless-lambda-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhirockzz%2Fgo-serverless-lambda-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhirockzz%2Fgo-serverless-lambda-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abhirockzz","download_url":"https://codeload.github.com/abhirockzz/go-serverless-lambda-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247666003,"owners_count":20975785,"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":["aws","aws-lambda","cdk","dynamodb","go","infrastructure-as-code","nosql","serverless"],"created_at":"2024-12-21T03:13:46.789Z","updated_at":"2026-05-12T07:41:24.883Z","avatar_url":"https://github.com/abhirockzz.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Build and deploy a Serverless application with Go, AWS Lambda, DynamoDB and AWS CDK\n\n![](architecture.png)\n\n- [Part 1](part1) - Start off with a simple AWS Lambda function using Go - hello world!\n- [Part 2](part2) - Bring DynamoDB into the mix! Update the Lambda function to use the DynamoDB Go SDK and persist data in a DynamoDB table\n- [Part 3](part3) - Finally, use [AWS CDK](https://docs.aws.amazon.com/cdk/v2/guide/work-with-cdk-go.html) to manage your Infra-as-code with AWS CDK.\n\n### Build, deploy and test\n\n**Part 1 - Hello world function**\n\nBuild and package:\n\n```bash\ncd part1\n\n# build\nGOOS=linux go build -o hello .\n\n# package\nzip func.zip hello\n```\n\n- Navigate to AWS console \u003e Lambda\n- Create new Lambda function (Go 1.x runtime), upload the zip file\n- Test using the console (use `AWS API Gateway Proxy` as the payload type and set `isBase64Encoded` attribute to `false`).\n\n**Part 2 - Persist data to DynamoDB**\n\n```bash\ncd part2\n\n# build\nGOOS=linux go build -o hello .\n\n# package\nzip func.zip hello\n```\n\n- Navigate to AWS console \u003e Lambda\n- Upload the zip file for the existing function\n- Create DynamoDB table - use `email` as the Partition key (data type `String`)\n- Add an environment variable to the Lambda function with name `TABLE_NAME` and value as the name of the DynamoDB table you created\n- Update the Lambda Function IAM role to provide DynamoDB `PutItem` permission for the DynamoDB table you created\n- - Test using the console (use `AWS API Gateway Proxy` as the payload type and set `isBase64Encoded` attribute to `false`). Use a JSON payload e.g. `{\\\"email\\\":\\\"user1@foo.com\\\",\\\"name\\\":\\\"user1\\\"}`\n- Confirm that the user entry was added to DynamoDB table\n\n**Part 3 - Infra-as-code with AWS CDK**\n\n```bash\ncd part3\n\n# to see the CloudFormation template\ncdk synth\n\n# to deploy the stack (enter y to confirm)\ncdk deploy\n```\n\n- Navigate to AWS console \u003e CloudFormation and confirm that the stack was successfully created and all resources were provisioned (Lambda Function, DynamoDB table, IAM role and permission)\n- Test using the console (use `AWS API Gateway Proxy` as the payload type and set `isBase64Encoded` attribute to `false`). Use a JSON payload e.g. `{\\\"email\\\":\\\"user1@foo.com\\\",\\\"name\\\":\\\"user1\\\"}`\n- Confirm that the user entry was added to the *new* DynamoDB table\n\n### Resources\n\n**Go packages used:**\n\n- `events` - https://pkg.go.dev/github.com/aws/aws-lambda-go/events\n- `lambda` - https://pkg.go.dev/github.com/aws/aws-lambda-go/lambda\n- `API Gateway`[request](https://pkg.go.dev/github.com/aws/aws-lambda-go/events#APIGatewayV2HTTPRequest) and [response](https://pkg.go.dev/github.com/aws/aws-lambda-go/events#APIGatewayV2HTTPResponse) \n- DynamoDB [PutItem](https://pkg.go.dev/github.com/aws/aws-sdk-go/service/dynamodb?utm_source=gopls#DynamoDB.PutItem) API call \n- [Amazon DynamoDB Construct Library](https://pkg.go.dev/github.com/aws/aws-cdk-go/awscdk/v2/awsdynamodb)\n- [AWS Lambda Construct Library](https://pkg.go.dev/github.com/aws/aws-cdk-go/awscdk/v2/awslambda)\n\n**Others:**\n\n- Lambda Handler signatures - https://docs.aws.amazon.com/lambda/latest/dg/golang-handler.html\n- Lambda error handling - https://docs.aws.amazon.com/lambda/latest/dg/golang-exceptions.html#go-exceptions-how\n- API Gateway\n  - Lambda integration - https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html\n  - HTTP support https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html\n- CDK\n  - General https://docs.aws.amazon.com/cdk/v2/guide/home.html\n  - CDK Go https://docs.aws.amazon.com/cdk/v2/guide/work-with-cdk-go.html\n- Amazon Lambda Golang Library (*L2 construct in experimental phase at the time of writing*)\n  - [Go function structure](https://pkg.go.dev/github.com/aws/aws-cdk-go/awscdklambdagoalpha/v2#readme-go-function)\n  - [Bundle your Go function using go tooling](https://pkg.go.dev/github.com/aws/aws-cdk-go/awscdklambdagoalpha/v2#readme-local-bundling)\n  - [Use Docker to bundle your Go function code](https://pkg.go.dev/github.com/aws/aws-cdk-go/awscdklambdagoalpha/v2#readme-docker)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhirockzz%2Fgo-serverless-lambda-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhirockzz%2Fgo-serverless-lambda-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhirockzz%2Fgo-serverless-lambda-demo/lists"}