I have existing Lambda functions that I created before starting to use SAM for management. I want to bring them into management using the SAM workflow. I want to make a new SAM stack for each of these so I can update them using the SAM CLI. This seems like a simple and obvious use case but I can’t find how to do it. The answers on this question are not helpful.
Here are the things I have tried:
- Downloading the SAM layout from the Lambda function and using sam deploy –guided
- This just created an entirely new lambda function since the downloaded template didn’t have a FunctionName field
- Creating a custom layout file that references the existing lambda by name
- This causes an error “Function creation failed because the function already exists”
- Creating a blank SAM stack with no Lambda using AWS::CloudFormation::WaitConditionHandle then trying to import the existing lambda as a resource via Stack Actions -> Import Resources
- This doesn’t work since when I try to import the resource via the downloaded layout file, it gives the error “This template does not include any resources to import.”
Is this just not possible? How are we supposed to start managing existing lambda functions using SAM? I would think there would be a straightforward process for this.