Skip to main content

Loop Component

Repeat a set of steps by iterating over items in a dataset or a fixed number of iterations

Component key: loop

Description

The loop component allows you to loop over a list of items or loop a specific number of times depending on which action is selected. This is handy if you have a set of files or pieces of data to process. The loop component can be set up execute a series of actions on each file or item in a list.

The array that is looped over can contain numbers, strings, or complex objects, but all items in the array should be of the same type.

For each iteration of the loop, the loop provides two variables - currentItem and index, which contains the item currently being looped over, and the zero-indexed number of the item respectively. For example, if your array looked like this:

[
{
"firstName": "Bob",
"lastName": "Smith"
},
{
"firstName": "Vince",
"lastName": "Nguyen"
}
{
"firstName": "Sally",
"lastname": "Jones"
}
]

The second iteration of the loop would have a currentItem of { "firstName": "Vince", "lastName": "Nguyen"}, and an index of 1.

Looping is particularly useful for looping over files. For example, if you used the Amazon S3 listObjects action to list objects in an S3 bucket, you can use a loop to perform a series of actions on each of those S3 objects.

Actions

Break Loop

Breaks out of the current Loop, causing execution to resume after the containing Loop. | key: breakLoop


Loop N Times

Loops over the the steps in the loop N times, or until a loop break occurs. | key: loopNTimes

InputDefaultNotes
Number of Iterations
string
/ Required
iterationCount
1000
The number of times to execute the steps in the loop.

Loop Over Items

Loops over items, applies each step in sequence, and returns a new collection of the results. Items must be an Array or Object. | key: loopOverItems

InputNotes
Items
data
/ Required
items
These are the items to loop over. This must be an Array (list) or Object, and should be a reference to a previous step's results.