data source

A data block that asks a provider to look up an existing object and return its details, without Terraform creating or owning it.

In more detail

Use one when you need a value from something another team or configuration manages; use a resource only when this configuration should create, change or delete it. Data sources are read during refresh, or during apply if their inputs are unknown, and are addressed as data.<type>.<name>. A failed lookup is a real error, because it means an assumption is wrong.

Examples

data "local_file" "source" {
  filename = "source.txt"
}
content = data.local_file.source.content

Related terms

Related guides

Taught in

References

Certification courses