Terraform

What is a data source? In what scenarios for example would need to use it?

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

Data sources lookup or compute values that can be used elsewhere in terraform configuration.

There are quite a few cases you might need to use them:

  • you want to reference resources not managed through terraform
  • you want to reference resources managed by a different terraform module
  • you want to cleanly compute a value with typechecking, such as with aws_iam_policy_document