description: |-
  # Retype GP2 EBS Volumes to GP3
  * Takes an EBS Snapshot and waits till CreateSnapshot process is completed
  * Retypes the EBS volume to GP3
  * Verifies if Volume Retyping was successful
  * Deletes the snapshot

  Inputs
  *  `volume_id` 
schemaVersion: '0.3'
assumeRole: '{{ AutomationAssumeRole }}'
parameters:
  volumeId:
    type: String
    description: ID of the EBS volume that needs to be converted from GP2 to GP3
  AutomationAssumeRole:
    type: String
    description: The ARN of the role that allows Automation to perform the actions on your behalf.
mainSteps:
  - name: CreateSnapshot
    action: 'aws:executeAutomation'
    inputs:
      DocumentName: AWS-CreateSnapshot
      RuntimeParameters:
        VolumeId: '{{volumeId}}'
  - name: RetypeVolume
    action: 'aws:executeAwsApi'
    inputs:
      Service: ec2
      Api: ModifyVolume
      VolumeId: '{{volumeId}}'
      VolumeType: gp3
  - name: CheckVolume
    action: 'aws:assertAwsResourceProperty'
    inputs:
      Service: ec2
      Api: DescribeVolumes
      PropertySelector: '$.Volumes[0].VolumeType'
      DesiredValues:
        - gp3
      VolumeIds:
        - '{{volumeId}}'
  - name: DeleteSnapshot
    action: 'aws:executeAutomation'
    inputs:
      DocumentName: AWS-DeleteSnapshot
      RuntimeParameters:
        SnapshotId: '{{ CreateSnapshot.Output }}'