A simple AWS lambda function that takes a JIRA webhook payload, creates a Discord-compatible webhook payload, and executes the appropriate Discord webhook. This repository is inspired by aucerna/jira-discord-lambda which was written with scala. This repository however is code in dotnet. Some of the functionality has been changed to accommodate my specification.
Setup instruction:
- Create an AWS Lambda function. Choose .Net 6(C#/PowerShell) as the runtime and upload the published code.
- Define the environment variable in lambda:-
- discord_id - Discord webhook id
- discord_token - Discord webhook token
- jira_api_key - Jira Rest API token key.
- jira_email - Jira email of the generated token.
- Change the handler to JiraDiscord::JiraDiscord.Program::Handler
- Add DynamoDb table named "jira_user_mapping" with hash key of "jira_account_id" string. DynamoDb is used to store user mapping of jira account id and the display name.
- Add the DynamoDb accsess to the lambda role.
- Create an HTTP API in AWS API Gateway
- Add integration with the lambda function. Choose Version 2.0
- Define your preferred route.
- Create a webhook in Discord, take note the URL will contain the discord id and token.
- Create JIRA webhook from setting->system->WebHooks.
- Fill in the URL with this format: (https://[Api_Url]/[Route]?projectKey=${project.key})
- Save and test the webhook.
The diagram below shows how the flow work. Credit to aucerna. See his blog post to see more depth in technical view.
https://github.com/aucerna/jira-discord-lambda https://discordapp.com/developers/docs/resources/webhook#execute-webhook