-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
39 lines (38 loc) · 1.05 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* Usage:
*
* ```
* module "terraform_string_convert_format" {
* source = "[email protected]:hacomono/terraform-string-convert-format.git"
* str = "hello new world"
* }
* ```
*
* Output:
*
* ```
* terraform_string_convert_format = {
* "pure" = "hello new world"
* "camelcase" = "helloNewWorld"
* "kebabcase" = "hello-new-world"
* "lower" = "hello new world"
* "pascalcase" = "HelloNewWorld"
* "snakecase" = "hello_new_world"
* "upper" = "HELLO NEW WORLD"
* "uppercamelcase" = "HelloNewWorld"
* "upperkebabcase" = "Hello-New-World"
* }
*/
locals {
formats = {
pure = var.str
upper = upper(var.str)
lower = lower(var.str)
camelcase = replace(join("", [substr(var.str, 0, 1), substr(title(var.str), 1, -1)]), " ", "")
snakecase = replace(var.str, " ", "_")
kebabcase = replace(var.str, " ", "-")
pascalcase = replace(title(var.str), " ", "")
uppercamelcase = replace(title(var.str), " ", "")
upperkebabcase = replace(title(var.str), " ", "-")
}
}