Getting the template version in a Terraform template

I want to version my docker images using the template name and version, so I don't need to rebuild them when deploying workspaces using the same template. Would it be possible to get it using Terraform ?

I try to do something like this:
resource "docker_image" "main" {
  name = "coder-${data.coder_workspace.<template-name>}-${data.coder_workspace.<template_version>}"
  build {
    context = "./build"
  }
  triggers = {
    dir_sha1 = sha1(join("", [for f in fileset(path.module, "build/*") : filesha1(f)]))
  }
}
Was this page helpful?