Table of Contents

Param Filter

Totalcloud Updated by Totalcloud

Param filter helps filter out resources either by their attributes or their Add-ons' attributes fetched from Resource node.

Example:

If you select Param and enter the below conditions, you can fetch only t2.medium instances from the subset of instances fetched from Resource node:

  • Enter Key with InstanceType
  • Enter Operator with ==
  • Enter Value with t2.medium

There are several conditional setters available in Param filter that you can use with Key and Value. Here's an overview of how to use Operators with Key and Value:

<

less than

Example:

To filter EC2 Volumes size less than 4GiB, use Param filter, and:

  • Enter Key with Ebs.VolumeSize
  • Enter Operator with <
  • Enter Value with 4GiB

>

greater than

Example:

To filter EC2s with CPU greater than 90% usage, use Param filter, and:

  • Enter Key with CPUUtilization
  • Enter Operator with >
  • Enter Value with 90

==

equal to

Example:

To filter instances with State Name as Stopped, use Param filter, and:

  • Enter Key with State.Name
  • Enter Operator with ==
  • Enter Value with Stopped

!=

not equal to

Example:

To filter EC2 Volumes State not in use, use Param filter, and:

  • Enter Key with VolumeState
  • Enter Operator with !=
  • Enter Value with Use

>=

greater than or equal to

Example:

To filter IAM roles with access key greater than or equal to 90 days, use Param filter, and:

  • Enter Key with AccessKeyLastUsed
  • Enter Operator with >=
  • Enter Value with 90

<=

less than or equal to

Example:

To filter EC2 Volumes' size less than or equal to 100 GiB, use Param filter, and:

  • Enter Key with VolumeSize
  • Enter Operator with <=
  • Enter Value with 100

has

has the value

Example:

To filter EC2 Volumes with Key 'addOns.Snapshots.data.VolumeId' has Value 'vol-1234567890', use Param filter, and:

  • Enter Key with addOns.Snapshots.data.VolumeId
  • Enter Operator with has
  • Enter Value with vol-1234567890

Not has

does not have the value

Example:

To filter EC2 Volumes with Key 'addOns.Snapshots.data.State' not has 'completed', use Param filter, and:

  • Enter Key with addOns.Snapshots.data.State
  • Enter Operator with not has
  • Enter Value with completed

More Context

When a Resource node executes, it fetches all the attributes of resources. Say, you have selected EC2 as Service and Instances as Resource in Resource node, the output of this node will have all the attributes as shown below.

```
Instances = [
{
"AmiLaunchIndex": 0,
"ImageId": "ami-0de53d8956e8dxxxxx",
"InstanceId": "i-090c12466862xxxxx",
"InstanceType": "t2.micro",
"State": {
"Code": 80,
"Name": "stopped"
},
"NetworkInterfaces": [
{

"Attachment": {
"AttachTime": "2019-03-27T04:33:16.000Z",
"AttachmentId": "eni-attach-0ab1798fc85cxxxxx",
"DeleteOnTermination": true
},
"Groups": [
{
"GroupName": "default",
"GroupId": "sg-09b49b4b205cxxxxx"
}
]
}
],

"SecurityGroups": [

{

"GroupName": "launch-wizard-2",
"GroupId": "sg-09b49b4b205cxxxxx"
},{

"GroupName": "launch-wizard-1",
"GroupId": "sg-09b49b4b205cxxxxx"
}
]
},
{

"AmiLaunchIndex": 0,
"ImageId": "ami-1de53d8956e8xxxxx",
"InstanceId": "i-190c12466862xxxxx",
"InstanceType": "t2.micro",
"State": {
"Code": 70,
"Name": "running"
},

"NetworkInterfaces": [
{

"Attachment": {
"AttachTime": "2019-03-27T04:33:16.000Z",
"AttachmentId": "eni-attach-0ab1798fc85cxxxxx",
"DeleteOnTermination": true
},

"Groups": [
{

"GroupName": "default",
"GroupId": "sg-09b49b4b205cxxxxx"
}

]
},
{
"Attachment": {
"AttachTime": "2019-03-27T04:33:16.000Z",
"AttachmentId": "abc-attach-0ab1798fc85cxxxxx",
"DeleteOnTermination": true
},
"Groups":

[
{
"GroupName": "launch-wizard-2",
"GroupId": "sg-11b49b4b205cxxxxx"
}
]

}

],

"SecurityGroups": [

{
"GroupName": "default,
"GroupId": "sg-09b49b4b205cxxxx"
}
]
}
]

```

To filter specific attributes from the above example, set the Param filter's Key and Value as shown below.

A. To filter instances with State Name as Stopped from the above example:

  • Enter Key with State.Name
  • Enter Operator with ==
  • Enter Value with Stopped

B. To filter all the instances with stopped state from the above example, using JSON path, use Param filter, and:

  • Enter Key with $.State.Name
  • Enter Operator with ==
  • Enter Value with stopped

You can use different symbols while using JSON path. Here's a list of essential symbols with its meaning:

$

The root object/element

@

The current object/element

.

Child member operator

..

Recursive descendant operator; JSONPath borrows this syntax from E4X

*

Wildcard matching all objects/elements regardless their names

[]

Subscript operator

[,]

Union operator for alternate names or array indices as a set

C. To filter just the 1st instance with stopped state from the above example, using JSON path, use Param filter, and:

  • Enter Key with $..Name
  • Enter Operator with ==
  • Enter Value with stopped

D. To filter instances where security group name in network interfaces is launch-wizard-2, from the above example, use Param filter, and:

  • Enter Key with $.NetworkInterfaces[*].Groups[*].GroupName
  • Enter Operator with ==
  • Enter Value with launch-wizard-2

E. To filter instances with all the Group Names of the second Group, from the above example, use Param filter, and:

  • Enter Key with $..Groups[*].GroupName
  • Enter Operator with ==
  • Enter Value with launch-wizard-2

F. To filter instances with just second Group name of 2nd Network Interface, from the above example, use Param filter, and:

  • Enter Key with $.NetworkInterfaces[1]..GroupName
  • Enter Operator with ==
  • Enter Value with launch-wizard-2

G. To filter instances with just the second GroupName, from the above example, use Param filter, and:

  • Enter Key with $..GroupName
  • Enter Operator with ==
  • Enter Value with launch-wizard-2

H. To filter instances' first SecurityGroup's GroupName with launch-wizard-2, from the above example, use Param filter, and:

  • Enter Key with $.SecurityGroup[0].GroupName
  • Enter Operator with ==
  • Enter Value with launch-wizard-2

I. To filter instances where security group name is 'default,' from the above example, use Param filter, and:

  • Enter Key with SecurityGroups.GroupName
  • Enter Operator with ==
  • Enter Value with default
NOTE: If you want to refer to SecurityGroups.GroupName you have to mention the complete depth as ```SecurityGroups.GroupName = default``` because ```GroupName = default ``` will get the first match for GroupName, which is NetworkInterfaces.Groups.GroupName.

J. To filter instances from last security group name, from the above example, use Param filter, and:

  • Enter Key with $.SecurityGroups[(@.length-1)]
  • Enter Operator with ==
  • Enter Value with launch-wizard-2

K. To filter instances from only 1st and 2nd security group, from the above example, use Param filter, and:

  • Enter Key with $.SecurityGroups[0,1]
  • Enter Operator with ==
  • Enter Value with launch-wizard-2

L. To filter instances from specific Availability zone, use Param filter, and:

  • Enter Key with $AvailabilityZone
  • Enter Operator with ==
  • Enter Value with us-east-1

Usage Examples:

Here are few usage examples to give you a gist of how to use this Filter:

  • Selecting only a specific type of EC2 instances
  • Selecting EC2 instances created in the past week

How did we do?

Types of Filter Node

Tags Filter

Contact