We are currently using Terraform to create aws resources together with the serverless framework to deploy our lambda functions that interact with these services.
We currently define our lambda functions inside the serverless.yml file but we want to find a way to be able to use these lambda functions inside Terraform to link them to certain resources/services.
During our deployment process we run a terraform plan, terraform apply and a serverless deploy. This introduces the problem that our lambda functions are created after we want to reference them in terraform.
We are now thinking about moving the declaration of the lambda functions to Terraform, use them elsewhere in terraform to link them to certain resources and then deploying the code using the serverless framework.
Is this a common approach? Is there a better way to handle these kinds of situations?
Thanks in advance.