{"id":19601470,"url":"https://github.com/stackstorm/serverless-plugin-stackstorm","last_synced_at":"2025-04-27T17:32:02.197Z","repository":{"id":47596064,"uuid":"108401424","full_name":"StackStorm/serverless-plugin-stackstorm","owner":"StackStorm","description":"Plugin for serverless framework to run ready to use actions from StackStorm Exchange as AWS Lambda.","archived":false,"fork":false,"pushed_at":"2021-08-22T21:24:41.000Z","size":351,"stargazers_count":28,"open_issues_count":3,"forks_count":2,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-09-21T12:12:41.376Z","etag":null,"topics":["aws","aws-lambda","lambda","serverless","stackstorm","stackstorm-action"],"latest_commit_sha":null,"homepage":"https://exchange.stackstorm.org","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StackStorm.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":"2017-10-26T11:18:11.000Z","updated_at":"2021-05-17T20:40:35.000Z","dependencies_parsed_at":"2022-08-27T10:12:32.514Z","dependency_job_id":null,"html_url":"https://github.com/StackStorm/serverless-plugin-stackstorm","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StackStorm%2Fserverless-plugin-stackstorm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StackStorm%2Fserverless-plugin-stackstorm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StackStorm%2Fserverless-plugin-stackstorm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StackStorm%2Fserverless-plugin-stackstorm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StackStorm","download_url":"https://codeload.github.com/StackStorm/serverless-plugin-stackstorm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224076188,"owners_count":17251704,"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":["aws","aws-lambda","lambda","serverless","stackstorm","stackstorm-action"],"created_at":"2024-11-11T09:18:34.285Z","updated_at":"2024-11-11T09:18:35.254Z","avatar_url":"https://github.com/StackStorm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serverless StackStorm Plugin\n\n[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)\n[![npm version](https://badge.fury.io/js/serverless-plugin-stackstorm.svg)](https://badge.fury.io/js/serverless-plugin-stackstorm)\n\nRun ready to use actions from [StackStorm Exchange](https://exchange.stackstorm.com/)\nas AWS Lambda with [serverless framework](http://serverless.com/). Serverless and Stackstormless.\n\n## Prerequisite\n\n- [Serverless framework](https://serverless.com/framework/docs/getting-started/)\n- [NodeJS](https://nodejs.org/en/download/) \u003e= 8.4.0\n- [Docker](https://docs.docker.com/engine/installation/) - used to build and local-run Lambda on any OS\n- Build tools (``build-essentials`` package on Ubuntu)\n- SSL dev files (``libssl-dev`` package on Ubuntu)\n\n## Getting Started\n\nInstall serverless dependency globally\n\n```bash\nnpm install -g serverless\n```\n\nInit with `package.json`:\n\n```bash\nnpm init\n```\n\nInstall the plugin:\n\n```bash\nnpm i --save-dev serverless-plugin-stackstorm\n```\n\nBrowse [StackStorm Exchange](https://exchange.stackstorm.com/)\nto find the integration pack and an action you'd like to use.\nIn the example below we use `github.get_issue` from [GitHub integration pack](https://github.com/StackStorm-Exchange/stackstorm-github).\n\nConfigure your service to use the plugin by creating `serverless.yml` file.\n\n```yaml\nservice: my-service\n\nprovider:\n  name: aws\n  runtime: python2.7 # StackStorm runners are based on Python 2\n\nfunctions:\n  get_issue:\n    stackstorm: # `stackstorm` object replaces `handler`. The rest is the same.\n      action: github.get_issue\n      config:\n        token: ${env:GITHUB_TOKEN}\n      input:\n        user: \"{{ input.pathParameters.user }}\"\n        repo: \"{{ input.pathParameters.repo }}\"\n        issue_id: \"{{ input.pathParameters.issue_id }}\"\n      output:\n        statusCode: 200\n        body: \"{{ output }}\"\n    events:\n      - http:\n          method: GET\n          path: issues/{user}/{repo}/{issue_id}\n\nplugins:\n  - serverless-plugin-stackstorm\n```\n\nThere are few new options inside the function definition\n(see [serverless.example.yml](./serverless.example.yml) for more options):\n  - `stackstorm.action` allows you to pick up a function you want to turn into a lambda\n  - `stackstorm.config` sets config parameters for the action. Config parameters are pack-wide in stackstorm and are commonly used for authentication tokens and such.\n  - `stackstorm.input` defines how input event parameters should be transformed to match the parameters list stackstorm action expects\n  - `stackstorm.output` defines the transformation that should be applied to the action output to form a result of lambda execution\n\nIf you are in doubt on the list of parameters given StackStorm action expects, check action info:\n\n```\n$ sls stackstorm info --action github.get_issue\ngithub.get_issue .............. Retrieve information about a particular Github issue.\nParameters\n  issue_id [string] (required)  Issue id\n  repo [string] (required) .... Repository name.\n  user [string] (required) .... User / organization name.\nConfig\n  base_url [string] (required)  The GitHub URL, for GitHub Enterprise please set enterprise_url.\n  deployment_environment [string] (required)  The environment for this StackStorm server.\n  enterprise_url [string]  .... GitHub API url (including /api/v3) of your GitHub Enterprise hostname.\n  github_type [string] (required)  Default to either github or enterprise.\n  password [string]  .......... GitHub Password\n  repository_sensor [object]  . Sensor specific settings.\n  token [string] (required) ... GitHub oAuth Token\n  user [string]  .............. GitHub Username\n```\n\nThen deploy your function to the cloud and invoke it:\n\n```\nsls deploy\n\nsls invoke --function get_issue --log \\\n--data '{\"pathParameters\": {\"user\": \"StackStorm\", \"repo\": \"st2\", \"issue_id\": \"3785\"}}'\n```\n\nYou can also invoke a function locally for testing. It runs in docker container to ensure\ncompatibility with AWS lambda environment.\n```\nsls stackstorm docker run -f get_issue --verbose --passthrough -d '{\"pathParameters\": {\"user\": \"StackStorm\", \"repo\": \"st2\", \"issue_id\": \"3785\"}}'\n```\n\nNote the options:\n\n* `--passthrough`: skips actual invocation - comes handy to ensure the input maps to action parameters right, without invoking the body of the lambda.\n* `--verbose`:  shows the transformation routine that happened for a particular input and output.\n\nHere is an example of a verbose output:\n```\nIncoming event -\u003e\n{\n  \"issue_id\": \"222\"\n}\n-\u003e Parameter transformer -\u003e\n{\n  \"repo\": \"st2\",\n  \"issue_id\": \"222\",\n  \"user\": \"StackStorm\"\n}\n-\u003e Action call -\u003e\n{\n  \"result\": {\n    \"url\": \"https://github.com/StackStorm/st2/pull/222\",\n    \"created_at\": \"2014-07-14T19:25:46.000000+00:00\",\n    ...\n  },\n  \"exit_code\": 0,\n  \"stderr\": \"\",\n  \"stdout\": \"\"\n}\n-\u003e Output transformer -\u003e\n{\n  \"result\": \"2014-07-14T19:25:46.000000+00:00\"\n}\n```\n\n## Commands\n\n  The plugin also provides a few optional commands. You don't have to use them as they are all included into `sls package`, but they still might be handy in some situations.\n\n - `sls stackstorm` - Build λ with StackStorm\n - `sls stackstorm clean` - Clean StackStorm code\n - `sls stackstorm docker pull` - Pull λ docker image\n - `sls stackstorm docker start` - Start λ docker container\n - `sls stackstorm docker stop` - Stop λ docker container\n - `sls stackstorm docker exec` - Execute a command in λ docker container\n - `sls stackstorm docker run` - Execute a function in λ docker container\n - `sls stackstorm install adapter` - Install StackStorm adapter\n - `sls stackstorm install deps` - Install StackStorm dependencies\n - `sls stackstorm install packs` - Install a pack\n - `sls stackstorm install packDeps` - Install dependencies for packs\n - `sls stackstorm info` - Print information on the action\n\n## Exchange\n\nThe available packs can be discovered in StackStorm Exchange (https://exchange.stackstorm.com/). At the moment, the collection consist of 6500+ actions spread across 130 packs. We've yet to try them all, though, but the one we did are marked with [`serverless`](https://exchange.stackstorm.org/#serverless) tag.\n\n## Contributing to Exchange\n\nThe StackStorm packs this plugin allows you to run on serverless infrastructure are all part of [StackStorm Exchange](https://github.com/StackStorm-Exchange). We encourage community members to contribute to this packs to enrich the entire ecosystem. The most simple way to help us is to try different packs, mark the one that works with `serverless` keyword and report ones that don't work for some reason. For now, the plugin only supports stackstorm's python runner, but they represent more than 90% of exchange actions.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackstorm%2Fserverless-plugin-stackstorm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackstorm%2Fserverless-plugin-stackstorm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackstorm%2Fserverless-plugin-stackstorm/lists"}