{"id":18437790,"url":"https://github.com/vsrc/samg","last_synced_at":"2025-04-14T13:13:51.057Z","repository":{"id":40276723,"uuid":"340449494","full_name":"vsrc/samg","owner":"vsrc","description":"AWS SAM boilerplate generator command line utility","archived":false,"fork":false,"pushed_at":"2022-05-17T02:44:12.000Z","size":31,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-16T10:42:52.457Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vsrc.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}},"created_at":"2021-02-19T18:00:43.000Z","updated_at":"2021-02-27T09:52:45.000Z","dependencies_parsed_at":"2022-08-27T12:10:38.163Z","dependency_job_id":null,"html_url":"https://github.com/vsrc/samg","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/vsrc%2Fsamg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsrc%2Fsamg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsrc%2Fsamg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsrc%2Fsamg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vsrc","download_url":"https://codeload.github.com/vsrc/samg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248886328,"owners_count":21177644,"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-06T06:16:07.955Z","updated_at":"2025-04-14T13:13:51.019Z","avatar_url":"https://github.com/vsrc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SAM Generator\n\nAWS SAM boilerplate generator command line utility\n\nMotivation behind creating this tool is to help automate repetitive steps a developer has to do when creating api with AWS lambda. In addition to already existing amazing aws sam cli tools, for each new function and stack, developer needs to:\n\n1. Create new folder/s\n2. Copy paste template code\n3. Copy paste any commonly used code snippets\n4. Add configuration for the new function / stack in `template.yaml`\n\nThis tool does all of that for you with one command. Two if you need to create a stack.\n\n## How to install\n\nTo install it, run:\n\n```sh\n  go get github.com/vsrc/samg\n```\n\nCommand will download and compile the source code, then put it in the `bin` folder inside your `GOPATH`.\n\n### Requirement\n\nIn order to properly work this tool requires templates. You can download `templates` folder from from this repo and edit them if needed. These files are generated with aws sam cli sample command `sam init` and contain simple demo functionality. \n\nAs you are developing your api, you might start using your own set libraries / packages / code snippets in most of your functions and it makes sense to add them to the template code so it gets copied into every new function you generate afterwards.\n\n\n## How to use\n\nTo see all commands and options available run \n\n```sh\n  samg -h\n```\n\nor for specific command\n\n```sh\n  samg [COMMAND] -h\n```\n\n### To create new stack\n\n```sh\n  samg stack [command options]\n```\n\nOptions that you can add to this command:\n```txt\n  --path value, -p value      path where new stack will be created (required)\n  --parent value, -a value    path to folder where parent stack configuration file is in which we will put the reference to this new stack (default: parent folder of the provided path)\n  --template value, -t value  path to template file for this new stack (default: templates/stack/template.yaml)\n  --help, -h                  show help (default: false)\n```\n\nFor example command:\n\n```sh\n  samg stack -p v1/\n```\n\nwill create new folder `v1` and put `template.yaml` file inside, ready to be populated.\n\nNOTE: when deploying via aws sam cli, deployment will create new separate API for each stack. It makes sense to keep same logical units inside same stack. \n\n\n### To create new function\n```sh\n  samg function [command options]\n```\n\nOptions that you can add to this command:\n```txt\n  --path value, -p value      path where new function will be created (required)\n   --parent value, -a value    path to folder where parent stack configuration file is in which we will put the reference to this new function (default: parent folder of the provided path)\n   --template value, -t value  path to template folder for this new function (default: templates/fn/)\n   --name value, -n value      optional name for this function (default: last part of provided path)\n   --url value, -u value       url for the api for this function (default: same as provided path)\n   --method value, -m value    http method for this function (default: GET)\n   --help, -h                  show help (default: false)\n```\n\nFor example command:\n\n```sh\n  samg fn -p v1/user/register\n```\n\nwill create new folder on the path `v1/user/register/` and put two template files (`go.mod` and `main.go`) inside, ready to be used.\n\n\n## How to test locally\n\nUse aws sam cli as usual, navigate to the function directory and run:\n\n\n```sh\n  sam build # Build package before starting local api\n```\n\n```sh\n  sam local start-api # Start local api\n```\n\n\n### How to deploy\n\nUse aws sam cli as usual, navigate to the folder where `template.yaml` is either for function or for stack and run:\n\n```sh\n  sam deploy --guided --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND\n```\n\nThis command will guide you through first time configuration setup and if you choose to save configuration, for every subsequent run of this command you can omit `--guided` flag.\n\n## TODO Whishlist\n\nThese are the things I would like to improve this project with. If you want to suggest any other feel free to file an issue or contact me. If you want to improve this code feel free to submit a PR, I will gladly take a look.\n\n- [ ] Switch to go 1.16 and embed default templates into binary itself \n- [ ] TESTS!!! 😬😬😬😬😬😬😬😬😬😬😬 (not a single test written yet)\n\n\n## Additional resoucres\n\nYou can find some really good reading materials about best practices of develpment with aws, sam and lambda on the documentation pages of the AWS. Some of them are:\n\n- [Your first steps with SAM](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html)\n- [Template anatomy - What to write in the template.yaml file](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html)\n- [Best practices for organizing larger serverless applications,](https://aws.amazon.com/blogs/compute/best-practices-for-organizing-larger-serverless-applications/) one of the first concerns for using AWS lambda for development api is that as your api grows, configuration file becames too big to manage, this article explains best practices how to scale your code and keep it managable\n- [Announcing nested applications for AWS SAM and the AWS Serverless Application Repository] https://aws.amazon.com/blogs/compute/announcing-nested-applications-for-aws-sam-and-the-aws-serverless-application-repository/\n- [Using nested applications](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-nested-applications.html)\n\n[This blog post](https://blog.rowanudell.com/getting-started-with-aws-sam-cli-and-golang/) from [@elrowan](https://twitter.com/elrowan) gives amazing intro and simple theory into whole aws -\u003e lambda -\u003e sam local development setup, definitely worth reading.\n\n## Contact me\n\nIf you would like to contact me about this project or anything else feel free to reach me out: [https://veddy.me/](https://veddy.me/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsrc%2Fsamg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvsrc%2Fsamg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsrc%2Fsamg/lists"}