Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to copy code from one AWS Lambda function to another without downloading it first?

So I'm currently working on building the deployer for our AWS Lambda functions.

Since AWS versions all share a configuration, this requires having multiple functions (foo_prod, foo_staging, foo_whatever) that are the various versions of our code instead of using aliases like I want to do.

So my question is:

1) Whether or not there's a sane way to re-deploy code. (IE: Staging to Prod) without downloading it to my desktop first and then re-uploading.

2) Whether or not I'm wrong about that shared configuration bit or whether it's possible to tell under which alias the function is running in the actual Lambda such that I can create multiple environment variables for each environment.

like image 994
Kevin Meyer Avatar asked Jul 12 '17 21:07

Kevin Meyer


1 Answers

You can deploy lambda functions in a lot of different ways that don't involve downloading and re-uploading code. If you use something like SAM (http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-use-app-spec.html) you can just point to an S3 bucket that holds your code and build functions from that. You can also hook CloudFormation up to git repository like Github or AWS CodeCommit and have it automatically update your functions when you push commits to the repository. And there are other systems like Severless (https://serverless.com) that can abstract and automate deploys in repeatable and manageable ways.

The Lambda's version is available in the context object. You should be able to tell which alias is called by looking at the ARN. ARNs have the alias as a suffix such as:

arn:aws:lambda:aws-region:acct-id:function:helloworld:PROD    

Info here: http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html

like image 76
Mark Avatar answered Oct 07 '22 01:10

Mark