- et up a Jira account and obtain API credentials. This will include a Jira API key and a Jira username and password.
- Create an AWS Lambda function in your preferred language. In this example, we will use Python.
- Install the requests module by running
pip install requestsin your command line or terminal. - 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
- 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.
- Deploy the Lambda function to AWS.
- 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.
