#!/usr/bin/env ruby if ENV.has_key?('SSM_KEY_PATH') require 'docker/pipeline/ssm_parameters' require 'timeout' puts 'Injecting application secrets...' begin ssm_key_path = ENV.fetch('SSM_KEY_PATH') exec Docker::Pipeline::SsmParameters.at(ssm_key_path), *ARGV rescue Aws::Errors::MissingRegionError puts 'Error: Missing AWS Region' exit 1 rescue Aws::Errors::MissingCredentialsError puts 'Error: Missing AWS Credentials' exit 2 rescue Docker::Pipeline::ExcessiveThrottlingError puts 'Error: Unable to fetch all SSM Parameters; exhausted retries due to API throttling!' exit 3 rescue Timeout::Error puts 'Error: Unable to fetch all SSM Parameters; exhausted maximum allowable time to complete!' end else exec *ARGV end