0

I've launched this stack and needed to update it's Lamdba function, I've made some amendments and hit deploy, a new version of function was saved, however Lambda application still refers to the first version of function, I've tried to update stack, deploy from local environment and nothing worked, the only way was to re-create the whole stack with a link to modified functions in yml template.

Mike
  • 13
  • 3
  • You can put lambda version number in the file name then pass it as parameter to CF template. CF will not update function unless it knows something is different there, so just update zip isn't enough, you need to change its name. This way you'll re-create lambda only, not the whole stack. – Putnik Jan 30 '21 at 17:38
  • I've tried something like that - I've put a renamed zip to S3 and updated it's name in CF template and updated the stack with it, still no luck, it still used an old version (it created a 1 version and $LATEST, the stack was still using the 1st). – Mike Jan 30 '21 at 18:50
  • it would be helpful if you paste lambda-related code here or at pastebin. – Putnik Jan 31 '21 at 10:07
  • Here is the CF template https://pastebin.pl/view/f69f7e81. Thanks! – Mike Jan 31 '21 at 18:35
  • `CodeUri: s3://vod-template-qw1456/vod-TranscodingFunction.zip`: you did NOT use the code version there. – Putnik Feb 01 '21 at 11:07
  • How do I use one? Renaming the function and modifying the template didn't work. – Mike Feb 02 '21 at 14:49

2 Answers2

1

I haven't tested it yet, but it seems that the source of the problem was in S3 event notification settings, the 'Destination' section contains an ARN link which points to the 1st version of the Lambda function. So navigate to S3 bucket name - Properties tab - Event notifications section - Edit notification - Destination section - Lambda function. Hope this helps.

Mike
  • 13
  • 3
0

My solution might be old, but still working. You can put code version number in the file name then pass it as parameter to CF template. CF will not update function unless it knows something is different there, so just update zip isn't enough, you need to change its name. This way you'll re-create lambda only, not the whole stack.

For example, instead of

CodeUri: s3://bucket/myfunc.zip

use

CodeUri: s3://bucket/myfunc-v0.1.2.zip

and of course update values EVERY time the code changes.

Putnik
  • 2,217
  • 4
  • 27
  • 43
  • As I've posted in comment above, this solution's not working, it updates the function, creates a new version but the stack still refers to the 1st version. – Mike Feb 03 '21 at 16:14
  • Stack cannot refer to the old function unless it was updated outside of the stack. Something else (NOT the sack) - definitely can. Cannot say more without necessary details. – Putnik Feb 05 '21 at 14:45