{"id":20471739,"url":"https://github.com/signiant/jarvis","last_synced_at":"2025-04-13T11:08:45.100Z","repository":{"id":46648903,"uuid":"46365725","full_name":"Signiant/Jarvis","owner":"Signiant","description":"Slack bot to query AWS Elastic Beanstalk and ECS resources (Lambda/API Gateway)","archived":false,"fork":false,"pushed_at":"2023-05-22T21:33:46.000Z","size":686,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-13T11:08:30.243Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Signiant.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-17T18:09:15.000Z","updated_at":"2022-05-15T14:48:23.000Z","dependencies_parsed_at":"2024-05-29T16:12:32.497Z","dependency_job_id":null,"html_url":"https://github.com/Signiant/Jarvis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Signiant%2FJarvis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Signiant%2FJarvis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Signiant%2FJarvis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Signiant%2FJarvis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Signiant","download_url":"https://codeload.github.com/Signiant/Jarvis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248703198,"owners_count":21148118,"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":[],"created_at":"2024-11-15T14:17:06.943Z","updated_at":"2025-04-13T11:08:45.074Z","avatar_url":"https://github.com/Signiant.png","language":"Python","readme":"# Jarvis\nJarvis is your personal AWS Slackbot. Currently, Jarvis can be used to find out information about ECS services and Elastic Beanstalk environments running in AWS.\n\n## Preparing\nClone the repository\n\n``` git clone https://github.com/Signiant/Jarvis ```\n\nCD into the Jarvis directory then install requirements in the current directory\n\n``` pip install -r requirements.txt -t . ```\n\nCreate a file called SLACK_TEAM_TOKEN that contains your Slack team token\n\nOptional: If you plan on using Jarvis on multiple aws accounts, include a file called aws.config\n```json\n{\n    \"Accounts\": [\n        {\n            \"AccountName\": \"KeyWord\",\n            \"RoleArn\": \"arn:aws:iam::role/jarvis\"\n        }\n    ]\n}\n```\nZip everything inside the Jarvis folder\n\n``` zip -r lambda.zip * ```\n\n## Deploying Jarvis to Lambda\n\nJarvis consists of a Lambda function in python which is installed behind API Gateway.  You'll need to configure API gateway to call the lambda function at a REST endpoint and upload to Lambda the zip that you created previously.\n\n### IAM\n\nCreate an IAM Role that has a trusted relationship from AWS Lambda.\n\nCreate and attach a policy or more to the role that allows listing and describing from ECS and any other permissions that plugins need.\n\n### Lambda\nCreate a new Lambda function and choose to upload a python zip, select the created zip and hit save.\n\nUnder API Endpoints, choose to add an API endpoint from API Gateway. Fill in the form, selecting POST for the method and Open for the security.\n\n### API Gateway\nNavigate to your created API Gateway entry for the Lambda function. Open the POST method then choose **Integration Request**\n\n**This step turns the incoming request into a string within a json object that we can parse later on**\n\nUnder **Mapping Templates**, add a new entry that has *Content-Type* set to *application/x-www-form-urlencoded* then edit the mapping template to include:\n``\n{\n    \"formparams\": $input.json(\"$\")\n}\n``\n\n**The following steps are done to stop slackbot from posting a 'null' message whenever a slash command is issued for this function**\n\nReturn to the POST method and select **Integration Response**\n\nUse the arrow on the left to expand and reveal a section named **Mapping Templates**\n\nAdd an entry to *Content-Type* with a value of *application/json* and set the mapping template to:\n\n``` #set($inputRoot = $input.path('$')) ```\n\nNow, return to the POST method one more time and select **Method Response**\n\nUse the arrow on the left to expand the 200 Response section and select *Add Response Model*\n\nSet the *Content-Type* to *application/json* and the *Models* to *Empty*\n\nDeploy your API when ready. Copy the URL shown to you. You will need that to set up your slash command in Slack.\n\n### Slack\n\nYou will also need to configure your slash command on Slack to post the information to your API Gateway URL.\n\nGo to *Configure Integrations* on your slack team then choose *Configured Integrations*\n\nFind *Slash Commands* in the list presented to you, then choose *Add*\n\nSet a command that you want to use to call Jarvis (ex. /jarvis) and set the URL to the previously copied URL from API Gateway\n\nSet the *Method* to `POST` and finish by customizing the bot's name and icon.\n\nOnce that is done, issuing \"/jarvis help\" will display the available commands\n\n## Creating plugins\n\nTo create a plugin, simply create a folder with the plugin name in the plugins folder. An example would be: `plugins/blame`\n\nIn the plugin folder, `blame` in this case, create a file named __init__.py.\n\nThis file is the entry point of your plugin. This python file MUST contain the following three functions:\n\n`main(text)` The entry point to your plugin's main functionality. More on return values later.\n\n`about()` This shows up when somebody asks Jarvis for help. Have it return a string that contains a brief description of what the plugin does.\n\n`information()` This shows up when somebody asks for help on a specific plugin. This is where you return a string containing a more detailed explanation.\n\n### main(text) return what?\n\nThere are two ways a plugin can return values to be posted into your slack.\n\nThe first method is just returning a string. This will just post said string on a slack channel.\n\nThe second method is by returning a Slack attachment object. The syntax is as follows:\n\n```json\n{\n    \"attachments\": [\n        {\n            \"fallback\": \"Required plain-text summary of the attachment.\",\n\n            \"color\": \"#36a64f\",\n\n            \"pretext\": \"Optional text that appears above the attachment block\",\n\n            \"author_name\": \"Bobby Tables\",\n            \"author_link\": \"http://flickr.com/bobby/\",\n            \"author_icon\": \"http://flickr.com/icons/bobby.jpg\",\n\n            \"title\": \"Slack API Documentation\",\n            \"title_link\": \"https://api.slack.com/\",\n\n            \"text\": \"Optional text that appears within the attachment\",\n\n            \"fields\": [\n                {\n                    \"title\": \"Priority\",\n                    \"value\": \"High\",\n                    \"short\": false\n                }\n            ],\n\n            \"image_url\": \"http://my-website.com/path/to/image.jpg\",\n            \"thumb_url\": \"http://example.com/path/to/thumb.png\"\n        }\n    ]\n}\n```\n\nMore information on the syntax of attachments can be found at: https://api.slack.com/docs/attachments\n\n## Configuring aws.config for the EB, ECS and s3 plugins\n\nThe EB, ECS and s3 plugins make use of an aws.config file to assume roles in different accounts. The syntax of the config file is as follows:\n\nNote: We use a BlueGreen Deployment release technique on Elastic Beanstalk. In order to find out which is the `live` environment, the config file contains an `Applications` section that contains the Application Name, Hosted Zone ID, and DNS Record to figure out which environment is the `live` environment by looking at which load balancer the Route53 record set is pointing to.\n\nThe `Applications` key at the same level as the `Accounts` key is the `default account`. i.e. the same account where Jarvis is running.\n\n```json\n{\n\t\"Accounts\": [{\n\t\t\"AccountName\": \"KeyWord\",\n\t\t\"RoleArn\": \"arn:aws:iam::role/jarvis”,\n\t\t\"Applications\": {\n\t\t\t\"us-east-1\": [{\n\t\t\t\t\"ApplicationName\": “ApplicationName”,\n\t\t\t\t\"HostedZoneId\": “ZXXXXXXXXXX”,\n\t\t\t\t\"DNSRecord\": “something.somewhere.com”\n\t\t\t}],\n\t\t\t\"us-west-1\": [{\n\t\t\t\t\"ApplicationName\": “ApplicationName”,\n\t\t\t\t\"HostedZoneId\": “ZXXXXXXXXXX”,\n\t\t\t\t\"DNSRecord\": “something.somewhere.com”\n\t\t\t}]\n\t\t}\n\t}],\n\t\"Applications\": {\n\t\t\"eu-west-1\": [{\n\t\t\t\"ApplicationName\": “ApplicationName”,\n\t\t\t\t\"HostedZoneId\": “ZXXXXXXXXXX”,\n\t\t\t\t\"DNSRecord\": “something.somewhere.com”\n\t\t}]\n\t}\n}\n```\nThe s3 bucket store the aws.config is under ```s3://jenkins-user-bucket/Jarvis/aws.config```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigniant%2Fjarvis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsigniant%2Fjarvis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigniant%2Fjarvis/lists"}