python-lambda
python-lambda copied to clipboard
Support for version in Amazon API and filenames
Currently filenames are coded only with a timestamp... ideally there would be provisions for creating the filename based on a version string. The same input could then in turn be used to set the version as per the AWS Lambda API:
https://docs.aws.amazon.com/lambda/latest/dg/versioning-intro.html
This could be implemented by adding a "version: x.x.x" line to the config.yaml file, if present then the version provided will be used, otherwise the code will exhibit the current behavior for backward compatibility. Another option would be to add a '--version=x.x.x' command line parameter to 'lambda build' and the pending S3 change 'lambda upload'.
It would break 100% compatibility with current outputs, but it would also likely be more intuitive to have the filenames generated be in the format
Tagging my other non-work account @kilna
Also, bears mentioning... looking at the codebase, I can do this. Just curious if others have the same need.
Me too
Yes, I think this would be a very useful feature. I was thinking about submitting a patch for this along the same lines, so if you're doing it, I'll definitely support and use it.
I realised (later) that this issue was submitted a while ago. I since tried to write a patch, but got into trouble running: python setup.py sdist bdist_wheel upload
First Issue is that README.rst has been renamed to README.md (No such file or directory: 'README.rst'). I renamed it Second Issue: the command line upload doesn't seem to work without specifying a .pypirc file Third Issue: my user cannot upload patches to this project, and I can't see any way of getting those permissions.
So an additional issue is that it seems to be very hard to contribute to this project.
Anyway, it would be a very simple change in aws_lambda.py:
instead of:
# Combine the name of the Lambda function with the current timestamp to use
# for the output filename.
function_name = cfg.get('function_name')
output_filename = '{0}-{1}.zip'.format(timestamp(), function_name)
Have:
function_name = cfg.get('function_name')
function_version = cfg.get('version')
# If no version is set in config.yaml
# Combine the name of the Lambda function with the current timestamp
# otherwise combine the name of the Lambda function with the version
# for the output filename.
output_filename = (
'{0}-{1}.zip'.format(timestamp(), function_name)
if not function_version
else '{0}-{1}.zip'.format(function_name, function_version)
)