Package: slsmanager
Serverless ManagerA basic Python Tool that simplifies the deployment of multiple AWS Lambda functions directly from an AWS CodeCommit Repository.pip install slsmanagerThis project uses a combination ofServerlessandBoto3Set UpSet up an IAM user on your AWS consoleYou can find the required permissions here:assets/IAMpolicyThese policies are only for reference and should be edited as required (to limit accessespeciallywith IAM permissions)Store the Access Key ID and the Secret Access KeyGenerate the git credentials for the user. (Security Credentials -> HTTPS Git Credentials)Using the toolDirectly through AWS CodeBuild (> v0.1.7) :Serverless Manager can be directly used from AWS CodeBuild.Set up the required CodeCommit Repo (This can be done through the AWS Console)Clone the repo to your local directory using Git CredentialsSkip the next 2 steps if you have a CodeBuild Project and a CodePipeline set up.Create a CodeBuild Project:Skip these steps if you used slsmanager to create the projectSet the source provider toCodeCommitand the repository to the newly created CodeCommit repositoryPick the branch you will be pushing to (usually this ismain)In buildspec, choose“Use a buildspec file”and leave the filename empty (Since the default isbuildspec.ymlCreate the projectEdit the environment variables and add the following variables:The ENV_NAME_st variable is the stage variable that would be a part of the name of the final Lambda you would be deploying. For instance, I have the_stvariable set tolambdaand theSERVICE_Namevariable set toBestX, my final Lambdas will be namedBestX-lambda-funNameCreate a CodePipeline:Using the AWS console:Source provider:AWS CodeCommitRepo Name:Source repoBuild Provider:AWSCodeBuildProject Name:Name of Codebuild ProjectSkip deploy stage since we are using theServerless Frameworkto deploy our functionsCreate the PipelineCreate abuildspec.ymlfile using the provided template.Add thisbuildspec.ymlfile to the local repository along with your handlers.For now, the js handlers need to be calledindex.jsand python handlers need to be calledlambda_function.py. Place these handlers in sub-directories in your repo directory.For instance, my test repo directory looked like this:. 
├── buildspec.yml 
├── backend  
│   └── lambda_function.py   
├── deploy  
│   └── lambda_function.py  
├── testing  
│   └── index.js  
└── ui  
   └── index.jsOnce you commit/push these changes, CodeBuild will automatically run Serverless Manager and create aserverless.ymlfile (which will be removed after deployment).It will then callsls deploywhich will deploy your lambda functionsServerless Manager will also create an aliasdevfor each function and point it to$LATEST. You can use this alias and add other aliases to stage development.Read more about aliaseshereOn your Local Computer (Incomplete):If you wish to use slsmanager from your local computer to create projects/repositories:Open a terminal window and navigate to the directory with the handler file.Install serverless-manager on your local machine:pip install slsmanagerRun serverless manager on your terminal:slsmanager1. Creating a CodeCommit RepositoryFollow the instructions to create a CodeCommit Repository and clone it to your directory using the Git Credentials.You can also do this from the AWS console.2. Creating a CodeBuild Project(OPTION 1: using slsmanager)You can use slsmanager to create a CodeBuild Project.You will need your AWS Access Key ID, your Secret Access Key, the default region and the URL to your CodeCommit Repository(OPTION 2: using AWS console)Follow the steps provided in the first section of this README3. Creating the CodePipelineServerless manager doesn't support the creation of a CodePipeline yet.Follow the steps provided in the first section of this README4. Creatingserverless.ymlandbuildspec.yml(INCOMPLETE)Please use the provided buildspec.yml template and do not create a serverless.yml file using slsmanager as it is currently incompleteIf you have a file calledhandlerFun1.js, and it contains the function firstFun() which you would like to deploy.Follow the on-screen instructions:Here, I created a service called "CodeCommitTest"I set the AWS-region to us-east-2 (which is what my AWS console is set to).The stage sets the serverlessstageproperty.The ENV_NAME is the last part of the ENV_NAME_ environment variables (which we set earlier). This will be reflected in the final name of your function on your console. This property allows us to create multiple  deployed versions of the same lambda function source.Module name follows the conventiondirectory/filename.functionThefunction nameis the name of the final lambda function (and is set inserverless.yml).By default, the only file added to the current lambda function (That will show up on the console) is the handler file provided in the module name. If you would like to include other files in the final lambda function that is deployed, you may edit the newly generatedserverless.ymland add the required files to thefunctions/your_function/package/patternsYou may also edit/add any other properties inserverless.ymlFinally, the tool generates a buildspec.yml file for your function.If you want to deploy all lambda functions present inserverless.ymlyou can press'a'in the final step. Otherwise, press'n'.Once you have completed all your steps, you will see 2 new filesserverless.yml(Which lists all the properties required to deploy using the Serverless Framework andbuildspec.yml(Which instructs CodeBuild to deploy the function(s) using the given files and properties.OptionsThere are a few config options you can use while runningslsmanagerAdd / Createslsmanager --add/-aThis allows you to skip the preliminary steps in the CLI (Create CodeCommit Repo/ Create CodeBuild Project) and jump directly to adding functions toserverless.ymland (later)buildspec.yml.Buildspecslsmanager --buildspec / -bThis allows you to skip all preliminary steps in the CLI and jump directly to adding deploy commands tobuildspec.yml.NoCLIslsmanager --nocli/-nREQUIRES-oto also be usedThis allows you to deploy the functions directly from codeCommit without needing to create aserverless.yml. Follow the steps above.Optionsslsmanager -n -o "service" "region" "stage"Options required for the noCLI method.Aliasesslsmanager -l "ACCESS-KEY-ID" "SECRET-ACCESS-KEY" "region"Creates adevalias for all functions in theserverless.ymlfile.This is also run when you use the provided templatebuildspec.yml