{ "info": { "author": "Sam Van Overmeire", "author_email": "sam.van.overmeire@hotmail.com", "bugtrack_url": null, "classifiers": [], "description": "# SAM Template Creator\n\n## Intro\n\n![Alt Text](https://cl.ly/21b792e2627b/Screen%252520Recording%2525202019-04-21%252520at%25252010.56%252520AM.gif)\n\nThe SAM Template Creator helps you set up Infrastructure as Code for an AWS serverless project.\nIt reads your project folder and generates a [SAM template][1] containing the necessary functions, globals, environment variables, etc.\n\nCompared to a full-fledged framework like [Serverless][2], the scope of this template creator is *limited*. But this has advantages as well:\nthe tool is lightweight, generating no additional files except your IaC yaml, and is simple to use. Though it may not suffice for very complex\nuse-cases, it can still provide a starting point to expand upon.\n\n[1]: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md\n[2]: https://serverless.com/\n\n## Requirements\n\n- python 3.5 or higher\n- pip\n- a serverless project to scan. *Currently only Python and Go projects are supported. Support for Node and Java is planned.*\n\n## Usage Guide / How-to\n\nInstall the tool using pip\n\n```\npip install sam-template-creator\n\n# or alternatively\n\npip3 install sam-template-creator\n```\n\nNow either go to the root directory of your project and type\n\n```\nsam-template-creator --location .\n\n# or with shorthand argument names\n\nsam-template-creator -l .\n```\n\nOr use an absolute path from any directory \n\n`sam-template-creator --location /path/to/project`\n\nThe script will create a `template.yaml` file in the root of your project's directory. Check its contents! It might point out some things you have to fill in.\n\nYou can also pass some (optional) arguments:\n\n- language: by default, the tool will guess which language the project is written in. If it does not find the correct language, or if you want an older version of\nthe runtime (the script will default to the latest version), you can use this argument.\n- globals: if used, the memory and timeout of the lambdas will be set globally, instead of per function\n\nWith your template created, you should now be able to deploy to AWS using\n\n```\naws cloudformation package --template-file template.yaml --s3-bucket YOUR-BUCKET-NAME --output-template-file outputSamTemplate.yaml\naws cloudformation deploy --template-file outputSamTemplate.yaml --stack-name PICK-A-STACK-NAME --capabilities CAPABILITY_IAM\n```\n\n### Notes on usage\n\n*Important!* SAM Template Creator requires your project to be organised in a certain way.\n\n#### Directory\n\nThe tool will work best if every lambda has its own directory, though it should be able to handle other project structures as well. \nThe file containing the handler and files it directly refers to will be checked for information on required permissions, environment variables, etc. \n\nIf a single zip (for most languages) or executable is present in the folder of the handler file, or a subfolder, the tool assumes this zip contains the code you want to upload.\n\n#### Naming conventions\n\n##### Python\n\n- the name of the Lambda handler function should contain the word 'handler'. The event should end with 'event' and the context should be 'context'. \nFor example `def lambda_handler(s3event, context)`\n- if part of the name equals a http method, we assume you want to map it to an api gateway method with the path represented by the rest of the name. \nFor example, if your handler's name is `def put_hello_world_hander(event, context)`, the function is mapped to a `PUT` to `/hello/world`.\n- if the lambda is triggered by an event source, the name should reflect this. \nFor example, if s3 is the source, the name of the event should contain `s3`: `s3event` or `s3_event` or...\n\n##### Go\n\n- the name of your executable should be `handler`, except if you have an executable in the folder of your lambda, called `main`. If so, the tool will assume that this\nexecutable has the code of your lambda. It will set `Handler` and `CodeUri` accordingly. \nFor example, if your folder `mylambda` contains a `main` file under `dist/main`, the `Handler` will become `main`, with the `CodeUri` equal to `/mylambda/dist/main`. \n- if you want to map a function to an api gateway method, the lambda handler should end with the word Request, with the path and method prepended to this word.\nFor example, `func PostAddHelloRequest(_ context.Context, event events.APIGatewayProxyRequest) error` is mapped to a `POST` to `/add/hello`.\n- if the lambda is triggered by an event source, the name should reflect that. \nFor example, if s3 is the source, the name of the event should contain `s3`, like this: `s3event` or `s3_event` or...\n\n##### Node\n\n- TODO\n\n##### Java\n\n- TODO\n\n### Project Structure\n\nThere are three main parts to this project\n- `reader`: contains files that help with reading the files in the project. The `FileInfo.py` class reads an individual file and retrieves\nresources and other configuration information. Because files will look very different depending on the language, it uses the strategy pattern\nto aid in these language-specific tasks. For example, when dealing with Python, the `PythonStrategy` class is used.\n- `middleware`: these files and functions take the information from the read side and do transforms, adding/removing certain config, before this is\npassed to the writers.\n- `writer`: these files are responsible for writing the information to yaml.\n\nBesides these folders, there is a `util` folder, the `coordinator.py` file which coordinates the work of the other files and the `command_line.py`,\nwhich contains the argument parser and calls the coordinator after checking the input.\n\n### Tests\n\nUnit tests can be run with `python -m unittest`. A relatively simple it-test is run with the bash script `test.sh` under tests/it-test.\nIt requires a bucket as argument (for uploading the lambda zip) and [default AWS credentials][3].\n\n[3]: https://docs.aws.amazon.com/polly/latest/dg/setup-aws-cli.html\n\n### Roadmap\n\n* Languages\n * Node\n * Java \n* Incremental templates by checking previous ones for values for timeout, env vars etc. (and maybe notifying user of finds) \n* Robust error handling \n* Ask questions. See you call dynamo, add to template? generate outputs? how many buckets for events? deploy template? use 'middleware' for this\n* More flexibility in location of lambdas: searching more folders, or ability to specify folder structure? \n* Polyglot projects?\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/VanOvermeire/sam-template-creator", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "sam-template-creator", "package_url": "https://pypi.org/project/sam-template-creator/", "platform": "", "project_url": "https://pypi.org/project/sam-template-creator/", "project_urls": { "Homepage": "https://github.com/VanOvermeire/sam-template-creator" }, "release_url": "https://pypi.org/project/sam-template-creator/0.1.3/", "requires_dist": [ "ruamel.yaml (>=0.15.89)" ], "requires_python": "", "summary": "Creates a SAM template for a given project", "version": "0.1.3" }, "last_serial": 5353837, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "48141d9a4d78edceab8860b6cc664297", "sha256": "c6fa38de659df5f9c09b3c81541457855347e80b76af3a779c9837e9b2a2cb10" }, "downloads": -1, "filename": "sam_template_creator-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "48141d9a4d78edceab8860b6cc664297", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14515, "upload_time": "2019-04-20T16:29:12", "url": "https://files.pythonhosted.org/packages/0c/44/b11453672ca7ae067234a558a9b08d2b13addad8b1e6c9c6cffe9cce0de5/sam_template_creator-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "73b7a8f16eadb00edb325ce5f056e156", "sha256": "c02e6477fdc5a434df9146b3b83ce6e467f06c38a10f5c062d86dc0d8a93b93d" }, "downloads": -1, "filename": "sam-template-creator-0.0.1.tar.gz", "has_sig": false, "md5_digest": "73b7a8f16eadb00edb325ce5f056e156", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9250, "upload_time": "2019-04-20T16:29:13", "url": "https://files.pythonhosted.org/packages/ca/d4/49baa718a19160ffb2ef2b07ce7667d29a661b6b2b73a6dfcf63433c0d49/sam-template-creator-0.0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "6dc9575ed6ac1a97828ebd4683059a02", "sha256": "42e033322b5ce9125faf38868cdaa4fa1282544908e7c7d6175c1c2c0233aee1" }, "downloads": -1, "filename": "sam_template_creator-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "6dc9575ed6ac1a97828ebd4683059a02", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 19611, "upload_time": "2019-05-17T15:46:24", "url": "https://files.pythonhosted.org/packages/de/78/9697aa76d9ced614ed7e31d8247660398edcb49d823bc4fe80c1d515b310/sam_template_creator-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a8a667a6cada44671169ac458cbd80de", "sha256": "3a748e6872bd4b9d73b470e5515ddc43320e9bfd4e66f9ee4575e8ba1e68766d" }, "downloads": -1, "filename": "sam-template-creator-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a8a667a6cada44671169ac458cbd80de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12421, "upload_time": "2019-05-17T15:46:26", "url": "https://files.pythonhosted.org/packages/8b/14/dad1493953b6f6cd8115c00ff861c8e1d971e2ef04845862adcc75397dd2/sam-template-creator-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "2813b85211277b9f4569ef00214dd3d2", "sha256": "591e5f53c5f3e3172b01da56af5af75ebd9f8b1d91bf6c84f977bcf18f51c0b2" }, "downloads": -1, "filename": "sam_template_creator-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "2813b85211277b9f4569ef00214dd3d2", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 19632, "upload_time": "2019-05-17T15:54:11", "url": "https://files.pythonhosted.org/packages/82/3b/6eda0bb2cca0fedf66fab13b2856cfb11996c1421d9172e591c649f815ba/sam_template_creator-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fc1decfb4eaf29ca63a68dedcde6abac", "sha256": "16ae50dfb7bb4ee7e48214ffc0130bf531e5c386c2fe9e2a1a96273234f6db62" }, "downloads": -1, "filename": "sam-template-creator-0.1.2.tar.gz", "has_sig": false, "md5_digest": "fc1decfb4eaf29ca63a68dedcde6abac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12437, "upload_time": "2019-05-17T15:54:13", "url": "https://files.pythonhosted.org/packages/2a/04/a24a1bb9c3c975fb7214861909f0aa0f8a7de93c81a9316a33238cad8280/sam-template-creator-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "b6906e44347e740fff99c59676c3929e", "sha256": "f50d1c5c025c03b429df89798d440e0ffe334332399fba660e9c00d38f0a1b6a" }, "downloads": -1, "filename": "sam_template_creator-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "b6906e44347e740fff99c59676c3929e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 20559, "upload_time": "2019-06-03T18:30:46", "url": "https://files.pythonhosted.org/packages/b7/6d/ceb4ed048c43c5c41118ba131a210a90165c203562161376ae0c444232ec/sam_template_creator-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6333c7438795df20f76c9770d52fec03", "sha256": "8c767cdad87ec168ee681371bc8b064d73582fea0349181a02600a6d83e63ae3" }, "downloads": -1, "filename": "sam-template-creator-0.1.3.tar.gz", "has_sig": false, "md5_digest": "6333c7438795df20f76c9770d52fec03", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13122, "upload_time": "2019-06-03T18:30:47", "url": "https://files.pythonhosted.org/packages/09/bf/ae3e6b71c8b6a3e7a2dc895b4ae2368f0b576312a7f82cd7301c0247cbf5/sam-template-creator-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b6906e44347e740fff99c59676c3929e", "sha256": "f50d1c5c025c03b429df89798d440e0ffe334332399fba660e9c00d38f0a1b6a" }, "downloads": -1, "filename": "sam_template_creator-0.1.3-py3-none-any.whl", "has_sig": false, "md5_digest": "b6906e44347e740fff99c59676c3929e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 20559, "upload_time": "2019-06-03T18:30:46", "url": "https://files.pythonhosted.org/packages/b7/6d/ceb4ed048c43c5c41118ba131a210a90165c203562161376ae0c444232ec/sam_template_creator-0.1.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6333c7438795df20f76c9770d52fec03", "sha256": "8c767cdad87ec168ee681371bc8b064d73582fea0349181a02600a6d83e63ae3" }, "downloads": -1, "filename": "sam-template-creator-0.1.3.tar.gz", "has_sig": false, "md5_digest": "6333c7438795df20f76c9770d52fec03", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13122, "upload_time": "2019-06-03T18:30:47", "url": "https://files.pythonhosted.org/packages/09/bf/ae3e6b71c8b6a3e7a2dc895b4ae2368f0b576312a7f82cd7301c0247cbf5/sam-template-creator-0.1.3.tar.gz" } ] }