Help for the VSCode editor.
-
Information only
-
What is the resource_type of the resource that's currently defined in the main.tf file?
Refer to the documentation
-
Information only
-
Which of the following attributes are exported by the time_static resource?
Refer to the documentation, and scroll down to the
Read-Only
section belowSchema
. Compare what is there with the given answers and select the correct one.Read-only attributes are exported by a resource, and can be referenced from other resources.
Note that you cannot assign a value to a read-only attribute in a
.tf
configuration file. -
How do we refer to the attribute called id using a reference expression?
Know that a resource attribute reference is of the form
resource_type.resource_name.attribute_name
time_static.time_update.id
-
Now, update the main.tf file and add a new local_file resource called time with the following requirements
- filename:
/root/time.txt
- content:
Time stamp of this file is <id from time_update resource>
For this, we need to add a
local_file
resource, like in previous labs. However this time, we need to refer to the ID of thetime_static
resource for the content, so we'll be using the expression we determined in Q5.-
Update
main.tf
and add new resourceReveal
resource "local_file" "time" { filename = "/root/time.txt" content = "Time stamp of this file is ${time_static.time_update.id}" }
-
Deploy the resources from the terminal
cd /root/terraform-projects/project-chronos terraform init terraform plan terraform apply
- filename:
-
What is the attribute called id that is created for the local file resource called time?
Make use of the terraform show command and identify the attribute values.
cd /root/terraform-projects/project-chronos terraform show
This will print out the resources that were defined, along with the current values for all their attributes. Find the
id
attribute for thelocal_file
resource. -
What is the attribute called rfc3339 that is created for the time_static resource called time_update?
Refer again to the output from
terraform show
. Find therfc3339
attribute for thetime_static
resource.