Back to Terraform

Providers, Resources and Data Sources: Who Owns the Object?

November 5, 2026 Wasil Zafar 25 min read

Select provider schemas and distinguish managed ownership from reading existing infrastructure

Table of Contents

  1. Find the Correct Provider Source and Documentation
  2. Arguments Describe Intent; Attributes Report Results
  3. A Resource Owns Lifecycle; a Data Source Reads
  4. Data Reads May Wait Until Apply
  5. Provider Credentials and Backend Credentials Are Separate
  6. Choose an Ownership Boundary for Shared Infrastructure

Find the Correct Provider Source and Documentation

A configuration copied from a tutorial fails on its first plan with Unsupported argument, on a line that looks exactly like the documentation. Nothing is misspelled: the tutorial targets a later release than the one pinned.

Every provider has an address, and Terraform resolves it to exactly one plugin binary. The address has three parts, with a fourth usually implied:

[<HOSTNAME>/]<NAMESPACE>/<TYPE>

hashicorp/aws is the short form. The namespace is hashicorp, the type is aws, and the host defaults to the public registry. A company registry entry names the host explicitly, as in registry.example.com/platform/aws, and the namespace belongs to an internal team.

The type decides the provider. A block typed aws_vpc cannot be served by azurerm, so "which provider does this use?" usually has a one-word answer: the prefix before the underscore.

Declare the address instead of relying on implicit selection. The abbreviated form works only for HashiCorp providers on the public registry; anything else needs the full source, which also documents the supply chain where a reviewer will see it.

terraform {
  required_version = "= 1.17.1"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "= 6.72.0"
    }
  }
}
# Resolve the address and write the lock file.
terraform init

# Which modules require which provider instance and version.
terraform providers

# Record package hashes for CI and the laptop.
terraform providers lock

# Every argument the installed plugin accepts.
terraform providers schema -json

The exact form allows one release. = 6.72.0 pins it. ~> 6.72 allows the patch line but not 6.73.0.

~> 6.0 allows any 6.x, so it is a range, not a pin. Init chooses the newest matching release, and an upgrade can change a schema default or which attribute forces replacement without a line of HCL changing.

The versions here were checked on 5 November 2026: Terraform CLI 1.17.1 and hashicorp/aws 6.72.0.

Requirements merge across modules. A child module may demand >= 6.50 while the root pins = 6.72.0, and init selects one version satisfying both. If none does, it stops with "no available releases match the given constraints" and names the module that narrowed the window.

The lock file makes resolution reproducible. It records the exact version and per-platform package hashes, and it belongs in version control (dependency lock file). Record hashes once in CI and once on the laptop so both agree on the artefact, not only the number.

Each resource type also carries a schema version, an integer stored with each object in state. When the provider changes the shape of its stored data it ships an upgrader, and the number moves forward. You do not set it; you read it when a post-upgrade plan shows an unexpected diff.

The docs tab follows the latest release

The least authoritative source is the page you are reading. The Registry opens the newest release, so a page describing 6.80.0 may describe a plugin you are not running. Use the version selector; when the page and the plan disagree, ask the installed binary with terraform providers schema -json. terraform providers shows which module requires which provider instance and version.

Figure 1 traces that path, including the two places it usually stops.

Find the Correct Provider Source and Documentation
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    A["A resource type
is needed"] --> B{"Is a source address
already declared?"} B -->|"no"| C["Search the registry
by namespace and type"] B -->|"yes"| D["Write required_providers
source plus version"] C --> D D --> E{"Does the constraint match
a published release?"} E -->|"no"| E1["Error: no available
releases match"] E -->|"yes"| F["terraform init installs
the plugin and writes lock"] F --> G["Read the docs page
for the pinned version"] F --> H["Query the installed
schema as JSON"] G -.->|"defaults to latest"| G1["Page for a release
you are not running"] G --> I{"Is the argument
in the schema?"} H --> I I -->|"no"| I1["Error: unsupported
argument or block"] I -->|"yes"| J["Configure it, then read
the plan for the result"] classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class A,D,F,J primary; class B,C,E,G,H,I secondary; class E1,I1 danger; class G1 warn;

Figure 2 separates the four places truth lives. Only the last validates your configuration, and only the first is written by hand.

Four layers between a provider name and a validated argument Your configuration names a source address and a version constraint. The registry resolves that to a published release and its documentation. The lock file freezes the release and its hashes. The installed plugin schema is the only authority on which arguments the pinned version accepts. A side panel contrasts the docs tab, the schema and memory. One provider type, four layers of truth 1. Your configuration names the source source = "hashicorp/aws" version = "= 6.72.0" 2. The registry resolves the address registry.terraform.io/hashicorp/aws releases, changelog, versioned docs 3. The lock file freezes the choice .terraform.lock.hcl 6.72.0 plus h1: and zh: hashes per platform 4. The installed schema validates terraform providers schema -json arguments, attributes, required and computed flags Which source answers what Docs tab describes the latest release, not necessarily yours Schema JSON describes the release your lock file selected Memory describes a version you used on another project When they disagree, the installed schema wins. The address is stable. The version is a decision. The schema is the evidence.

Arguments Describe Intent; Attributes Report Results

A resource block has two kinds of fields, and the schema labels every one.

An argument is something you set: the image, the size, the subnet, the tags. The schema marks each one required, optional, or optional and computed. A required argument fails the plan when absent; an optional one has a provider default; optional and computed means the provider chooses unless you set it, and then Terraform manages the value and reports drift.

An attribute is something the provider reports: the platform-assigned identifier, the ARN, the private address, the timestamp. Values arrive only after the platform has answered.

A computed value is not yours to declare

tags is yours; tags_all is the provider's. The first is an argument you write, the second a computed attribute that merges your tags with the provider's default tag set. Set the argument and Terraform accepts it; set the attribute and validation refuses.

That refusal is enforced at validation. Assigning an ARN by hand produces:

Error: Value for unconfigurable attribute — followed by "Can't configure a value for arn: its value will be decided automatically based on the result of applying this configuration."

The same distinction decides what you can know before apply. Arguments are known as soon as their expressions are known. Attributes that the platform assigns are unknown until the object exists, and Terraform prints them as (known after apply). It is not an error or a warning but a statement about ordering: no API call has returned this value yet, so the plan cannot show it.

The plan's symbol column compresses the same information. A plus creates, a tilde updates in place, a minus-plus replaces, a minus destroys, and a left arrow reads a data source. Whether an argument change produces an update or a replacement is decided by the provider schema, not by intuition: a tag is usually an update, and a subnet on an instance is usually a replacement.

The configuration below is the running example. A network root already owns a VPC and its private subnets; this root reads them, then creates one service object that depends on what it read.

terraform {
  required_version = "= 1.17.1"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "= 6.72.0"
    }
  }
}

provider "aws" {
  region = "eu-west-1"
}

variable "ami_id" {
  description = "Image for the payments service, supplied per region"
  type        = string
}

# Read an existing network owned by another root module.
data "aws_vpc" "shared" {
  tags = {
    Name = "platform-shared"
    Tier = "network"
  }
}

data "aws_subnets" "private" {
  filter {
    name   = "vpc-id"
    values = [data.aws_vpc.shared.id]
  }

  tags = {
    Tier = "private"
  }
}

# Create one object this root owns.
resource "aws_instance" "payments" {
  ami           = var.ami_id
  instance_type = "t3.micro"
  subnet_id     = sort(data.aws_subnets.private.ids)[0]

  tags = {
    Name    = "payments-api"
    Owner   = "payments-team"
    Network = data.aws_vpc.shared.id
  }
}

output "placement" {
  description = "Where the service landed, for the ownership map"
  value = {
    vpc_id      = data.aws_vpc.shared.id
    subnet_id   = aws_instance.payments.subnet_id
    instance_id = aws_instance.payments.id
  }
}
# Install the pinned provider and record the lock file.
terraform init

# Which provider instances this configuration uses, and for which modules.
terraform providers

# Addresses recorded in state. data.* entries are cached reads, not ownership.
terraform state list

# The full plan: created objects, data reads, and unknown values.
terraform plan -out=payments.tfplan

# Re-open the reviewed plan, including any read deferred to apply.
terraform show payments.tfplan

The schema splits the two blocks cleanly.

BlockArguments you setAttributes the provider reports
data.aws_vpc.sharedtags, filterid, cidr_block, owner_id, arn
aws_instance.paymentsami, instance_type, subnet_id, tagsid, arn, private_ip, public_ip

The output references only attributes, so it can show what was created and never dictate it.

One line deserves a second look: the sorted subnet index. The subnet list order is an API detail rather than a contract, so indexing the raw result would make placement depend on response order. Sorting makes the choice deterministic but picks by identifier rather than by design; a real service would repeat over the subnets or take a designated ID as a variable.

Figure 3 shows the loop from argument to attribute and the three points where it stops.

Arguments Describe Intent; Attributes Report Results
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    A["Arguments written
in the block"] --> B{"Every required
argument present?"} B -->|"no"| B1["Error: argument
required"] B -->|"yes"| C["Core evaluates
the expressions"] C --> D{"Value known
at plan time?"} D -->|"no"| D1["Plan prints
(known after apply)"] D -->|"yes"| E["Provider plans
a create or update"] D1 --> E E --> F["Apply sends planned
values through the API"] F --> G{"Did the API
accept the call?"} G -->|"no"| G1["Error returned,
partial work remains"] G -->|"yes"| H["Provider returns
the full attribute set"] H --> I["Core writes attributes
into state"] I --> J["Another block references
an attribute, not an argument"] classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class A,C,E,I,J primary; class B,D,F secondary; class H ok; class B1,G1 danger; class D1 warn;

A Resource Owns Lifecycle; a Data Source Reads

resource and data look similar and mean opposite things in an account.

A managed resource claims an object. Terraform creates it if missing, updates it if an argument differs, and destroys it if the block is deleted. The resource state entry is that claim: address, provider, platform identity, and last observed attributes. Two roots declaring the same VPC address do not share it; the second apply proposes a create for an object that already exists.

A data source is a memo, not a title deed

Reading does not transfer ownership. A data source has no create, update or delete path, so removing the block removes a query and nothing else; terraform destroy will not touch the object, and deleting the cached data. entry changes nothing. Adoption has one mechanism, and it is not a data block: an import attaches the existing object to a managed address, after which Terraform treats the lifecycle as its own. That transfer deserves review.

The shared-network pattern is the common case. A platform team owns the VPC, subnets, route tables and peerings in one root; service teams own instances and security groups in separate roots. The service root reads the VPC by a published tag and the subnets by vpc-id plus a tier tag, then creates objects inside that network. Destroying it leaves the network alone.

Figure 4 draws the two roots and the direction of authority.

A shared network owned by one root and read by another The platform-network root owns a VPC and two subnets, with three addresses in its state. The payments-service root reads the VPC and the subnet list through data sources and owns one instance. An arrow labelled describe only points from the consumer to the owner. A panel explains that removing a data block removes a query, not the network, and that adoption requires an import plus a managed resource. Who owns the object? Root A: platform-network aws_vpc.shared creates, updates, destroys the network aws_subnet.private_a owned and replaced here aws_subnet.private_b owned and replaced here 3 addresses in state, 3 objects claimed. Root B: payments-service data "aws_vpc" "shared" tag lookup, no lifecycle data "aws_subnets" "private" filter by vpc-id and tier aws_instance.payments created and destroyed here 1 address in state, 1 object claimed. describe read only Deleting the data block deletes a query, not the network. Adoption is a different operation: an import block or terraform import attaches the existing object to a managed address, after which this root claims its lifecycle. The platform root must release it first, or two states will claim the same VPC. Reads need permission. A consumer without ec2:DescribeVpcs fails before it can place anything.

A tag lookup is a contract, not a guarantee

A tag filter can return zero, one, or several objects. Zero produces "no matching VPC found"; several produce "multiple VPCs matched". Both are contract failures, and both beat silently placing a service in the wrong network. A stricter contract passes the ID in as a variable, which also removes the read permission the consumer needs.

Data Reads May Wait Until Apply

Terraform tries to read data sources during planning. The result feeds expressions, and a plan that cannot evaluate one cannot show what will change. When the arguments are all known — a literal tag, a variable, an ID from a previous root — the read happens during the plan, and the values appear in the diff like any other known value.

When an argument depends on something that does not exist yet, the read is deferred. The documented causes are a dependency on a managed resource the current plan will change, arguments that can only be computed during apply, or a condition that depends on such a resource (data source behavior). The plan prints "will be read during apply", and every attribute of that data source becomes (known after apply) — not only the unknown ones, but the whole result, because Terraform has seen none of it.

This is where a plan stops being a preview. Suppose the network is created in the same configuration and the subnet data block filters on aws_vpc.shared.id. During planning the VPC has no ID, so the subnets cannot be queried, so the instance's subnet_id is unknown, so its placement is unknown. A reviewer sees that an instance will be created and cannot see where. Nothing is wrong with the configuration; the information does not exist yet.

depends_on on a data block forces the same outcome deliberately, waiting for the named objects' operations before querying. That is occasionally necessary when an API is eventually consistent, but it is not a way to make a value known earlier, and it usually makes the plan less informative. Use it for ordering the schema cannot express, and prefer a plain reference when the reference already creates the edge.

A deferred read also changes failure recovery. If the query returns nothing — the tag was renamed, the VPC is in another account, the region is wrong — the error arrives during apply, after earlier resources were created. You are in a partial apply, not a failed plan with nothing changed, which is the strongest argument for making the read's inputs known before apply.

Three designs keep the plan informative: pass the identifier in as a variable from the owning root; read through a data source whose arguments are entirely known, such as an ID from the pipeline; or accept the deferral and add a precondition on the consumer, so an empty result fails with your message and a short graph.

Data reads are API calls too. A plan that refreshes forty objects and reads six data sources makes forty-six calls before it prints anything. -refresh=false skips the refresh of managed objects; it does not remove the reads the plan still needs.

Provider Credentials and Backend Credentials Are Separate

A single terraform apply can use more than one identity, and usually should.

Three roles are in play. The first is a fact about the process; the other two are configured in different blocks and can be entirely different principals.

RoleWho it isWhat it touches
Execution identityengineer at a terminal or a CI job with a short-lived tokenruns plan and apply
Backend identitycredentials available to the process, or the backend rolestate object and its lock
Provider identitythe provider block, optionally with assume_rolethe platform API

The backend is configured before providers are installed: terraform init contacts storage to write or verify state metadata, and fails there if the backend is unreachable, before any provider work begins. Later, every plan reads state, then calls provider APIs. Two credential chains run inside one command, and an error in either looks generic unless you know the layer.

The S3 backend documentation makes the split explicit: backend operations use the credentials available to the process, while resource operations go through the provider's assume_role (S3 backend). A run can therefore use one role to read state and a second, in another account, to create resources. Reviewing only the provider block reviews half the run.

Figure 5 shows the two paths and the two ways teams collapse them by accident.

One Terraform process, two credential paths A runner reaches a backend role that reads and writes the state object and lock, and separately a deployment role that calls the cloud API. The lower panel contrasts the failure of a single shared credential with the narrower split, where a read-only deployment role plans successfully but fails at the first write. One process, two keys Execution identity engineer or CI job runs plan and apply Backend role state object and lock Deployment role platform API only S3 state plus .tflock GetObject, PutObject, lock only EC2 and ELB APIs create, tag, modify, delete One credential for both state read equals secret read, so the apply key can exfiltrate what it is only meant to deploy. Split, with a plan-only variant a read-only deployment role plans cleanly and fails at the first write, which is a permission test, not a defect. The failure that confuses people: init fails on the backend before any provider call, so the error names storage, not credentials for the platform you were about to change.

Three consequences follow.

State read access is secret access

State holds attribute values, including initial passwords, keys and connection strings, so a role that can read the state object can read them without calling the API. Scope the backend role to one key and one KMS key, and do not give the deployment role state read "because it is convenient".

A plan-only identity is a real control. With a read-only role for plan and a write role for apply, a compromised pull request can propose anything and change nothing. A plan reviewed under one role is not a guarantee about an apply under another, which is why the saved plan is passed between them.

Cross-root reads are a credential path of their own. terraform_remote_state reads another root's state through that root's backend, using the backend's credential resolution rather than the provider's. It never touches the platform API and creates the undocumented coupling the next section warns about.

Choose an Ownership Boundary for Shared Infrastructure

The question that decides most shared-infrastructure arguments is not "who can change this?" but "whose state contains it?"

If exactly one root has the object in state, that root owns the lifecycle. Every other root reads it. If two roots have it, the platform has one object and two claims, and the claims diverge. The second apply proposes a create for something that exists; a destroy in one root removes what the other still uses; an import into both looks clean until they overwrite each other on alternate applies.

Double management is easy to create by accident. Copy a network module into a service repository and the new root builds a second VPC with the same name, because nothing in Terraform treats a name as a unique key. The quota is generous enough that nobody notices until the bill does.

The opposite failure is subtler. Two roots with a clean split still depend on each other through a lookup nobody documented. The consumer matches Name = "platform-shared"; the platform team renames the tag and applies successfully, and the consumer's next plan fails with "no matching VPC found" — or silently selects a different VPC. The contract between them was implicit.

Four mechanisms make the contract explicit, trading convenience against coupling.

MechanismHow the consumer gets the IDMain cost
Input variablethe pipeline passes the value inweakest coupling, but a stale value quietly references the previous network
Remote state outputterraform_remote_state reads the owner's staterenaming an output breaks consumers; read access exposes every value in that state
Tag lookupmatches a published name or tagsurvives a move between roots, but a renamed or duplicated tag changes the answer without an error
SSM parameterreads a parameter pathsuits many consumers, and drifts when parameter and object are updated separately

Write the choice down in both repositories. The platform root lists what it publishes — VPC ID, subnet IDs by tier, tag contract, parameter path — and the service root records what it consumes and assumes. That pair of documents is the ownership map, and it names the failure better than a diagram can.

The boundary also runs between environments. A production network and a staging network are different objects with different owners even when one module creates both. A service root reading "the VPC tagged platform-shared" finds whichever one its credentials can see — without an account guard, whichever account the shell pointed at.

Lab

Manage or discover?

Status: design-only. None of these commands were executed for this article. They target a disposable sandbox account with Terraform CLI 1.17.1 and hashicorp/aws 6.72.0, and produce an ownership map plus one observed deferred read. Cost is near zero: no billable object is created.

Setup. Two directories, each with its own state.

DirectoryDeclaresWhat it owns
labs/p12/network/a VPC tagged Name = "platform-shared" and Owner = "platform", two subnets tagged Tier = "private", and an output vpc_idthe network objects
labs/p12/service/resource "terraform_data" "placement" whose triggers_replace is the sorted subnet IDone service object
  1. Apply the network root. The state list should show exactly the VPC and two subnets.
  2. Plan the service root. Both data sources are read during planning and the subnet IDs appear as concrete values.
  3. Apply, then list state. The two data addresses appear as cached reads. Confirm that destroy does not plan to touch the VPC.
  4. Add a managed VPC with the same tags and plan. Terraform proposes a create, not an import, proving the data source transferred no ownership. Delete the block without applying.
  5. Add a gate resource and put it in the subnet read's depends_on. Because the gate is new, the read moves to apply and the IDs become unknown until apply.
  6. Rename the tag, apply the network root, then plan the service root. With the read back at plan time, expect "no matching VPC found".
  7. Destroy the service root, then the network root. Both state lists should be empty.

Expected observation. Step 4 proves that reading is not owning: Terraform offers to create a second object rather than adopting the existing one. Step 5 shows the cost: a visible value becomes (known after apply).

Failure check. If step 4 shows no change, the block reused an address already in state. If step 5 still shows known IDs, depends_on went on the resource instead of the data block.

Evidence. The two state lists, the ownership map, and the step 4 and 5 plan excerpts. Sanitize account identifiers and VPC IDs.

An object's owner is the state file that would destroy it. Everything else is a reader, a variable, or a documented contract. Once that holds for every shared object, the remaining questions are ordinary engineering — naming, tagging, review — instead of ownership questions discovered during an incident.

Next in the Series

In Dependencies and Lifecycle: Make Replacement Behavior Explicit, we'll explore Read graph ordering and use lifecycle controls without assuming they guarantee availability.