Sha256: a2d3ad637999eb6cca9fdc58143c83fa5a0d63b9ed23663f0023a788cd2c4b5c

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

#!/usr/bin/env ruby

require 'aws-sdk-ssm'

env = {}
puts 'Injecting application secrets...'

begin
  client = Aws::SSM::Client.new

  next_token = nil
  loop do
    secrets = client.get_parameters_by_path(
      path: ENV.fetch('SSM_KEY_PATH'),
      with_decryption: true,
      next_token: next_token
    )

    secrets.parameters.map do |parameter|
      key = parameter.name.split('/').last
      value = parameter.value
      env[key] = value
    end

    next_token = secrets.next_token
    break unless next_token

    sleep 1 # don't overrun the API rate limit
  end
rescue Aws::Errors::MissingRegionError
  puts 'ERROR! Unable to fetch SSM parameters!'
  puts 'In production environments, this should fail startup!'
end

exec env, *ARGV

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cai-ecs-entrypoint-1.0.0 bin/ssm-entrypoint