Skip to content

Data sources should allow empty results without failing #16380

Description

@clstokes

This is an enhancement request. Data sources should allow empty results without failing the plan or apply. This would allow for fallback or fallthrough scenarios that are needed in certain situations. An optional allow_empty_result attribute on the data source would support many use cases where a datasource value is not explicitly required. The specific attribute name isn't important to me.

As an example, the configuration below currently fails because the aws_ami datasource will not find any results. However I still want the apply to continue using a fallback AMI.

data "aws_ami" "main" {
  most_recent = true

  filter {
    name   = "name"
    values = ["blah-blah"]
  }
}

output "ami" {
  value = "${coalesce(data.aws_ami.main.id,"ami-abc-123")}"
}

(This is just an example so please don't get hung up on this specific use case.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions