arazzo: 1.0.1
info:
title: Amazon EC2 Stop and Create Image
summary: Stop an instance, wait until stopped, then create an AMI from it.
description: >-
Captures a clean AMI from a running instance by first stopping it, polling
DescribeInstances until the instance reports the stopped state, and then
creating an image from the now-quiesced instance. The poll step branches on
the instance state name, looping while stopping and proceeding once stopped.
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
x-realizes-capability-ids:
- BC-600.50
x-capability-derivation:
method: 'deterministic join: sourceDescriptions -> per-tag OpenAPI -> tag/capability edge. No classification at this step.'
min_confidence: 0.7
sources:
- capability_id: BC-600.50
capability_name: IT Infrastructure Management
spec: amazon-ec2-amis-api-openapi.yml
confidence: 0.8
model: Turbo EA Capabilities by Vincent Verdet — Turbo EA, https://github.com/vincentmakes/turbo-ea-capabilities, CC BY 4.0
sourceDescriptions:
- name: amisApi
url: ../openapi/amazon-ec2-amis-api-openapi.yml
type: openapi
- name: instancesApi
url: ../openapi/amazon-ec2-instances-api-openapi.yml
type: openapi
workflows:
- workflowId: stop-and-create-image
summary: Quiesce an instance and snapshot it into a reusable AMI.
description: >-
Chains StopInstances, a DescribeInstances poll loop branching on the stopped
state, and CreateImage to produce an AMI from a cleanly stopped instance.
inputs:
type: object
required:
- instanceId
- imageName
properties:
instanceId:
type: string
description: The ID of the instance to stop and image.
imageName:
type: string
description: A name for the new AMI.
imageDescription:
type: string
description: An optional description for the new AMI.
steps:
- stepId: stopInstance
description: Stop the target instance ahead of imaging.
operationId: $sourceDescriptions.instancesApi.StopInstances
requestBody:
contentType: application/x-www-form-urlencoded
payload:
Action: StopInstances
Version: '2016-11-15'
InstanceIds:
- $inputs.instanceId
successCriteria:
- condition: $statusCode == 200
outputs:
stopStatus: $statusCode
- stepId: pollStopped
description: >-
Describe the instance and branch on its state, looping while stopping and
proceeding once it reports stopped.
operationId: $sourceDescriptions.instancesApi.DescribeInstances
requestBody:
contentType: application/x-www-form-urlencoded
payload:
Action: DescribeInstances
Version: '2016-11-15'
InstanceIds:
- $inputs.instanceId
successCriteria:
- condition: $statusCode == 200
outputs:
state: $response.body#/reservationSet/0/instancesSet/0/instanceState/name
onSuccess:
- name: stillStopping
type: goto
stepId: pollStopped
criteria:
- condition: $response.body#/reservationSet/0/instancesSet/0/instanceState/name == 'stopping'
- name: nowStopped
type: goto
stepId: CreateImage
criteria:
- condition: $response.body#/reservationSet/0/instancesSet/0/instanceState/name == 'stopped'
- stepId: CreateImage
description: Create an AMI from the stopped instance.
operationId: $sourceDescriptions.amisApi.CreateImage
requestBody:
contentType: application/x-www-form-urlencoded
payload:
Action: CreateImage
Version: '2016-11-15'
InstanceId: $inputs.instanceId
Name: $inputs.imageName
Description: $inputs.imageDescription
NoReboot: true
successCriteria:
- condition: $statusCode == 200
outputs:
imageId: $response.body#/imageId
outputs:
imageId: $steps.CreateImage.outputs.imageId
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.