Use Jira Ticket to Upgrade Instance

.

Before starting with this guide, follow all steps given here

.

  1. Open a filter node, and select the input as data from the Resource Node. We will filter out only the EC2 instances that we've received from the Jira Ticket.
    1. Select Tags as the filter type
    2. Select condition as Has.
    3. Enter $.<CustomNodeID>.data.InstanceTagKey as the Key and $.<CustomNodeID>.data.InstanceTagValue as Value (referring to the first custom node in the workflow)
      1. Eg. Key: $.node-38d67602-custom.data.InstanceTagKey; Value: $.node-38d67602-custom.data.InstanceTagValue
    4. Click Add Condition, and select Param as filter type
      1. Set Key as '$.State..Name', Operator as '==' and Value as 'running'
    5. Click Save

.

  1. Add a Custom Node. We will use this to mention the order in which to upgrade instances.
    1. Select the output of the Filter Node from the drop-down
    2. Select custom as predefined logic
    3. Paste the following code under Enter custom code:
function upgradeEc2Instances(instanceType)
{
const sizes = ["nano", "micro", "small", "medium", "large", "xlarge", "2xlarge"]
let splitInstanceType= instanceType.split(".")
let indexOfLargerSize= sizes.indexOf(splitInstanceType[1])
let largerSize = sizes[indexOfLargerSize+1]
let upgradedInstance = splitInstanceType[0]+"."+largerSize
return upgradedInstance
}
async function process(){
let {collection,region} = context;
let result = [];
for(let i = 0;i< collection.length; i++){
const instance = collection[i];
const instanceType = instance.InstanceType
const nextInstanceType= upgradeEc2Instances(instanceType);
print(nextInstanceType);
result.push({...instance, nextInstanceType: nextInstanceType});
}
exit(null,result)
}
process().catch(exit);

.

  1. Add an Action Node. We will use this to stop the instances before changing the instance type.
    1. Select the output of the second Custom Node from the drop-down
    2. Select EC2 as service and Stop Instances as action
    3. Check the box Wait for stopInstances to finish
    4. Click Save

.

  1. Add another Action Node. We will use this to change the instance type.
    1. Select the output of the second Custom Node from the drop-down
    2. Select EC2 as service and Modify Instance Attribute as action
    3. Paste the following code in the Params Mapping box
{

/*---------- required params ----------*/

"InstanceId": "obj.InstanceId",

/*---------- optional params ----------*/

"InstanceType": {
"Value": "obj.nextInstanceType"
}
}

.

  1. Add another Action Node. We will use this to restart the instances after changing the instance type.
    1. Select the output of the Filter Node from the drop-down (this will ensure that we restart only the filtered instances that were in running state)
    2. Select EC2 as service and Start Instances as action
    3. Check the box Wait for startInstances to finish
    4. Click Save

.

  1. Add a Report Node. We will use this to send a report to our email once the instance is upgraded.
    1. Select the output of the last Action Node from the drop-down (Start Instances)
    2. Select Email, and enter the email on which you want to be notified
    3. Select the box Only send report if data is available
    4. Select Input Transformer, and enter the parameters you want included in your report
    5. Click Save

.

Instances that have the tag mentioned in the Jira Ticket will have their process upgraded

Did You Find This Article Helpful?

Use Jira Ticket to Reboot Instance Process

Powered by HelpDocs