SAI VINIL
SAI VINIL

Reputation: 119

what is difference between resources and data sources in terraform documentation for a particular terraform provider?

resources and data sources in terraform documentation link, can anyone explain their difference and example scenario where they can be used

Upvotes: 4

Views: 6956

Answers (2)

Siraf
Siraf

Reputation: 1292

To understand the difference consider this scenario:

  • You develop a cloud solution that consists of services that consume data from a database.
  • You are not the owner of the database, a customer or another team owns the database.
  • Your services need to know some database properties like host name, ports...etc

Using a data source that refers to the database you can get information of the database that you need in your terraform configuration.

Upvotes: 1

Marcin
Marcin

Reputation: 238407

  • Data Sources: Allow Terraform to use information defined outside of Terraform, defined by another separate Terraform configuration, or modified by functions.
  • Resources: Each resource block describes one or more infrastructure objects, such as virtual networks, compute instances, or higher-level components such as DNS records.

Upvotes: 6

Related Questions