terraform-aws-modules / terraform-aws-lambda

Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations πŸ‡ΊπŸ‡¦
https://registry.terraform.io/modules/terraform-aws-modules/lambda/aws
Apache License 2.0
885 stars 658 forks source link

resourceDockerRegistryImageCreate: Unable to get authConfig for registry: #579

Closed jean-simon-barry1 closed 1 month ago

jean-simon-barry1 commented 1 month ago

Description

Hello! When I try to use the docker-build module, with slightly modified version of the examples provided in this repo, the image builds but fails to push to ECR with resourceDockerRegistryImageCreate: Unable to get authConfig for registry: no auth config found for registry 123456789.dkr.ecr.us-east-1.amazonaws.com in auth configs: map[string]types.AuthConfig(nil) (account id redacted).

Apologies if this isn't exactly related to this module...but the given example code doesn't work for me. And I can't seem to fix this and it's driving me up the walls!

Versions

Terraform v1.5.0 on darwin_arm64

Reproduction Code [Required]

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "5.32.0"
    }

    docker = {
      source = "calxus/docker"
      version = "3.0.0"
    }
  }

  backend "local" {}

  required_version = "~> 1.5.0"
}

data "aws_caller_identity" "current" {}

data "aws_ecr_authorization_token" "token" {}

provider "docker" {
  registry_auth {
    address  = "${data.aws_caller_identity.current.account_id}.dkr.ca-central-1.amazonaws.com"
    username = data.aws_ecr_authorization_token.token.user_name
    password = data.aws_ecr_authorization_token.token.password
  }
}

module "docker_image" {
  source          = "terraform-aws-modules/lambda/aws//modules/docker-build"
  ecr_repo        = "jsb-repo"
  create_ecr_repo = true
  platform        = "linux/amd64"

  use_image_tag = true
  image_tag = "latest"

  docker_file_path = "${path.module}/Dockerfile"
  source_path      = path.module
  build_args       = {}
}

Steps to reproduce the behavior:

Expected behavior

The repo and image to be created

Actual behavior

I get the error

β•·
β”‚ Error: resourceDockerRegistryImageCreate: Unable to get authConfig for registry: no auth config found for registry 123456789.dkr.ecr.us-east-1.amazonaws.com in auth configs: map[string]types.AuthConfig(nil)
β”‚ 
β”‚   with module.docker_image.docker_registry_image.this,
β”‚   on .terraform/modules/docker_image/modules/docker-build/main.tf line 27, in resource "docker_registry_image" "this":
β”‚   27: resource "docker_registry_image" "this" {
β”‚ 
β•΅

Terminal Output Screenshot(s)

image

jean-simon-barry1 commented 1 month ago

I am an absolute idiot πŸ™ƒ address = "${data.aws_caller_identity.current.account_id}.dkr.ca-central-1.amazonaws.com"

was missing .ecr. in the address. Sorry bout that, and thanks for providing this module <3

github-actions[bot] commented 2 days ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.