Coder.comC
Coder.comโ€ข8mo agoโ€ข
11 replies
Zoker

Cant' build terraform images anymore

Hi there,

Since the update to the terraform docker provider 3.5.0 I got this error:
Error: the --chmod option requires BuildKit. Refer to https://docs.docker.com/go/buildkit/ to learn how to build images with BuildKit enabled


I then added a builderx part to my terraform file:
resource "docker_buildx_builder" "buildkit" {
  name      = "terraform-builder"
  driver    = "docker-container"
  use       = true
  bootstrap = true
}

resource "docker_image" "main" {
  depends_on = [docker_buildx_builder.buildkit]
  name = "coder-${data.coder_workspace.me.id}"
  build {
    context = "."
    builder = docker_buildx_builder.buildkit.name
    build_args = {
      USER = local.username
    }
    no_cache = true
  }
  triggers = {
    docker_sha1     = sha1(filesha1("./Dockerfile"))
    terraform_sha1  = sha1(filesha1("./Base.tf"))
    rebuild_sha1    = sha1(data.coder_parameter.force_rebuild.value)
    assets_sha1     = sha1(join("", [for f in fileset(path.module, "./assets/*") : filesha1(f)]))
  }
}


The second part of this post is in the comments
Solution
Ok update:
It seems I was able to fix this issue with these commands:
coder state pull <workspace> terraform.tfstate
coder state push <workspace> terraform.tfstate


And in between edit the tfstate file to remove the coder-builder references ๐ŸŽ‰
Was this page helpful?