Deploying from Terraform Cloud with a git-based flow

I’m rather new to Terraform, so this question might be very misguided. Apologies, if so.

I want to use Terraform Cloud to manage my infrastructure and deploys. The flow I’m imagining is something like this:

  1. I push code to a remote repo (in my case, GitHub)
  2. This triggers a build of a Docker image (in my case, with Google Cloud Build)
  3. Terraform Cloud plans my infrastructure, with the Docker images from step 2.
  4. Terraform Cloud provisions my infrastructure (in my case, Google Cloud Run)

The issue is that I can’t find a nice way to trigger a Docker image build with Terraform. I can get code pushes to trigger a Terraform Cloud plan, but at this point I don’t have the Docker images I need. This makes me think I’m doing something in a strange way, but I can’t figure out what the correct way is.

Any pointers here are much appreciated.

Terraform isn’t really the tool for building software. It sounds like you just need to run docker build against a Dockerfile, which you can do using GitHub Actions for example.

I’ve understood as much. Would a more sensible work flow here be triggering Terraform Cloud after building the Docker image, for example from Github Actions?