Difference between revisions of "Terraform replace function"
Jump to navigation
Jump to search
(Created page with " == See also == * {{Terraform functions}} Category:Terraform") |
|||
| (6 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| + | https://www.terraform.io/language/functions/replace | ||
| + | |||
| + | replace(string, substring, replacement) | ||
| + | |||
| + | == Examples == | ||
| + | |||
| + | > replace("1 + 2 + 3", "+", "-") | ||
| + | 1 - 2 - 3 | ||
| + | > replace("hello world", "/w.*d/", "everybody") | ||
| + | hello everybody | ||
| + | |||
| + | |||
| + | |||
| + | locals { | ||
| + | name = "example-${replace([[basename]]([[path.cwd]]), "_", "-")}" | ||
| + | region = "eu-west-1" | ||
| + | tags = { | ||
| + | Owner = "user" | ||
| + | Environment = "dev" | ||
| + | } | ||
| + | } | ||
Latest revision as of 12:48, 7 June 2022
https://www.terraform.io/language/functions/replace
replace(string, substring, replacement)
Examples[edit]
> replace("1 + 2 + 3", "+", "-")
1 - 2 - 3
> replace("hello world", "/w.*d/", "everybody")
hello everybody
locals {
name = "example-${replace(basename(path.cwd), "_", "-")}"
region = "eu-west-1"
tags = {
Owner = "user"
Environment = "dev"
}
}
See also[edit]
- Terraform functions, Terraform collection functions:
tolist,toset,length,sum,file,join,depends_on,zipmap,replace,lookup,read files,concat,merge, templatefile, for_each, format, element, slice, try, filebase64, upper, filemd5, coalesce, formatlist, flatten, sensitive, tonumber, jsondecode, yamldecode, pathexpand
Advertising: