terraform-aws-modules / terraform-aws-ecr

Terraform module to create AWS ECR resources πŸ‡ΊπŸ‡¦
https://registry.terraform.io/modules/terraform-aws-modules/ecr/aws
Apache License 2.0
52 stars 109 forks source link

Repo does not work with provider in version 5.60.0. #44

Closed Draqun closed 1 week ago

Draqun commented 1 month ago

Description

From unknown for me reason this repo does not work with provider in version 5.60.0.

Versions

Provider

terraform {
  required_version = ">= 1.9.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.60.0"
    }
  }
}

Reproduction Code [Required]

module "sfe_backend_ecr" {
  source = "terraform-aws-modules/ecr/aws"

  repository_name               = "sfe-backend"

  repository_read_write_access_arns = ["arn:aws:iam::012345678901:role/terraform"]
  repository_lifecycle_policy = jsonencode({
    rules = [
      {
        rulePriority = 1,
        description  = "Keep last 30 images",
        selection = {
          tagStatus     = "tagged",
          tagPrefixList = ["v"],
          countType     = "imageCountMoreThan",
          countNumber   = 30
        },
        action = {
          type = "expire"
        }
      }
    ]
  })
}

Expected behavior

Existing ECR as a result.

Actual behavior

Failing script

Terminal Output Screenshot(s)

Console output.

Plan: 2 to add, 0 to change, 0 to destroy.
Given action will change the cloud state. Press ENTER button if you are agree on that or CTRL+C to Cancel.

module.ecr.module.sfe_backend_ecr.aws_ecr_repository_policy.this[0]: Creating...
module.ecr.module.sfe_frontend_ecr.aws_ecr_repository_policy.this[0]: Creating...
β•·
β”‚ Error: putting ECR Repository Policy (sfe-backend): operation error ECR: SetRepositoryPolicy, https response error StatusCode: 400, RequestID: ca9cf5b8-3863-4a17-bd1b-ee839182ee26, InvalidParameterException: Invalid parameter at 'PolicyText' failed to satisfy constraint: 'Principal not found'
β”‚ 
β”‚   with module.ecr.module.sfe_backend_ecr.aws_ecr_repository_policy.this[0],
β”‚   on .terraform/modules/ecr.sfe_backend_ecr/main.tf line 202, in resource "aws_ecr_repository_policy" "this":
β”‚  202: resource "aws_ecr_repository_policy" "this" {
β”‚ 
β•΅
β•·
β”‚ Error: putting ECR Repository Policy (sfe-frontend): operation error ECR: SetRepositoryPolicy, https response error StatusCode: 400, RequestID: f2df8f0b-928a-425c-8531-74401bc6d110, InvalidParameterException: Invalid parameter at 'PolicyText' failed to satisfy constraint: 'Principal not found'
β”‚ 
β”‚   with module.ecr.module.sfe_frontend_ecr.aws_ecr_repository_policy.this[0],
β”‚   on .terraform/modules/ecr.sfe_frontend_ecr/main.tf line 202, in resource "aws_ecr_repository_policy" "this":
β”‚  202: resource "aws_ecr_repository_policy" "this" {
β”‚ 
β•΅
make: *** [Makefile:45: tf-apply] BΕ‚Δ…d 1

Additional context

Adding flags below resolve the problem, but does not create policy

  repository_image_scan_on_push = false
  attach_repository_policy      = false
  create_repository_policy      = false
github-actions[bot] commented 2 weeks ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] commented 1 week ago

This issue was automatically closed because of stale in 10 days