Skip to content

Commit 5434430

Browse files
committed
Added a role flag
This allows publishing a lambda function without needing to publish the role in the config. By default the flag will read the environment variable LAMBDA_UPLOADER_ROLE which can be set in CI to make full CD easier.
1 parent 8de5a97 commit 5434430

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lambda_uploader/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424

2525

2626
class Config(object):
27-
def __init__(self, pth, config_file=None):
27+
def __init__(self, pth, config_file=None, role=None):
2828
self._path = pth
2929
self._config = None
3030
self._load_config(config_file)
31+
if role is not None:
32+
self._config['role'] = role
3133
self._set_defaults()
3234

3335
for param, clss in REQUIRED_PARAMS.iteritems():

lambda_uploader/shell.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import traceback
2323
import lambda_uploader
2424

25-
from os import getcwd, path
25+
from os import getcwd, path, getenv
2626
from lambda_uploader import package, config, uploader
2727

2828
LOG = logging.getLogger(__name__)
@@ -47,7 +47,7 @@ def _print(txt):
4747
def _execute(args):
4848
pth = path.abspath(args.function_dir)
4949

50-
cfg = config.Config(pth, args.config)
50+
cfg = config.Config(pth, args.config, role=args.role)
5151

5252
_print('Building Package')
5353
pkg = package.build_package(pth, cfg.requirements)
@@ -97,6 +97,10 @@ def main(arv=None):
9797
action='store_const',
9898
help='publish an upload to an immutable version',
9999
const=True)
100+
parser.add_argument('--role', dest='role',
101+
default=getenv('LAMBDA_UPLOADER_ROLE'),
102+
help=('IAM role to assign the lambda function, '
103+
'can be set with $LAMBDA_UPLOADER_ROLE'))
100104
parser.add_argument('--profile', dest='profile',
101105
help='specify AWS cli profile')
102106
alias_help = 'alias for published version (WILL SET THE PUBLISH FLAG)'

0 commit comments

Comments
 (0)