Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save flexjames/535ed74b7de6024f4a0f180e393fc6ea to your computer and use it in GitHub Desktop.
Save flexjames/535ed74b7de6024f4a0f180e393fc6ea 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