Skip to content

Commit

Permalink
Add ability to specify name
Browse files Browse the repository at this point in the history
  • Loading branch information
jimjkelly committed Aug 10, 2016
1 parent 7099b65 commit 012a111
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ Lambda directory you would have a file
`lambda_function.py` which contains a
function `lambda_handler`.

#### Name (LAMBDA_NAME)

This is the name attached to your Lambda job
on AWS. It defaults to the directory name the
code resides in. This can be specified via
the `-n/--name` option on the command line
or the environment variable.

#### Description (LAMBDA_DESCRIPTION)

This is the description attached to your Lambda
Expand Down
19 changes: 16 additions & 3 deletions src/lambda_deploy/lambda_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class LambdaDeploy(object):
lambda_dir = os.getcwd()

def __init__(self, lambda_dir=None, env_file=None, env_vars=None,
role=None):
role=None, name=None):

if not env_file or env_file == self.DEFAULT_ENV_FILE:
env_file = os.path.realpath(os.getenv('LAMBDA_ENV_FILE', '.env'))
Expand Down Expand Up @@ -67,7 +67,10 @@ def __init__(self, lambda_dir=None, env_file=None, env_vars=None,

self.env_vars = env_vars
self.lambda_dir = lambda_dir
self.lambda_name = os.path.basename(os.path.normpath(self.lambda_dir))
self.lambda_name = name if name else yaep.env(
'LAMBDA_NAME',
os.path.basename(os.path.normpath(self.lambda_dir))
)
self.role = role if role else yaep.env('LAMBDA_ROLE')
self.client = boto3.client('lambda')

Expand Down Expand Up @@ -294,6 +297,15 @@ def main():
)
)

parser.add_option(
'-n', '--name', dest='name',
help=(
'The name of the Lambda to use on AWS. Defaults to '
'the name of the directory. Can be configured via '
'environment variable LAMBDA_NAME as well.'
)
)

parser.add_option(
'-l', '--logging-level', dest='logging_level', default='INFO',
help=(
Expand Down Expand Up @@ -344,7 +356,8 @@ def main():
lambda_dir=options.directory,
env_file=options.env_file,
env_vars=options.env_vars,
role=options.role
role=options.role,
name=options.name
), action, None)
except ArgumentsError:
logger.error('Invalid arguments.')
Expand Down
2 changes: 1 addition & 1 deletion src/lambda_deploy/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.1'
__version__ = '0.1.2'

0 comments on commit 012a111

Please sign in to comment.