Type constraints - Any Type

Learn how to use any type constraints in a Terraform project.

We'll cover the following

any#

The any type is a special construct that serves as a placeholder for a type yet to be decided. any itself is not a type. Terraform will attempt to calculate the type at runtime when you use any.

Project example#

Let’s go into an example of using the any type:

Terraform any type constraints project example

In the above example, we are defining an object with the any type. As we are initialising the object to a default value, Terraform will use this default value to figure out the type of our variable any_example. Terraform will give our variable the type object({ field1 = string, field2 = string}). We then print out the any_example variable using an output.

Running the project#

Clicking the terminal will run terraform init and terraform apply commands. When prompted, type yes and press enter.

This code requires the following environment variables to execute:
access_key_id
Not Specified...
secret_access_key
Not Specified...
Terminal 1
Terminal

Click to Connect...

📝Note: Once you are done with the project, do not forget to run terraform destroy and then confirm with yes to delete all of the resources in this project.

Type constraints - Object
🎉Quiz
Mark as Completed
Report an Issue