Using existing resource attributes from another resource in Terraform

In below example we will use a time_static resource attribute id to put the value of it in a file:

resource "time_static" "time" {}

resource "local_file" "timefile" {
  filename = "/home/dmitritelinov/time.txt"
  content = "Hi, the time is ${time_static.time.id}"
}
To test in run init, plan and apply