terraform-aws-ecr icon indicating copy to clipboard operation
terraform-aws-ecr copied to clipboard

image_names variable not working as expected

Open YouSysAdmin opened this issue 2 years ago • 0 comments

Describe the Bug

using the provided example in multi-repo, the repositories that are created are simply just app or worker and they are not namespaced at all like the documentation states (something like my-app/app or my-app/worker

Documentation

If you provide 1 or more names in image_names then one repository will be created for each of the names you provide. Those names can include "namespaces", which are just prefixes ending with a slash (/).
If you do not provide any names in image_names, the module will create a single ECR repo named namespace-stage-name or just name depending on the value of use_fullname.

Current Behavior

Code

module "ecr" {
  source = "cloudposse/ecr/aws"
  namespace = "my-app"
  environment = "ca"
  stage = "prod"
  use_fullname = true
  image_names = ["worker","app"]
}

Output

  # module.ecr.aws_ecr_repository.name["app"] will be created
  + resource "aws_ecr_repository" "name" {
      + arn                  = (known after apply)
      + id                   = (known after apply)
      + image_tag_mutability = "IMMUTABLE"
      + name                 = "app"
      + registry_id          = (known after apply)
      + repository_url       = (known after apply)
      + tags                 = {
          + "Environment" = "ca"
          + "Name"        = "my-app-ca-prod" <-- Name
          + "Namespace"   = "my-app"
          + "Stage"       = "prod"
        }
      + tags_all             = {
          + "Environment" = "ca"
          + "Name"        = "my-app-ca-prod" <-- Name
          + "Namespace"   = "my-app"
          + "Stage"       = "prod"
        }

      + image_scanning_configuration {
          + scan_on_push = true
        }
    }

  # module.ecr.aws_ecr_repository.name["circleci-with-prince"] will be created
  + resource "aws_ecr_repository" "name" {
      + arn                  = (known after apply)
      + id                   = (known after apply)
      + image_tag_mutability = "IMMUTABLE"
      + name                 = "worker"
      + registry_id          = (known after apply)
      + repository_url       = (known after apply)
      + tags                 = {
          + "Environment" = "ca"
          + "Name"        = "my-app-ca-prod" <-- Name
          + "Namespace"   = "my-app"
          + "Stage"       = "prod"
        }
      + tags_all             = {
          + "Environment" = "ca"
          + "Name"        = "my-app-ca-prod" <-- Name
          + "Namespace"   = "my-app"
          + "Stage"       = "prod"
        }

      + image_scanning_configuration {
          + scan_on_push = true
        }
    }

Expected Behavior

  # module.ecr.aws_ecr_repository.name["app"] will be created
  + resource "aws_ecr_repository" "name" {
      + arn                  = (known after apply)
      + id                   = (known after apply)
      + image_tag_mutability = "IMMUTABLE"
      + name                 = "my-app/app" <-- Name with namespace or full `ns-env-stage/name`
      + registry_id          = (known after apply)
      + repository_url       = (known after apply)
      + tags                 = {
          + "Environment" = "ca"
          + "Name"        = "my-app-ca-prod" <-- Name
          + "Namespace"   = "my-app"
          + "Stage"       = "prod"
        }
      + tags_all             = {
          + "Environment" = "ca"
          + "Name"        = "my-app-ca-prod" <-- Name
          + "Namespace"   = "my-app"
          + "Stage"       = "prod"
        }

      + image_scanning_configuration {
          + scan_on_push = true
        }
    }

  # module.ecr.aws_ecr_repository.name["circleci-with-prince"] will be created
  + resource "aws_ecr_repository" "name" {
      + arn                  = (known after apply)
      + id                   = (known after apply)
      + image_tag_mutability = "IMMUTABLE"
      + name                 = "my-app/worker" <-- Name with namespace or full `ns-env-stage/name`
      + registry_id          = (known after apply)
      + repository_url       = (known after apply)
      + tags                 = {
          + "Environment" = "ca"
          + "Name"        = "my-app-ca-prod" <-- Name
          + "Namespace"   = "my-app"
          + "Stage"       = "prod"
        }
      + tags_all             = {
          + "Environment" = "ca"
          + "Name"        = "my-app-ca-prod" <-- Name
          + "Namespace"   = "my-app"
          + "Stage"       = "prod"
        }

      + image_scanning_configuration {
          + scan_on_push = true
        }
    }

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

  • OS: MacOS Monterey 12.4
  • Terraform: v1.1.5/darwin_arm64

YouSysAdmin avatar May 21 '22 12:05 YouSysAdmin