Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

format string with multiple values in terraform

Terraform version = .12+

I'm wondering if there's a way to format a single string with multiple values.

I've tried using the terraform format function like so:

bucket = format("%-%", 'dev', "test")
bucket = format("%-%", ['dev', "test"])

which both output the error:

Call to function "format" failed: unrecognized format character '%' at offset
2.

The expected formatted value would be dev-test

like image 909
Marshallm Avatar asked May 02 '26 07:05

Marshallm


1 Answers

The code should be:

bucket = format("%s-%s", "dev", "test")

It uses %s as well as double quotes for dev.

The formatting marks available are detailed here.

like image 130
Marcin Avatar answered May 03 '26 19:05

Marcin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!