AWS Lambda to create a Jira story in Python

  1. et up a Jira account and obtain API credentials. This will include a Jira API key and a Jira username and password.
  2. Create an AWS Lambda function in your preferred language. In this example, we will use Python.
  3. Install the requests module by running pip install requests in your command line or terminal.
  4. Use the following code as a starting point:

import requests
import json

def lambda_handler(event, context):
# Set up the Jira API URL and credentials
url = ‘https://your-jira-instance.atlassian.net/rest/api/3/issue/’
username = ‘your-jira-username’
password = ‘your-jira-api-key’

# Set up the Jira issue data
issue_data = {
    "fields": {
        "project":
        {
            "key": "YOUR_PROJECT_KEY"
        },
        "summary": "YOUR_SUMMARY",
        "description": "YOUR_DESCRIPTION",
        "issuetype": {
            "name": "Story"
        }
    }
}

# Convert the issue data to JSON format
json_data = json.dumps(issue_data)

# Set up the HTTP request headers
headers = {
    'Content-Type': 'application/json'
}

# Set up the HTTP basic authentication
auth = (username, password)

# Send the HTTP POST request to create the issue
response = requests.post(url, data=json_data, headers=headers, auth=auth)

# Check if the request was successful
if response.status_code == 201:
    return "Jira issue created successfully"
else:
    return "Error creating Jira issue: " + response.text
  1. Replace the following variables in the code with your own Jira project key, issue summary, and issue description:
  • YOUR_PROJECT_KEY: The key of the Jira project where you want to create the new story.
  • YOUR_SUMMARY: The summary or title of the new story.
  • YOUR_DESCRIPTION: The description of the new story.
  1. Deploy the Lambda function to AWS.
  2. Test the function by triggering it with an event, such as a test event in the AWS Lambda console. If everything is set up correctly, the function should create a new Jira story with the specified details.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.