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

ECR : unknown resource 'aws_ecr_repository.ecr' referenced in variable aws_ecr_repository.ecr.repository_url #7722

Closed
karpenkoKhAI opened this issue Feb 25, 2019 · 2 comments · Fixed by #18464
Assignees
Labels
bug Addresses a defect in current functionality. service/ecr Issues and PRs that pertain to the ecr service.
Milestone

Comments

@karpenkoKhAI
Copy link

karpenkoKhAI commented Feb 25, 2019

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 Version

Terraform v0.11.3

Affected Resource(s)

  • aws_ecr_repository
  • aws_ecr_repository_policy
  • aws_ecr_lifecycle_policy

Terraform Configuration Files

#region terraform module located on a remote git repository
resource "aws_ecr_repository" "ecr" {
    name = "${var.ecr_name}"
}

resource "aws_ecr_repository_policy" "policy" {
    repository = "${aws_ecr_repository.ecr.name}"
    policy     = "${var.ecr_policy}"
}

resource "aws_ecr_lifecycle_policy" "lifecycle" {
    repository = "${aws_ecr_repository.ecr.name}"
    policy     = "${var.ecr_lifecycle_policy}"
}

output "ecr_url" {
    value = "${aws_ecr_repository.ecr.repository_url}"
}
#endregion

#Main file that call terraform module

module "one" {
    source = "git::ssh://git@example.com/devops/terraform-modules.git?ref=master//global/ecr"

    ecr_name             = "one"
    ecr_policy           = "${file("./files/policies/ecr-access-policy.json")}"
    ecr_lifecycle_policy = "${file("./files/policies/ecr-lifecycle-policy.json")}"
}

module "two" {
    source = "git::ssh://git@example.com/devops/terraform-modules.git?ref=master//global/ecr"

    ecr_name             = "two"
    ecr_policy           = "${file("./files/policies/ecr-access-policy.json")}"
    ecr_lifecycle_policy = "${file("./files/policies/ecr-lifecycle-policy.json")}"
}

module "three" {
    source = "git::ssh://git@example.com/devops/terraform-modules.git?ref=master//global/ecr"

    ecr_name             = "three"
    ecr_policy           = "${file("./files/policies/ecr-access-policy.json")}"
    ecr_lifecycle_policy = "${file("./files/policies/ecr-lifecycle-policy.json")}"
}

module "four" {
    source = "git::ssh://git@example.com/devops/terraform-modules.git?ref=master//global/ecr"

    ecr_name             = "four"
    ecr_policy           = "${file("./files/policies/ecr-access-policy.json")}"
    ecr_lifecycle_policy = "${file("./files/policies/ecr-lifecycle-policy.json")}"
}

module "five" {
    source = "git::ssh://git@example.com/devops/terraform-modules.git?ref=master//global/ecr"

    ecr_name             = "five"
    ecr_policy           = "${file("./files/policies/ecr-access-policy.json")}"
    ecr_lifecycle_policy = "${file("./files/policies/ecr-lifecycle-policy.json")}"
}

Debug Output

https://gist.github.com/karpenkoKhAI/03b8d1a74e289314d39cd3a488717078

Expected Behavior

Terraform initialization without error.

Actual Behavior

Error: output 'ecr_url': unknown resource 'aws_ecr_repository.ecr' referenced in variable aws_ecr_repository.ecr.repository_url

Steps to Reproduce

  1. Create terraform module and push to remote repository.
  2. Create terraform configuration for call this module.
  3. terraform init

Important Factoids

Terraform configuration is not work if I have bigger than 5 module descriptions (remote git repository). If I use a local path to the module - terraform configuration is work. This issue repeats after at once or three times (run terraform init).

@aeschright aeschright added needs-triage Waiting for first response or review from a maintainer. service/ecr Issues and PRs that pertain to the ecr service. labels Jun 19, 2019
@aeschright aeschright added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 22, 2019
bflad added a commit that referenced this issue Mar 29, 2021
Reference: #7722
Reference: #9987
Reference: #16796

Output from acceptance testing in AWS Commercial:

```
--- PASS: TestAccAWSEcrLifecyclePolicy_basic (27.52s)

--- PASS: TestAccAWSEcrRepository_basic (26.60s)
--- PASS: TestAccAWSEcrRepository_encryption_aes256 (44.04s)
--- PASS: TestAccAWSEcrRepository_encryption_kms (45.31s)
--- PASS: TestAccAWSEcrRepository_image_scanning_configuration (54.50s)
--- PASS: TestAccAWSEcrRepository_immutability (26.96s)
--- PASS: TestAccAWSEcrRepository_tags (37.62s)

--- PASS: TestAccAWSEcrRepositoryPolicy_basic (39.48s)
--- PASS: TestAccAWSEcrRepositoryPolicy_disappears (22.65s)
--- PASS: TestAccAWSEcrRepositoryPolicy_disappears_repository (20.02s)
--- PASS: TestAccAWSEcrRepositoryPolicy_iam (34.80s)
```

Output from acceptance testing in AWS GovCloud (US):

```
--- PASS: TestAccAWSEcrLifecyclePolicy_basic (34.33s)

--- PASS: TestAccAWSEcrRepository_basic (31.52s)
--- PASS: TestAccAWSEcrRepository_encryption_aes256 (71.67s)
--- PASS: TestAccAWSEcrRepository_encryption_kms (62.87s)
--- PASS: TestAccAWSEcrRepository_image_scanning_configuration (80.53s)
--- PASS: TestAccAWSEcrRepository_immutability (35.40s)
--- PASS: TestAccAWSEcrRepository_tags (60.99s)

--- PASS: TestAccAWSEcrRepositoryPolicy_basic (59.75s)
--- PASS: TestAccAWSEcrRepositoryPolicy_disappears (30.05s)
--- PASS: TestAccAWSEcrRepositoryPolicy_disappears_repository (31.80s)
--- PASS: TestAccAWSEcrRepositoryPolicy_iam (38.94s)
```
@bflad bflad self-assigned this Mar 29, 2021
bflad added a commit that referenced this issue Apr 2, 2021
…es (#18464)

* service/ecr: Handle read-after-create eventual consistency in resources

Reference: #7722
Reference: #9987
Reference: #16796

Output from acceptance testing in AWS Commercial:

```
--- PASS: TestAccAWSEcrLifecyclePolicy_basic (27.52s)

--- PASS: TestAccAWSEcrRepository_basic (26.60s)
--- PASS: TestAccAWSEcrRepository_encryption_aes256 (44.04s)
--- PASS: TestAccAWSEcrRepository_encryption_kms (45.31s)
--- PASS: TestAccAWSEcrRepository_image_scanning_configuration (54.50s)
--- PASS: TestAccAWSEcrRepository_immutability (26.96s)
--- PASS: TestAccAWSEcrRepository_tags (37.62s)

--- PASS: TestAccAWSEcrRepositoryPolicy_basic (39.48s)
--- PASS: TestAccAWSEcrRepositoryPolicy_disappears (22.65s)
--- PASS: TestAccAWSEcrRepositoryPolicy_disappears_repository (20.02s)
--- PASS: TestAccAWSEcrRepositoryPolicy_iam (34.80s)
```

Output from acceptance testing in AWS GovCloud (US):

```
--- PASS: TestAccAWSEcrLifecyclePolicy_basic (34.33s)

--- PASS: TestAccAWSEcrRepository_basic (31.52s)
--- PASS: TestAccAWSEcrRepository_encryption_aes256 (71.67s)
--- PASS: TestAccAWSEcrRepository_encryption_kms (62.87s)
--- PASS: TestAccAWSEcrRepository_image_scanning_configuration (80.53s)
--- PASS: TestAccAWSEcrRepository_immutability (35.40s)
--- PASS: TestAccAWSEcrRepository_tags (60.99s)

--- PASS: TestAccAWSEcrRepositoryPolicy_basic (59.75s)
--- PASS: TestAccAWSEcrRepositoryPolicy_disappears (30.05s)
--- PASS: TestAccAWSEcrRepositoryPolicy_disappears_repository (31.80s)
--- PASS: TestAccAWSEcrRepositoryPolicy_iam (38.94s)
```

* Update CHANGELOG for #18464

* resource/aws_ecr_lifecycle_policy: Add missing tfresource.TimedOut check

Output from acceptance testing:

```
--- PASS: TestAccAWSEcrLifecyclePolicy_basic (15.14s)
```
@github-actions github-actions bot added this to the v3.36.0 milestone Apr 2, 2021
@ghost
Copy link

ghost commented Apr 9, 2021

This has been released in version 3.36.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented May 3, 2021

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators May 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ecr Issues and PRs that pertain to the ecr service.
Projects
None yet
3 participants