I'm creating a Terraform file, and something is obviously wrong,

Error: Incorrect condition type

  on ssh.tf line 47, in locals:
  47:   is_generated = data.local_sensitive_file.public_key ? true : false
    │ data.local_sensitive_file.public_key is object with 4 attributes

The condition expression must be of type bool.

How do I find out what the attributes of data.local_sensitive_file.public_key are though?

2 Answers 2


Since local_sensitive_file here is a data source, you can assume that its attributes are the attributes defined by the provider that this data source belongs to, which is hashicorp/local.

At the time of writing the documentation for local_sensitive_file says that it has the following attributes:

  • filename
  • content
  • content_base64
  • id

Provider documentation is typically the best place to find out about attributes of a resource type because it'll also tell you what these attributes represent, in addition to their names.

Not all objects you'll encounter in Terraform will originate in providers though, so a more general answer that will work for any object you can refer to in an expression is to run terraform console and then ask it for the type of the value in question:

> type(data.local_sensitive_file.public_key)
    content: string,
    content_base64: string,
    filename: string,
    id: string,

Unfortunately for a resource (either a resource or data block) it won't yet have a known type until it's been created or read for the first time, and so if your configuration isn't valid then you would need to make it valid enough to run terraform apply successfully before you could use this technique. But for objects that are defined within the Terraform configuration itself, rather than by external operations that haven't run yet, the console is a useful way to inspect data and data types.

  • 1
    your answer is better than mine, thanks for coming in after with it. Feb 15, 2023 at 16:21

You can find the keys with

terraform show -json |
  jq '.values[].resources[] | select(.address=="data.local_sensitive_file.public_key").values | keys'

Which should return,


Alternatively you can look up local_sensitive_file in the docs.

  • It doesn't work: first item is null. Try it yourself!
    – EnzoR
    Jun 23, 2023 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.