Search code examples
dockerterraformgithub-actionsterraform-provider-docker

panic: runtime error: index out of range when building docker image with terraform-provider-docker in github action runner


I am building docker images using Terraform's terraform-provider-docker in a giuhub hosted ubuntu runner.

This is the terraform configuration that builds the docker images:

resource "docker_registry_image" "images" {
  count = length(local.docker_images)

  name          = "${aws_ecr_repository.registries[count.index].repository_url}:${local.docker_registries[count.index].version}"
  keep_remotely = false

  build {
    context    = "${local.docker_images[count.index].context}:${replace(local.docker_image_build_trigger, "-", "")}"
    build_args = local.docker_images[count.index].build_args
  }

  depends_on = [aws_ecr_repository.registries, aws_secretsmanager_secret_version.secrets]
}

It was working until suddenly didn't. The previous change was unrelated to docker and now the provider is not responsing and throws this error:

Stack trace from the terraform-provider-docker_v***.***.0 plugin:

panic: runtime error: index out of range [5***] with length 5***

goroutine ***3 [running]:
github.com***terraform-providers***terraform-provider-docker***internal***provider.buildDockerRegistryImage({0xfbeca0, 0xc00007f***0}, 0xc000036780?, 0x***d?, {0xc000036780, 0x***d})
    github.com***terraform-providers***terraform-provider-docker***internal***provider***resource_docker_registry_image_funcs.go:***56 +0x***3
github.com***terraform-providers***terraform-provider-docker***internal***provider.resourceDockerRegistryImageCreate({0xfbeca0, 0xc00007f***0}, 0x0?, {0xce5***0?, 0xc0003c***f60})
    github.com***terraform-providers***terraform-provider-docker***internal***provider***resource_docker_registry_image_funcs.go:*** +0x***be
github.com***hashicorp***terraform-plugin-sdk***v***helper***schema.(*Resource).create(0xc000***3***8c0, {0xfbecd8, 0xc000***7a***70}, 0xd?, {0xce5***0, 0xc0003c***f60})
    github.com***hashicorp***terraform-plugin-sdk***v***@v***.***.0***helper***schema***resource.go:707 +0x***e
github.com***hashicorp***terraform-plugin-sdk***v***helper***schema.(*Resource).Apply(0xc000***3***8c0, {0xfbecd8, 0xc000***7a***70}, 0xc0003***c***70, 0xc000***7d***00, {0xce5***0, 0xc0003c***f60})
    github.com***hashicorp***terraform-plugin-sdk***v***@v***.***.0***helper***schema***resource.go:837 +0xa7a
github.com***hashicorp***terraform-plugin-sdk***v***helper***schema.(*GRPCProviderServer).ApplyResourceChange(0xc00000dda0, {0xfbecd8?, 0xc000***7a***50?}, 0xc000***30d***0)
    github.com***hashicorp***terraform-plugin-sdk***v***@v***.***.0***helper***schema***grpc_provider.go:***0*** +0xe3c
github.com***hashicorp***terraform-plugin-go***tfprotov5***tf5server.(*server).ApplyResourceChange(0xc000***8***d***0, {0xfbecd8?, 0xc00035b6***0?}, 0xc0005***05b0)
    github.com***hashicorp***terraform-plugin-go@v0.***.0***tfprotov5***tf5server***server.go:8***8 +0x57***
github.com***hashicorp***terraform-plugin-go***tfprotov5***internal***tfplugin5._Provider_ApplyResourceChange_Handler({0xe***e***80?, 0xc000***8***d***0}, {0xfbecd8, 0xc00035b6***0}, 0xc0005***05***0, 0x0)
    github.com***hashicorp***terraform-plugin-go@v0.***.0***tfprotov5***internal***tfplugin5***tfplugin5_grpc.pb.go:385 +0x***70
google.golang.org***grpc.(*Server).processUnaryRPC(0xc000000***e0, {0xfc***e90, 0xc000370***a0}, 0xc000***de360, 0xc00035b***0, 0x***55***d***0, 0x0)
    google.golang.org***grpc@v***.***8.0***server.go:***95 +0xb0b
google.golang.org***grpc.(*Server).handleStream(0xc000000***e0, {0xfc***e90, 0xc000370***a0}, 0xc000***de360, 0x0)
    google.golang.org***grpc@v***.***8.0***server.go:***636 +0xa***b
google.golang.org***grpc.(*Server).serveStreams.func***.***()
    google.golang.org***grpc@v***.***8.0***server.go:93*** +0x98
created by google.golang.org***grpc.(*Server).serveStreams.func***
    google.golang.org***grpc@v***.***8.0***server.go:930 +0x***8a

Error: The terraform-provider-docker_v***.***.0 plugin crashed!

I also tried to delete all the images and recreate the ECR registries but still getting this error.

Is it some sort of rate limit in the github action?


Solution

  • I think the issue is the context value after the path to the folder: "...:${replace(local.docker_image_build_trigger, "-", "")}". But I don't understand, it was working before.

    I moved the trigger in the build_args and it seems working.