Configure
Create the following variable in your variables.tf:
variables.tf
variable "apps" {
default = [ "www", "api", "blog", "shop", "cdn"]
}
Update
In your main.tf and with the use of the for
expression, convert each app name above into a hostname by appending the example.com domain. The new local variable containing the new hostnames list can be named app_hostnames
and we will use it in later exercises.
Output
Output the app_hostnames
local to confirm the logic is applied.
Plan
Run terraform plan
. You could run terraform apply
too, but because we are not modifying any resources no changes will be applied anyway.
Commit
Commit your change and push it to GitHub.