Reputation: 1995
I am looking through some terraform code and not sure what the format("%s-%s",) does below?
app_resourcegroup_name = format("%s-%s", module.env_vars.resourcegroup_prefix, "app")
Upvotes: 1
Views: 7077
Reputation: 20537
It's a common format string as you might find it in c, bash, or go for that matter.
In your example, %s
means this should be substituted for a string. The string values are supplied by the additional arguments module.env_vars.resourcegroup_prefix
and "app"
.
In your example %s-%s
, assuming the prefix is "foo", the final result would be foo-app
.
You can see more information about format strings here: https://pkg.go.dev/fmt and here https://www.terraform.io/language/functions/format. Terraform is written in go, but its format string syntax can differ slightly.
Upvotes: 4