{"id":22615653,"url":"https://github.com/marcellodesales/aws-sam-server-docker","last_synced_at":"2026-05-04T22:38:04.734Z","repository":{"id":142072443,"uuid":"520038284","full_name":"marcellodesales/aws-sam-server-docker","owner":"marcellodesales","description":"Dockerized version of AWS SAM API Server on a Docker Container!","archived":false,"fork":false,"pushed_at":"2022-08-01T18:44:45.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T00:42:46.422Z","etag":null,"topics":["aws","developer-productivity","docker","docker-compose","lambda","localhost","sam","step-functions"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","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/marcellodesales.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":"2022-08-01T09:05:46.000Z","updated_at":"2022-08-08T16:24:06.000Z","dependencies_parsed_at":"2023-07-09T05:31:37.974Z","dependency_job_id":null,"html_url":"https://github.com/marcellodesales/aws-sam-server-docker","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/marcellodesales/aws-sam-server-docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcellodesales%2Faws-sam-server-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcellodesales%2Faws-sam-server-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcellodesales%2Faws-sam-server-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcellodesales%2Faws-sam-server-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcellodesales","download_url":"https://codeload.github.com/marcellodesales/aws-sam-server-docker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcellodesales%2Faws-sam-server-docker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32628211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"ssl_error","status_checked_at":"2026-05-04T10:08:02.005Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","developer-productivity","docker","docker-compose","lambda","localhost","sam","step-functions"],"created_at":"2024-12-08T19:08:42.711Z","updated_at":"2026-05-04T22:38:04.707Z","avatar_url":"https://github.com/marcellodesales.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ☁️  marcellodesales/aws-sam-server-docker\n\nDockerized version of AWS sam api server so you can test your serverless code before pushing to AWS Lambda service!!!\n\n# 🤷 Why\n\nWe use CDK to develop the lambda in multiple languages (Java, Nodejs, Golang, Python) so it's important to keep this\nas simple as possible, reusing the CDK templates based on the current code. Avoid multiple round-trips to AWS Console.\n\n# ⬇️  Setup\n\n* Install latest version of docker engine.\n* Make sure `docker-compose` or `docker compose` commands work.\n\n# 🔧 Config\n\n\u003e **NOTE**: Make sure to follow the steps from Serverless CDK guids\n\u003e * https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-cdk-getting-started.html\n\n1. You must discover your cdk environments\n2. Then generate the templates from all your environments\n3. Convert the environment template to the YAML template format\n4. Start the dockerized SAM server with the YAML template\n5. Copy our `docker-compose.yaml` to the root of your CDK project.\n6. Profit! Test your lambda functions without pushing to AWS Lambda!\n\n## 🙌 Discover environments of your CDK project\n \n```console\n$ cdk synth --no-staging\n\n===\u003e Creating or updating stack SupercashWebPlatformStackProd...\n===\u003e Loading stage \"prod\" of/for stack SupercashWebPlatformStackProd\n  --\u003e Logical id: APIDomainName-prod\n  --\u003e Logical id: AdminDomainName-prod\n  --\u003e Logical id: HTTPApiGatewayIntegration\n  --\u003e Logical id: Route53APIHostName-prod\n  --\u003e Logical id: APIAuthenticationService-prod\n  --\u003e Logical id: UserPool-prod\n  --\u003e Logical id: UserPoolAppClient-prod\n  --\u003e Logical id: AuthentificationServiceAdminsGroup-prod\n  --\u003e Logical id: AuthentificationServiceAdminUsersleandro@supercash.io-prod\n  --\u003e Logical id: AuthentificationServiceAdminUsersmarcello@supercash.io-prod\n  --\u003e Logical id: AuthentificationServiceCognitoTriggersFunction-prod\n  --\u003e Logical id: AuthenticationServiceBucket-prod\n  --\u003e Logical id: AuthentificationServiceFunction-prod\n  --\u003e Logical id: AuthentificationServiceFunctionIntegration-prod\n  --\u003e Logical id: APIParkinglotService-prod\n  --\u003e Logical id: ParkinglotServiceFunction-prod\n  --\u003e Logical id: ParkinglotServiceFunctionIntegration-prod\n===\u003e Creating or updating stack SupercashWebPlatformStackDev...\n===\u003e Loading stage \"dev\" of/for stack SupercashWebPlatformStackDev\n  --\u003e Logical id: APIDomainName-dev\n  --\u003e Logical id: AdminDomainName-dev\n  --\u003e Logical id: HTTPApiGatewayIntegration\n  --\u003e Logical id: Route53APIHostName-dev\n  --\u003e Logical id: APIAuthenticationService-dev\n  --\u003e Logical id: UserPool-dev\n  --\u003e Logical id: UserPoolAppClient-dev\n  --\u003e Logical id: AuthentificationServiceAdminsGroup-dev\n  --\u003e Logical id: AuthentificationServiceAdminUsersleandro@supercash.io-dev\n  --\u003e Logical id: AuthentificationServiceAdminUsersmarcello@supercash.io-dev\n  --\u003e Logical id: AuthentificationServiceCognitoTriggersFunction-dev\n  --\u003e Logical id: AuthenticationServiceBucket-dev\n  --\u003e Logical id: AuthentificationServiceFunction-dev\n  --\u003e Logical id: AuthentificationServiceFunctionIntegration-dev\n  --\u003e Logical id: APIParkinglotService-dev\n  --\u003e Logical id: ParkinglotServiceFunction-dev\n  --\u003e Logical id: ParkinglotServiceFunctionIntegration-dev\nSuccessfully synthesized to /Users/marcellodesales/dev-backup-64b/dev/gitlab.com/supercash/platform/services/parkinglot-service-serverless-cdk/cdk.out\nSupply a stack id (SupercashWebPlatformStackDev, SupercashWebPlatformStackProd) to display its template.\n```\n\n## 👷 Generate the templates for SAM\n\n\u003e **NOTE**: Here I'm choosing one of the stack ids from the output logs before\n\u003e * The output of the command creates a directory `./cdk.outs`\n\n```console\n$ cdk synth --no-staging SupercashWebPlatformStackDev\n\n===\u003e Creating or updating stack SupercashWebPlatformStackProd...\n===\u003e Loading stage \"prod\" of/for stack SupercashWebPlatformStackProd\n  --\u003e Logical id: APIDomainName-prod\n  --\u003e Logical id: AdminDomainName-prod\n  --\u003e Logical id: HTTPApiGatewayIntegration\n  --\u003e Logical id: Route53APIHostName-prod\n  --\u003e Logical id: APIAuthenticationService-prod\n  --\u003e Logical id: UserPool-prod\n  --\u003e Logical id: UserPoolAppClient-prod\n  --\u003e Logical id: AuthentificationServiceAdminsGroup-prod\n  --\u003e Logical id: AuthentificationServiceAdminUsersleandro@supercash.io-prod\n  --\u003e Logical id: AuthentificationServiceAdminUsersmarcello@supercash.io-prod\n  --\u003e Logical id: AuthentificationServiceCognitoTriggersFunction-prod\n  --\u003e Logical id: AuthenticationServiceBucket-prod\n  --\u003e Logical id: AuthentificationServiceFunction-prod\n  --\u003e Logical id: AuthentificationServiceFunctionIntegration-prod\n  --\u003e Logical id: APIParkinglotService-prod\n  --\u003e Logical id: ParkinglotServiceFunction-prod\n  --\u003e Logical id: ParkinglotServiceFunctionIntegration-prod\n===\u003e Creating or updating stack SupercashWebPlatformStackDev...\n===\u003e Loading stage \"dev\" of/for stack SupercashWebPlatformStackDev\n  --\u003e Logical id: APIDomainName-dev\n  --\u003e Logical id: AdminDomainName-dev\n  --\u003e Logical id: HTTPApiGatewayIntegration\n  --\u003e Logical id: Route53APIHostName-dev\n  --\u003e Logical id: APIAuthenticationService-dev\n  --\u003e Logical id: UserPool-dev\n  --\u003e Logical id: UserPoolAppClient-dev\n  --\u003e Logical id: AuthentificationServiceAdminsGroup-dev\n  --\u003e Logical id: AuthentificationServiceAdminUsersleandro@supercash.io-dev\n  --\u003e Logical id: AuthentificationServiceAdminUsersmarcello@supercash.io-dev\n  --\u003e Logical id: AuthentificationServiceCognitoTriggersFunction-dev\n  --\u003e Logical id: AuthenticationServiceBucket-dev\n  --\u003e Logical id: AuthentificationServiceFunction-dev\n  --\u003e Logical id: AuthentificationServiceFunctionIntegration-dev\n  --\u003e Logical id: APIParkinglotService-dev\n  --\u003e Logical id: ParkinglotServiceFunction-dev\n  --\u003e Logical id: ParkinglotServiceFunctionIntegration-dev\n```\n```yaml\nResources:\n  SupercashCrossRegionCertificateCertificateRequestorFunctionServiceRoleC2CBA1EF:\n    Type: AWS::IAM::Role\n    Properties:\n      AssumeRolePolicyDocument:\n        Statement:\n          - Action: sts:AssumeRole\n            Effect: Allow\n            Principal:\n              Service: lambda.amazonaws.com\n        Version: \"2012-10-17\"\n...\n...\n```\n\n* This results in the creation of the dir\n\n```console\n$ tree cdk.out -L 1\ncdk.out\n├── SupercashWebPlatformStackDev.assets.json\n├── SupercashWebPlatformStackDev.template.json\n├── SupercashWebPlatformStackProd.assets.json\n├── SupercashWebPlatformStackProd.template.json\n├── cdk.out\n├── manifest.json\n└── tree.json\n```\n\n## 🔨 Create a template.yaml based on one of the templates\n\n\u003e **NOTE**: `.yaml` files are a subset of `.json` and, therefore, can be used as a hack for the creation of the template.yaml required by SAM.\n\u003e * After this step, your are ready to run!\n```console\ncp cdk.out/SupercashWebPlatformStackDev.template.json template.yaml\n```\n\n## ✂️ Copy the docker-compose.yaml to your CDK project root's dir\n\n\u003e **NOTE**: Make sure the file is located in the root dir\n\u003e * The version of the docker image used is latest.\n\n```yaml\nversion: '3.9'\n\n# Setup a provide network for local deployments of aws services\nnetworks:\n  backend:\n    name: aws_backend\n    driver: bridge\n\nservices:\n\n  aws-sam-api-server:\n    # Choose a release version or a SHA version, latest is tested\n    image: marcellodesales/aws-sam-server:latest\n\n    # A container will run in a dir with the same name as current dir\n    working_dir: $PWD\n\n    volumes:\n      # The volumes for the current dir is mounted\n      - $PWD:$PWD\n\n      # Needed so a docker container can be run from inside a docker container\n      - /var/run/docker.sock:/var/run/docker.sock \n\n      # The settings to your aws if needed\n      - ~/.aws/:/root/.aws:ro\n\n    networks:\n      - \"backend\"\n\n    ports:\n      # SAM API server runs on port 3000\n      - \"3000:3000\"\n\n    environment:\n      # Just don't send telemetry data to AWS...\n      SAM_CLI_TELEMETRY: false\n\n      # The docker network created\n      DOCKER_NETWORK: aws_backend\n```\n\n# 🏃 Run\n\n```console\n$ docker-compose up\n[+] Running 1/1\n ⠿ Container supercash-aws-sam  Recreated                                                                                                        0.2s\nAttaching to supercash-aws-sam\nsupercash-aws-sam  | Mounting AuthentificationServiceFunction-dev at http://0.0.0.0:3000/v1/auth [POST, OPTIONS]\nsupercash-aws-sam  | Mounting AuthentificationServiceFunction-dev at http://0.0.0.0:3000/v1/auth/forgot-password [POST, OPTIONS]\nsupercash-aws-sam  | Mounting AuthentificationServiceFunction-dev at http://0.0.0.0:3000/v1/auth/confirm-forgot-password [POST, OPTIONS]\nsupercash-aws-sam  | Mounting AuthentificationServiceFunction-dev at http://0.0.0.0:3000/v1/auth/confirm-sign-up [GET, POST, OPTIONS]\nsupercash-aws-sam  | Mounting AuthentificationServiceFunction-dev at http://0.0.0.0:3000/v1/auth/resend-confirmation-code [POST, OPTIONS]\nsupercash-aws-sam  | Mounting AuthentificationServiceFunction-dev at http://0.0.0.0:3000/v1/users [GET, POST, PUT, OPTIONS]\nsupercash-aws-sam  | Mounting AuthentificationServiceFunction-dev at http://0.0.0.0:3000/v1/users/{id} [DELETE, GET, PUT, OPTIONS]\nsupercash-aws-sam  | Mounting AuthentificationServiceFunction-dev at http://0.0.0.0:3000/v1/users/status/{id} [GET, POST, OPTIONS]\nsupercash-aws-sam  | Mounting ParkinglotServiceFunction-dev at http://0.0.0.0:3000/v1/parkinglots/tickets [GET, OPTIONS]\nsupercash-aws-sam  | Mounting ParkinglotServiceFunction-dev at http://0.0.0.0:3000/v1/parkinglots/tickets/{id} [GET, OPTIONS]\nsupercash-aws-sam  | Mounting ParkinglotServiceFunction-dev at http://0.0.0.0:3000/v1/parkinglots/tickets/{id}/pay [POST, OPTIONS]\nsupercash-aws-sam  | You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template\nsupercash-aws-sam  | 2022-08-01 09:02:42  * Running on all addresses.\nsupercash-aws-sam  |    WARNING: This is a development server. Do not use it in a production deployment.\nsupercash-aws-sam  | 2022-08-01 09:02:42  * Running on http://172.23.0.2:3000/ (Press CTRL+C to quit)\n```\n\n# ✅ Test\n\n* Now, you can make requests to one of the endpoints listed and test the local code...\n\n## 🔊 CURL Client Logs\n\n* Invoking the step function...\n\n```console\n$ curl -i http://0.0.0.0:3000/v1/parkinglots/tickets/2030340492\\?scanned\\=false\nHTTP/1.0 200 OK\nContent-Type: application/json\nContent-Length: 13\nServer: Werkzeug/2.0.0 Python/3.9.5\nDate: Mon, 01 Aug 2022 09:02:46 GMT\n\nticket status%\n```\n\n# 🔊 SAM Server Logs\n\n* The output of the terminal of the SAM server will show the interaction and running the lambda selected:\n\n```console\n...\n...\nsupercash-aws-sam  | 2022-08-01 09:02:42  * Running on http://172.23.0.2:3000/ (Press CTRL+C to quit)\nsupercash-aws-sam  | Invoking parkinglots.main (nodejs14.x)\nsupercash-aws-sam  | Skip pulling image and use local one: public.ecr.aws/sam/emulation-nodejs14.x:rapid-1.53.0-x86_64.\nsupercash-aws-sam  |\nsupercash-aws-sam  | Mounting /Users/marcellodesales/dev-backup-64b/dev/gitlab.com/supercash/platform/services/parkinglot-service-serverless-cdk/resources/v1/Parkinglot as /var/task:ro,delegated inside runtime container\nsupercash-aws-sam  | START RequestId: 751ad9f3-0d68-4c67-87bd-82bac07d719a Version: $LATEST\nsupercash-aws-sam  | 2022-08-01T09:02:45.744Z\t751ad9f3-0d68-4c67-87bd-82bac07d719a\tINFO\tevent: {\"version\":\"2.0\",\"routeKey\":\"GET /v1/parkinglots/tickets/{id}\",\"rawPath\":\"/v1/parkinglots/tickets/2030340492\",\"rawQueryString\":\"scanned=false\",\"cookies\":[],\"headers\":{\"Host\":\"0.0.0.0:3000\",\"User-Agent\":\"curl/7.79.1\",\"Accept\":\"*/*\",\"X-Forwarded-Proto\":\"http\",\"X-Forwarded-Port\":\"3000\"},\"requestContext\":{\"accountId\":\"123456789012\",\"apiId\":\"1234567890\",\"http\":{\"method\":\"GET\",\"path\":\"/v1/parkinglots/tickets/2030340492\",\"protocol\":\"HTTP/1.1\",\"sourceIp\":\"172.23.0.1\",\"userAgent\":\"Custom User Agent String\"},\"requestId\":\"5eb07add-83e8-49ef-a053-cdd1ea9eaf1d\",\"routeKey\":\"GET /v1/parkinglots/tickets/{id}\",\"stage\":\"$default\",\"time\":\"01/Aug/2022:09:02:41 +0000\",\"timeEpoch\":1659344561,\"domainName\":\"localhost\",\"domainPrefix\":\"localhost\"},\"body\":\"\",\"pathParameters\":{\"id\":\"2030340492\"},\"stageVariables\":null,\"isBase64Encoded\":false,\"queryStringParameters\":{\"scanned\":\"false\"}}\nsupercash-aws-sam  | END RequestId: 751ad9f3-0d68-4c67-87bd-82bac07d719a\nsupercash-aws-sam  | REPORT RequestId: 751ad9f3-0d68-4c67-87bd-82bac07d719a\tInit Duration: 1.00 ms\tDuration: 408.74 ms\tBilled Duration: 409 ms\tMemory Size: 128 MB\tMax Memory Used: 128 MB\nsupercash-aws-sam  | No Content-Type given. Defaulting to 'application/json'.\nsupercash-aws-sam  | 2022-08-01 09:02:46 172.23.0.1 - - [01/Aug/2022 09:02:46] \"GET /v1/parkinglots/tickets/2030340492?scanned=false HTTP/1.1\" 200 -\n```\n\n# 🛠️ Extending\n\n* Fork the repo and update the Dockerfile for any additional things in the server\n* You can install anything else required by the server.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcellodesales%2Faws-sam-server-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcellodesales%2Faws-sam-server-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcellodesales%2Faws-sam-server-docker/lists"}