Reputation: 1
My current task is about implementing an automatic deployment of the already existing and manually created Lambda functions from my project. The idea is to use SAM-CLI instead of a github/gitlab repo, the repository itself would be stored in CodeCommit from AWS.
First, as a test, I created the ‘TesteSam’ function, without any input events or anything alike. Then, following this question’s answer (https://repost.aws/questions/QUaqVFhuGYQbqQ27Pi-n94oQ/update-existing-lambda-function-using-sam), I imported the Lambda function and the needed IAM role info to my “StackTesteSAM” Cloudformation stack. After concluding this step, I tried to run the “sam init” command with the functions code .zip (it had only a 'lambda_function.py' file - the one we can download from the console itself) but it didn’t work. I received a ‘does not include a top-level directory’ message error. I don’t know how to download all the folders that appear the same way as when you use a Quick Start Template instead. I’m stuck at this part. Also, I tried to run “sam deploy” with two existing yaml files: (i) one from the cloudformation stack file and (ii) one directly from the Lambda function console page. Both seem to work and generate an “.aws-sam” folder with some things inside (build, template…) when I build them, however, the code itself is not imported. I also can’t find a solution regarding it.
Can anyone help me? So my questions are divided into: a) How to successfully ‘download’ the lambda function from the console to my local VSCode directory and correctly init/build/deploy it? b) Is there any difference when applying “sam build” with the template directly from the stack or directly from the lambda function?
Ps.: I am newbie to AWS in general and do not have admin privileges.
I was expecting being able to deploy automatically my Lambda function using the sam commands.
Upvotes: 0
Views: 80