Skip to content

Commit

Permalink
Merge pull request #2 from skrater/master
Browse files Browse the repository at this point in the history
Send executionRoleArn in register_task_definition
  • Loading branch information
skrater authored Mar 7, 2019
2 parents 11dca8c + b5529e8 commit eff1bba
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ecs_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self):
# run script
self._run_parser()


def _init_parser(self):
parser = argparse.ArgumentParser(
description='AWS ECS Deployment Script',
Expand Down Expand Up @@ -168,6 +169,7 @@ def _init_parser(self):
args = parser.parse_args(sys.argv[1:])
return vars(args)


def _run_parser(self):
self.cluster = self.args.get('cluster')
self.task_definition_name = self._task_definition_name()
Expand Down Expand Up @@ -213,11 +215,13 @@ def _run_parser(self):
else:
sys.exit(1)


def _int_or_none(self, value):
if type(value) == str and value.isdigit():
return int(value)
return None


def _task_definition_name(self):
if self.args.get('task_definition'):
return self.args.get('task_definition')
Expand All @@ -227,6 +231,7 @@ def _task_definition_name(self):
arn = service['services'][0]['taskDefinition']
return arn.split('/')[1].split(':')[0]


def _service_name(self):
if self.args.get('service_name'):
return self.args.get('service_name')
Expand All @@ -237,13 +242,15 @@ def _service_name(self):
in s][0]
return service.split('/')[1].split(':')[0]


def _arg_kwargs(self, kwargs, arg_name, alt_name=None):
# add specified arg to kwargs if it exists, return kwargs
if self.args.get(arg_name):
kwarg_name = alt_name or arg_name
kwargs[kwarg_name] = self.args.get(arg_name)
return kwargs


def client_kwargs(self, fn):
kwargs = {}

Expand All @@ -259,8 +266,10 @@ def client_kwargs(self, fn):

elif fn == 'register_task_definition':
kwargs['family'] = self.task_definition['family']
kwargs['containerDefinitions'] = \
self.task_definition['containerDefinitions']
kwargs['containerDefinitions'] = self.task_definition['containerDefinitions']

if 'executionRoleArn' in self.task_definition:
kwargs['executionRoleArn'] = self.task_definition['executionRoleArn']

# optional kwargs from args
for ci in self.args.get('container_image'):
Expand Down Expand Up @@ -309,6 +318,7 @@ def client_kwargs(self, fn):

return kwargs


def client_fn(self, fn):
try:
kwargs = self.client_kwargs(fn)
Expand Down

0 comments on commit eff1bba

Please sign in to comment.