Difference between revisions of "Terraform replace function"

From wikieduonline
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
  replace(string, substring, replacement)
 
  replace(string, substring, replacement)
  
=== Example ===
+
== Examples ==
  
 
  > replace("1 + 2 + 3", "+", "-")
 
  > replace("1 + 2 + 3", "+", "-")
Line 9: Line 9:
 
  > replace("hello world", "/w.*d/", "everybody")
 
  > replace("hello world", "/w.*d/", "everybody")
 
  hello everybody
 
  hello everybody
 +
 +
 +
 +
locals {
 +
  name  = "example-${replace([[basename]]([[path.cwd]]), "_", "-")}"
 +
  region = "eu-west-1"
 +
  tags = {
 +
    Owner      = "user"
 +
    Environment = "dev"
 +
  }
 +
}
 +
 +
  
 
== See also ==
 
== See also ==

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]

Advertising: