Trigger AWS CodePipeline pipelines with fzf

Simple bash script allowing to select CodePipeline pipelines using fuzzy finder and trigger them. Uses aws cli, jq and fzf packages.

#!/bin/bash

list_pipelines() {
  aws codepipeline list-pipelines --output json | jq -r '.pipelines[].name'
}

trigger_pipeline() {
  local pipeline_name=$1
  aws codepipeline start-pipeline-execution --name "$pipeline_name"
}

select_pipelines() {
  list_pipelines | fzf --multi --header="Select pipeline(s) to trigger"
}

main() {
  selected_pipelines=$(select_pipelines)

  if [ -z "$selected_pipelines" ]; then
    exit 0
  fi

  for pipeline in $selected_pipelines; do
    trigger_pipeline "$pipeline"
  done
}

main