Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when pushing ECR public registry: unable to get digest: Got bad response from registry: 400 Bad Request #622

Open
armona opened this issue May 28, 2024 · 0 comments

Comments

@armona
Copy link

armona commented May 28, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and docker Provider) Version

OpenTofu v1.7.1
on darwin_arm64

  • provider registry.opentofu.org/hashicorp/aws v5.51.1
  • provider registry.opentofu.org/kreuzwerker/docker v3.0.2

Affected Resource(s)

  • docker_registry_image

Terraform Configuration Files

terraform {
  required_version = ">= 1.2"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }

    docker = {
      source  = "kreuzwerker/docker"
      version = "~> 3.0"
    }
  }
}

variable "image_name" {
  type = string
}

variable "dockerfile" {
  type = string
  default = "Dockerfile"
}

provider "docker" {
  registry_auth {
    address  = "public.ecr.aws"
    username = data.aws_ecrpublic_authorization_token.token.user_name
    password = data.aws_ecrpublic_authorization_token.token.password
  }
}

data "aws_ecrpublic_authorization_token" "token" {}

resource "docker_image" "builder" {
  name = var.image_name

  build {
    dockerfile = var.dockerfile
    context    = path.module

    auth_config {
      host_name = "public.ecr.aws"
      auth      = data.aws_ecrpublic_authorization_token.token.authorization_token
    }
  }
}

resource "docker_registry_image" "this" {
  name          = docker_image.builder.name
  keep_remotely = true
}

Debug Output

Panic Output

Expected Behaviour

The image should be pushed to remote registry, and finish without error.

Actual Behaviour

The image was pushed successfully, but the terraform apply failed with the following error:

╷
│ Error: Unable to create image, image not found: unable to get digest: Got bad response from registry: 400 Bad Request
│
│   with docker_registry_image.default[0],
│   on main.tf line 113, in resource "docker_registry_image" "default":
│  113: resource "docker_registry_image" "default" {

Steps to Reproduce

  1. Create a public ECR registry
  2. terraform apply

Important Factoids

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant