Generate JIRA tickets from Pager Duty alerts using Amazon Web Services (AWS) Lambda!
pd2jira_python is an open source project that creates JIRA tickets from Pager Duty webhooks using AWS Lambda. This is a new option for making JIRA tickets from Pager Duty alerts. No need to host the code on your personal server (unless you want to).
pd2jira_python uses the following technologies:
- Python2.7
- AWS Lambda
- AWS API Gateway
- PagerDuty Webhooks
pd2jira-python will be up and running within minutes. Just follow this guide!
- Fork this project into your account and clone into local directory
git clone [email protected]:<your_github_handle>/pd2jira-python.git
note: replace <your_github_handle> with your Github handle
- Replace the comments in the Configs file with your credentials pd2jira-python/pd2jira-python/configs.yml Explanations:
- jira_url -- the site which your JIRA application is hosted from
- jira_username -- Username for which the JIRA tickets will be "created by." User must be registered with your JIRA account.
- jira_password -- Password for the above user.
- jira_project -- the project for which the ticket will be generated for. If DEVOPS was your project, ticket URL would be: https://<your_jira_site>.jira.com/browse/DEVOPS-6756
- Examples (from explanations above):
jira_url: https://<your_jira_site>.jira.com
jira_username: Team_Account
jira_password: topsecretpassword
jira_project: DEVOPS
Add custom configurations! (Look at configs.yml for example.
- Download dependencies and package project together into zip file: lambda.zip inside project root directory:
bash setup.sh
-
Upload lambda file to AWS
-
Log into your AWS account and navigate to Lambda
-
Click on "Create a Lambda Function"
-
Select Python 2.7 as language and "microsoft-http-endpoint" blueprint. Click next.
-
Configure your Lambda function. Give it a name and description.
-
For Lambda function code, select zip file. Upload the lambda.zip file from Step 3.
-
Set Lambda function handler and code * Handler: alertToTicket.lambda_handler * Role: "lambda_basic_execution"
-
Advanced settings. 128mb and 5 seconds should be plenty.
-
No VPC necessary
-
Configure Endpoints -- The only defaults that need to be changed: * Method: Post * Security: Open
-
Review and submit. Lambda is set up!
-
Navigate to "API Endpoints" and copy the API endpoint URL (you will need this for the next step).
-
Set up Pager Duty webhook.
-
Navigate to your Pager Duty account
-
Select a service you would like to create JIRA tickets from or create a new service
-
Click on "Add Webhook"
-
Give your webhook a name and paste the URL from the previous step. If you forgot to copy the API endpoint URL, go to AWS, navigate to Lambda, select your newly created Lambda function, and click on "API Endpoints."
-
You are done! Let's test it out
- In Pager Duty, navigate to the service you added the webhook to.
- Trigger an alert. NOTE: Make sure the person you are about to alert is aware that you are testing. You may want to create a new service or temporarily set yourself up as the on-call scheduled person.
- Go to JIRA and ensure your ticket was generated correctly. If you see your ticket, SUCCESS! If your new ticket was not created within 5 seconds, continue to the next step.
- Log in to AWS. Navigate to your Lambda function. Click on "Monitoring." Click on "View Logs in CloudWatch"
- View the log stream that was generated. This will give you some ideas as to why your ticket failed to be generated. Most likely, there are some custom fields you need to set to create tickets or your Configs were not properly configured. When you update the code, you will have to run the setup.sh again and reupload the zip file.
- To run the unit tests you must be in the project root directory and have nose installed
nosetests tests/
- Fork the repository.
- Make your changes.
- Add unit tests.
- Ensure unit tests pass.
- Submit pull-request. Please make sure your commit message contains a helpful comment. Please ensure you add a comment alongside your pull-request showing proof that your code works.