Package: babble-cloud-cli
Babble CloudBabble is a tool that enables beginner programmers to rapidly deploy serverless applications to AWS through a readable, low-code, Python-based YAML configuration file.Table of ContentsRequirementsInstallationUsageConfigurationDemonstrationRequirementsPythonDockerAWSInstallationTo install Babble, run the following command:pipinstallbabble-cloudUsageTo start a new project, run the following command:babblecreateTo set the configuration file for a project, run the following command:babblepush<sourcefile>To retrieve the configuration file from a project, run the following command:babblepull<destinationfile>To view the current configuration of a project, run the following command:babbleviewTo activate a project, run the following command:babbleactivateTo deactivate your project, run the following command:babbledeactivateTo delete your project, run the following command:babbledeleteNote:Upon running the commandsbabble activate,babble deactivate, and in some casesbabble delete, you will be prompted for your AWS account credentials in order to add or remove the necessary resources from your AWS account.  For information about obtaining these credentials, please refer to theAWS documentationon getting IAM role credentials.ConfigurationTo configure your application infrastructure, you will need to create a YAML configuration file containing your resources.  Currently, resources fall under five categories:tables,folders,packages,modules, andendpoints.TablesTable definitions are used to deploy DynamoDB tables to the user's AWS account.  The following methods can be accessed via dot notation from module and endpoint source code:put_item(item: dict)- Creates a new item in the table, or replaces an old item with a new item.  It is required that the item contains the "key" attribute specified in the table's configuration. If an item that has the same "key" attribute as the new item already exists in the table, the new item completely replaces the existing item. Otherwise, an entirely new item will be created.get_item(item: dict)- Retrieves an item from the table.  It is required that the item contains the "key" attribute specified in the table's configuration.  If there is no matching item, get_item will return an empty dict ({}).delete_item(item: dict)- Retrieves an item from the table.  It is required that the item contains the "key" attribute specified in the table's configuration.scan()- Performs a full table scan, returning a list of all items in the table.tables:<table name>:key:<key name><table name>:key:<key name>...FoldersFolder definitions are used to deploy S3 buckets to the user's AWS account.  The following methods can be accessed via dot notation from module and endpoint source code:open(path: str, mode: str)-url(path: str)-folders:<folder name>:<folder name>:...PackagesPackage definitions are used to include external packages in both module and endpoint source code.  These packages can be sourced from the Python Standard Library (lib), or packages from the Python Package Index (pip).packages:<package name>:source:<lib or pip>version:<version number or "~"><package name>:source:<lib or pip>version:<version number or "~">...ModulesModule definitions are used to write source code for the application.  All functions, classes, and variables defined within these modules can be accessed via dot notation from module and endpoint source code. Please note that all imports are handled implicitly and there is no need for any import statements.  All tables, folders, packages, and other modules can be accessed via dot notation.modules:<module name>:content:|# source code goes here<module name>:content:|# source code goes here...EndpointsEndpoint definitions are used to write source code that processes the request data and determines the response data. Please note that all imports are handled implicitly and there is no need for any import statements.  All tables, folders, packages, and modules can be accessed via dot notation. It is imperative that all endpoints contain a function namedrequestwith the parametersheaders,path,query, andbodyas shown below.endpoints:<endpoint method> <endpoint path>:content:|def request(headers, path, query, body):# source code goes herereturn response<endpoint method> <endpoint path>:content:|def request(headers, path, query, body):# source code goes herereturn responseDemonstrationCreation and ActivationStep 1:Create a new project. Upon running this command, you will be prompted for a name for your new project.babblecreateStep 2:Push your YAML configuration file to the project.  Upon running this command, you will be prompted to select a project you previously created.babblepush<filename>Step 3:Activate your project.  Upon running this command, you will be prompted to select a project you previously created.babbleactivateDeactivation and DeletionStep 1:Deactivate your project.   Upon running this command, you will be prompted to select a project you previously created.babbledeactivateStep 2:Delete your project.   Upon running this command, you will be prompted to select a project you previously created.  If the selected project is not deactivated, it will be deactivated automatically.babbledeleteConfiguration FileHere is an example of a configuration file that can be used with Babble to deploy a serverless application:tables:my_table:key:my_keyfolders:my_folder:packages:pandas:source:pipversion:1.5.3json:source:libversion:~modules:my_module:content:|def get_item(item_key):return my_table.get_item({"my_key": item_key})def put_item(item_key, body):item = json.loads(body)item["my_key"] = item_keymy_table.put_item(item)def delete_item(item_key):my_table.delete_item({"my_key": item_key})def get_items():items = my_table.scan()df = pandas.DataFrame.from_dict(items)with my_folder.open("output.txt", "w") as fp:fp.write(df.to_string())return my_folder.url("output.txt")endpoints:GET /items/{item_key}:content:|def request(headers, path, query, body):return my_module.get_item(path["item_key"])PUT /items/{item_key}:content:|def request(headers, path, query, body):return my_module.put_item(path["item_key"], body)DELETE /items/{item_key}:content:|def request(headers, path, query, body):return my_module.delete_item(path["item_key"])GET /items:content:|def request(headers, path, query, body):return my_module.get_items()