arazzo: 1.0.1
info:
title: Amazon EC2 Launch and Await Running
summary: Launch an instance, then poll DescribeInstances until it reaches the running state.
description: >-
Launches a single EC2 instance and then polls its state until it transitions
out of pending into running. The poll step branches on the reported instance
state name: while pending it loops back to describe again, and once running
it ends the workflow. Every step spells out its request inline using the
Amazon EC2 query protocol (Action and Version parameters) so the flow can be
read and executed without opening the underlying OpenAPI description.
version: 1.0.0
sourceDescriptions:
- name: instancesApi
url: ../openapi/amazon-ec2-instances-api-openapi.yml
type: openapi
workflows:
- workflowId: launch-and-await-running
summary: Launch one instance and wait for it to become running before returning.
description: >-
Chains RunInstances with a DescribeInstances poll loop that branches on the
instance state name, looping while pending and ending once running.
inputs:
type: object
required:
- imageId
- instanceType
properties:
imageId:
type: string
description: The AMI ID to launch the instance from.
instanceType:
type: string
description: The EC2 instance type (e.g. t3.micro).
keyName:
type: string
description: Optional name of the key pair to use for SSH access.
steps:
- stepId: runInstance
description: Launch a single instance from the supplied AMI.
operationId: RunInstances
requestBody:
contentType: application/x-www-form-urlencoded
payload:
Action: RunInstances
Version: '2016-11-15'
ImageId: $inputs.imageId
InstanceType: $inputs.instanceType
MinCount: 1
MaxCount: 1
KeyName: $inputs.keyName
successCriteria:
- condition: $statusCode == 200
outputs:
instanceId: $response.body#/instances/0/instanceId
- stepId: pollState
description: >-
Describe the launched instance and branch on its state, looping while
pending and ending once it reports running.
operationId: DescribeInstances
requestBody:
contentType: application/x-www-form-urlencoded
payload:
Action: DescribeInstances
Version: '2016-11-15'
InstanceIds:
- $steps.runInstance.outputs.instanceId
successCriteria:
- condition: $statusCode == 200
outputs:
state: $response.body#/reservationSet/0/instancesSet/0/instanceState/name
instanceId: $response.body#/reservationSet/0/instancesSet/0/instanceId
onSuccess:
- name: stillPending
type: goto
stepId: pollState
criteria:
- condition: $response.body#/reservationSet/0/instancesSet/0/instanceState/name == 'pending'
- name: nowRunning
type: end
criteria:
- condition: $response.body#/reservationSet/0/instancesSet/0/instanceState/name == 'running'
outputs:
instanceId: $steps.pollState.outputs.instanceId
finalState: $steps.pollState.outputs.state
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we
store it to create your key and to recognise you if you sign in with another
provider. By signing up you are subscribing to the APIs.io and API Evangelist
newsletters — you can unsubscribe from any issue. See our
Privacy Policy and Terms.