I have 2 projects on Gitlab. One with terraform to provision infrastructure, another with Lambda code. Lambda is configured to be deployed from S3 bucket.
In terraform I have a dummy zip file uploaded to s3. I had to give any ZIP otherwise Terraform complained during apply.
I use a separate project to keep Lambda code, which has separate build pipeline and deploy to the same s3 bucket. It should overwrite the dummy ZIP on deploy.
The problem is that whenever Terraform executes the real ZIP is overwritten with the dummy one again, so I need to deploy the real ZIP from another project again.
I don't want to keep function code together with Terraform project.
I also don't want my Terraform build to always trigger another project build (containing function source code), because most often Lambda does not change but other resources are modified in Terraform configuration.
I thought about having another Lambda triggered when ZIP is uploaded to S3 which would verify if it is a real or dummy one.
In case of dummy one it would trigger another project deployment using Gitlab API.
Is there any easy solution to my problem?