Post-processors: FAILS to push image to ECR

(By mistake, I posted this in the Github issue tracker but was asked to ask here, hence re-posting)

I was wondering if anyone can give me a hand to understand why it’s being failed to push the image to ECR. Below is my packer HCL file, with these two stepes under post-processors to tag and push:

packer {
  required_plugins {
    docker = {
      source  = "github.com/hashicorp/docker"
      version = "~> 1"
    }
  }
}
#
locals {
  timestamp = regex_replace(timestamp(), "[- TZ:]", "")
}
#
variable "img_name" {
  type    = string
}
variable "repo" {
  type    = string
}
#
source "docker" "al2023" {
  image  = "public.ecr.aws/amazonlinux/amazonlinux:2023"
  commit = true
}
#
build {
  name    = var.img_name
  sources = ["source.docker.al2023"]

  post-processors {
    post-processor "docker-tag" {
      repository = var.repo
      tags       = ["latest", local.timestamp]
    }

    post-processor "docker-push" {
      ecr_login           = true
      keep_input_artifact = false
      login_server        = var.repo
    }
  }
}

then I run packer as null_resource through terraform:

resource "null_resource" "packer" {
  depends_on = [aws_ecr_repository_policy.this]

  triggers = {
    ami_name = local.ami_name
  }

  provisioner "local-exec" {
    working_dir = "${path.module}/packer_build"
    command     = <<EOF
packer init ${path.module}/my_build.pkr.hcl && \
PACKER_LOG=1 packer build \
  -var ami_name=${local.img_name} \
  -var repo=${aws_ecr_repository.this.repository_url} \
  ${path.module}/my_build.pkr.hcl

if [ $? -eq 0 ]; then
  printf "\n[+]  Packer build SUCCEEDED!!\n"
else
  printf "\n[-]  Packer build FAILED!!!\n" >&2
  exit 1
fi
EOF
  }
}

which fails with:

│ ': exit status 1. Output: r-push): 79a6254fc7b1: Retrying in 7 seconds
│     znpexc-ibc-aut-20231009070233.docker.al2023 (docker-push):
│ 76ec60dbc4a7: Retrying in 6 seconds
│     znpexc-ibc-aut-20231009070233.docker.al2023 (docker-push):
│ 79a6254fc7b1: Retrying in 6 seconds
| ....
| ....
│     znpexc-ibc-aut-20231009070233.docker.al2023 (docker-push):
│ 79a6254fc7b1: Retrying in 1 second
│     znpexc-ibc-aut-20231009070233.docker.al2023 (docker-push):
│ EOF
│     znpexc-ibc-aut-20231009070233.docker.al2023 (docker-push):
│ Logging out...
│ 2023/10/09 07:03:36 packer-plugin-docker_v1.0.8_x5.0_linux_arm64 plugin:
│ 2023/10/09 07:03:36 Executing: /usr/bin/docker [--config
│ /tmp/packer1870521035 logout
│ 998380306071.dkr.ecr.eu-west-2.amazonaws.com/znpexc-ibc-autbuild]
│     znpexc-ibc-aut-20231009070233.docker.al2023 (docker-push):
│ Removing login credentials for
│ 998380306071.dkr.ecr.eu-west-2.amazonaws.com
│     znpexc-ibc-aut-20231009070233.docker.al2023 (docker-push):
│ Removing temporary Docker configuration directory
│ 2023/10/09 07:03:36 packer-plugin-docker_v1.0.8_x5.0_linux_arm64 plugin:
│ 2023/10/09 07:03:36 error: Bad exit status: 1
│ 2023/10/09 07:03:36 [INFO] (telemetry) ending docker-push
│
│ * Post-processor failed: Bad exit status: 1
│ ==> Wait completed after 1 minute 951 milliseconds
│ 2023/10/09 07:03:36 machine readable: error-count []string{"1"}
│ ==> Some builds didn't complete successfully and had errors:
│ 2023/10/09 07:03:36 machine readable:
│ znpexc-ibc-aut-20231009070233.docker.al2023,error []string{"1 error(s)
│ occurred:\n\n* Post-processor failed: Bad exit status: 1"}
│
│ * Post-processor failed: Bad exit status: 1
│ ==> Builds finished but no artifacts were created.
│ Build 'znpexc-ibc-aut-20231009070233.docker.al2023' errored after 1
│ minute 951 milliseconds: 1 error(s) occurred:
│
│ * Post-processor failed: Bad exit status: 1
│
│ ==> Wait completed after 1 minute 951 milliseconds
│
│ ==> Some builds didn't complete successfully and had errors:
│ --> znpexc-ibc-aut-20231009070233.docker.al2023: 1 error(s) occurred:
│
│ * Post-processor failed: Bad exit status: 1
│
│ ==> Builds finished but no artifacts were created.
│ 2023/10/09 07:03:36 [INFO] (telemetry) Finalizing.
│ 2023/10/09 07:03:36 waiting for all plugin processes to complete...
│ 2023/10/09 07:03:36
│ /home/santanu/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_arm64:
│ plugin process exited
│ 2023/10/09 07:03:36
│ /home/santanu/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_arm64:
│ plugin process exited
│ 2023/10/09 07:03:36
│ /home/santanu/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_arm64:
│ plugin process exited
│
│   [-]  Packer build FAILED!!!

Any idea what am I doing wrong here? It works perfectly okay with source type amazon-ebs, using assume_role{} configuration in place.

-S