{ "info": { "author": "Jordan Eremieff", "author_email": "jordan@eremieff.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7" ], "description": "# Mangum CLI\n\nThis package provides a command-line interface for generating AWS Lambda & API Gateway deployments used with [Mangum](https://github.com/erm/mangum).\n\n**Note**: This is a heavy work-in-progress, and it may be removed/changed at any point.\n\n**Requirements**: Python3.7+\n\n## Installation\n\n```shell\npip install mangum-cli\n```\n\n## Commands\n\n`mangum init` - Create a new deployment configuration.\n\n`mangum build` - Create a local build.\n\n`mangum deploy` - Deploy the packaged project.\n\n`mangum package` - Package the local build.\n\n`mangum describe` - Retrieve the endpoints for the deployment.\n\n`mangum validate` - Validate the AWS CloudFormation template.\n\n## Tutorial\n\nThe steps below outline a basic [FastAPI](https://fastapi.tiangolo.com/) deployment, however you should be able to use any ASGI framework/application with the adapter.\n\n### Step 1 - Create a local project\n\nFirst, create a new directory `app/`, this is the folder that will contain the main application code and function handler.\n\nThen create a file `asgi.py` with the following:\n\n```python\nfrom mangum import Mangum\nfrom fastapi import FastAPI\n\n\napp = FastAPI()\n\n\n@app.post(\"/items/\")\ndef create_item(item_id: int):\n return {\"id\": item_id}\n\n\n@app.get(\"/items/\")\ndef list_items():\n items = [{\"id\": i} for i in range(10)]\n return items\n\n\n@app.get(\"/\")\ndef read_root():\n return {\"Hello\": \"World!\"}\n\n\nhandler = Mangum(app)\n\n```\n\nThis demonstrates a basic FastAPI application, the most relevant part is:\n\n```python\nhandler = Mangum(app)\n```\n\nThe `handler` variable will be used as the handler name defined in the CloudFormation template to be generated later.\n\nLastly, create a `requirements.txt` file to include Mangum and FastAPI in the build:\n\n```\nmangum\nfastapi\n```\n\n\n### Step 2 - Create a new deployment configuration\n \nRun the following command with a name for the project (required) and optionally include the name of an S3 bucket and the region (these values can be changed later):\n\n```shell\nmangum init [bucket-name] [region-name]\n```\n\nAfter defining the configuration a `mangum.yml` file will be generated, the current directory should now look this:\n\n```shell\n\n\u251c\u2500\u2500 app\n\u2502 \u2514\u2500\u2500 asgi.py\n\u251c\u2500\u2500 mangum.yml\n\u2514\u2500\u2500 requirements.txt\n```\n\n### Step 3 - Create a local build\n\nRun the following command to create a local application build:\n\n```shell\nmangum build\n```\n\nThis will create a `build/` directory containing the application code and any dependencies included in `requirements.txt`.\n\n### Step 4 - Package the local build\n\nRun the following command to package the local build:\n\n```shell\nmangum package\n```\n\nThis wraps the AWS CLI's `package` command, it uses the definitions in `mangum.yml` to produce a `packaged.yml` file and a `template.yml` file.\n\n### Step 5 - Deploy the packaged build\n\nRun the following command to deploy the packaged build:\n\n```shell\nmangum deploy\n```\n\nThis wraps the AWS CLI's `deploy` command. It may take a few minutes to complete. If successful, the endpoints for the deployed application will be displayed in the console.", "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/erm/mangum-cli", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "mangum-cli", "package_url": "https://pypi.org/project/mangum-cli/", "platform": "", "project_url": "https://pypi.org/project/mangum-cli/", "project_urls": { "Homepage": "https://github.com/erm/mangum-cli" }, "release_url": "https://pypi.org/project/mangum-cli/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "CLI tools for Mangum", "version": "0.0.1" }, "last_serial": 5712414, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "7cd1581267c7d598d0285c4db25d5634", "sha256": "d373380f4b92764bf71dca980bd45c6d49b9ca6d7c1404d58bf12306827c8ec2" }, "downloads": -1, "filename": "mangum-cli-0.0.1.tar.gz", "has_sig": false, "md5_digest": "7cd1581267c7d598d0285c4db25d5634", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9499, "upload_time": "2019-08-22T00:05:51", "url": "https://files.pythonhosted.org/packages/07/3c/ec5ffda3efcb14feadb931c41f4de3404bd40351a358e98a50ab8260f7f2/mangum-cli-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7cd1581267c7d598d0285c4db25d5634", "sha256": "d373380f4b92764bf71dca980bd45c6d49b9ca6d7c1404d58bf12306827c8ec2" }, "downloads": -1, "filename": "mangum-cli-0.0.1.tar.gz", "has_sig": false, "md5_digest": "7cd1581267c7d598d0285c4db25d5634", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9499, "upload_time": "2019-08-22T00:05:51", "url": "https://files.pythonhosted.org/packages/07/3c/ec5ffda3efcb14feadb931c41f4de3404bd40351a358e98a50ab8260f7f2/mangum-cli-0.0.1.tar.gz" } ] }