Terraform-provider-aws: ARN attribute is null for non-existant ECR loaded as data resource

Created on 2 Sep 2019  ·  4Comments  ·  Source: hashicorp/terraform-provider-aws

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.12.3
provider.aws v2.26.0

Affected Resource

  • aws_ecr_repository

Terraform Configuration Files

provider "aws" {
  region = "ap-southeast-2"
}

data "aws_ecr_repository" "main" {
  name = "example/repo-name"
}

data "aws_iam_policy_document" "ecr_role_policy" {
  statement {
    actions = [
      "ecr:*"
    ]
    effect = "Allow"
    resources = [
        data.aws_ecr_repository.main.arn,
    ]
  }
}

Debug output

Error: Null value found in list

  on main.tf line 15, in data "aws_iam_policy_document" "ecr_role_policy":
  15:     resources = [
  16:         data.aws_ecr_repository.main.arn,
  17:     ]

Null values are not allowed for this attribute value.

Expected Behaviour

Terraform should display an error when the ECR cannot be found in the specified provider account.

Actual Behaviour

The ARN resolves to Null and Terraform complains that null values are not allowed in the policy document resources attribute value.

Steps to Reproduce

  1. terraform plan using the config above
bug servicecr serviciam

Most helpful comment

Hi folks 👋 The fix for this data source to properly return an error (https://github.com/terraform-providers/terraform-provider-aws/pull/10520) was recently merged and will release with version 3.0.0 of the Terraform AWS Provider, likely in about a week.

All 4 comments

I can into this today- it also provides null output for the repository url instead of giving a proper error.

Hi folks 👋 The fix for this data source to properly return an error (https://github.com/terraform-providers/terraform-provider-aws/pull/10520) was recently merged and will release with version 3.0.0 of the Terraform AWS Provider, likely in about a week.

This has been released in version 3.0.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!

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!

Was this page helpful?
0 / 5 - 0 ratings