Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jvautier committed Feb 10, 2021
1 parent 51f8288 commit 93ea9b8
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions summon-provider-ssm
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env python

import os
import sys


def write_and_flush(pipe, message):
pipe.write(message)
pipe.flush()


try:
import boto3
ssm = boto3.client('ssm')
Expand All @@ -20,13 +21,15 @@ if __name__ == '__main__':
sys.exit(1)

variable = sys.argv[1]
prefix=os.environ.get('SUMMON_SSM_PREFIX', "")
variable = prefix + variable
prefix = os.environ.get('SUMMON_SSM_PREFIX', "")
variable = prefix + variable

ssm_parameter = ssm.get_parameter(Name=variable,WithDecryption=True)
value = ssm_parameter.get('Parameter').get('Value')
if value is None:
write_and_flush(sys.stderr, '{} could not be retrieved'.format(variable))
try:
ssm_parameter = ssm.get_parameter(Name=variable, WithDecryption=True)
value = ssm_parameter.get('Parameter').get('Value')
if value is None:
write_and_flush(sys.stderr, '{} could not be retrieved'.format(variable))
sys.exit(1)
write_and_flush(sys.stdout, value)
except:
sys.exit(1)

write_and_flush(sys.stdout, value)

0 comments on commit 93ea9b8

Please sign in to comment.