Skip to content

Instantly share code, notes, and snippets.

@chadjvw
Last active March 16, 2020 18:55
Show Gist options
  • Save chadjvw/21c61b092767562b4fcb42d7f5ee1653 to your computer and use it in GitHub Desktop.
Save chadjvw/21c61b092767562b4fcb42d7f5ee1653 to your computer and use it in GitHub Desktop.
Example AWS Step Function Iterator Pattern
CreateSnapshot:
Type: Task
Resource: ${self:custom.function-arn}-CreateSnapshot
Next: CreateSnapshotIterator
Retry: ${file(common.yml):reqLimitRetry}
CreateSnapshotIterator:
Type: Task
Resource: ${self:custom.function-arn}-Iterate
InputPath: '$.snapshotCreateIterator'
ResultPath: '$.snapshotCreateIterator'
Next: IsCreateSnapshotIterationComplete
Retry: ${file(common.yml):reqLimitRetry}
IsCreateSnapshotIterationComplete:
Type: Choice
Choices:
- Variable: '$.snapshotCreateIterator.continue'
BooleanEquals: true
Next: CreateSnapshot
Default: WaitForSnapshotsCreate
WaitForSnapshotsCreate:
Type: Wait
Seconds: 60
Next: CheckSnapshotsCreateStatus
CheckSnapshotsCreateStatus:
Type: Task
Resource: ${self:custom.function-arn}-CheckSnapshotsCreateStatus
Next: EvaluateSnapshotsCreateStatus
ResultPath: '$.snapshotStatus'
Retry: ${file(common.yml):reqLimitRetry}
EvaluateSnapshotsCreateStatus:
Type: Choice
Choices:
- Variable: '$.snapshotStatus'
StringEquals: ${self:custom.status.failed}
Next: StopInstancesFailure
- Variable: '$.snapshotStatus'
StringEquals: ${self:custom.status.success}
Next: DeleteVolume
Default: WaitForSnapshotsCreate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment