Amazon EC2 · Arazzo Workflow

Amazon EC2 Release Elastic IP on Terminate

Version 1.0.0

Terminate an instance, wait until terminated, then release its Elastic IP.

1 workflow 1 source API 1 provider
View Spec View on GitHub Cloud ComputingComputeIaaSInfrastructureVirtual MachinesArazzoWorkflows

Provider

amazon-ec2

Workflows

release-eip-on-terminate
Terminate an instance and release its Elastic IP once it is gone.
Chains TerminateInstances, a DescribeInstances poll loop branching on the terminated state, and ReleaseAddress to reclaim the Elastic IP allocation.
3 steps inputs: allocationId, instanceId outputs: finalState, releaseStatus
1
terminateInstance
terminateInstances
Terminate the target instance.
2
pollTerminated
describeInstances
Describe the instance and branch on its state, looping while shutting-down and proceeding to release once it reports terminated.
3
releaseAddress
releaseAddress
Release the Elastic IP allocation back to the pool.

Source API Descriptions

Arazzo Workflow Specification

amazon-ec2-release-eip-on-terminate-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: Amazon EC2 Release Elastic IP on Terminate
  summary: Terminate an instance, wait until terminated, then release its Elastic IP.
  description: >-
    Avoids paying for an idle Elastic IP after an instance is gone. The workflow
    terminates the instance, polls DescribeInstances until the instance reports
    the terminated state, and then releases the Elastic IP allocation. The poll
    step branches on the instance state name, looping while shutting-down and
    releasing once terminated. 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: amazonEc2Api
  url: ../openapi/amazon-ec2-openapi.yml
  type: openapi
workflows:
- workflowId: release-eip-on-terminate
  summary: Terminate an instance and release its Elastic IP once it is gone.
  description: >-
    Chains TerminateInstances, a DescribeInstances poll loop branching on the
    terminated state, and ReleaseAddress to reclaim the Elastic IP allocation.
  inputs:
    type: object
    required:
    - instanceId
    - allocationId
    properties:
      instanceId:
        type: string
        description: The ID of the instance to terminate.
      allocationId:
        type: string
        description: The allocation ID of the Elastic IP to release.
  steps:
  - stepId: terminateInstance
    description: Terminate the target instance.
    operationId: terminateInstances
    parameters:
    - name: Action
      in: query
      value: TerminateInstances
    - name: Version
      in: query
      value: '2016-11-15'
    - name: InstanceId
      in: query
      value: $inputs.instanceId
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      terminateStatus: $statusCode
  - stepId: pollTerminated
    description: >-
      Describe the instance and branch on its state, looping while shutting-down
      and proceeding to release once it reports terminated.
    operationId: describeInstances
    parameters:
    - name: Action
      in: query
      value: DescribeInstances
    - name: Version
      in: query
      value: '2016-11-15'
    - name: InstanceId
      in: query
      value: $inputs.instanceId
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      state: $response.body#/reservationSet/0/instancesSet/0/instanceState/name
    onSuccess:
    - name: stillShuttingDown
      type: goto
      stepId: pollTerminated
      criteria:
      - context: $response.body
        condition: $.reservationSet[0].instancesSet[0].instanceState.name == 'shutting-down'
        type: jsonpath
    - name: gone
      type: goto
      stepId: releaseAddress
      criteria:
      - context: $response.body
        condition: $.reservationSet[0].instancesSet[0].instanceState.name == 'terminated'
        type: jsonpath
  - stepId: releaseAddress
    description: Release the Elastic IP allocation back to the pool.
    operationId: releaseAddress
    parameters:
    - name: Action
      in: query
      value: ReleaseAddress
    - name: Version
      in: query
      value: '2016-11-15'
    - name: AllocationId
      in: query
      value: $inputs.allocationId
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      releaseStatus: $statusCode
  outputs:
    finalState: $steps.pollTerminated.outputs.state
    releaseStatus: $steps.releaseAddress.outputs.releaseStatus