Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flexjames/ae5fb1b66ae56ba567e91684ce4a109f to your computer and use it in GitHub Desktop.
Save flexjames/ae5fb1b66ae56ba567e91684ce4a109f 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