Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 19


Which of the following is not a valid string function in Terraform?

Show Answer
Correct Answer: C

The function 'split' is used to split a string into a list of substrings. The function 'join' is used to concatenate a list of strings into a single string with a specified delimiter. The function 'chomp' removes newline characters at the end of a string. 'Slice', however, is not a string function in Terraform; it is a collection function used to extract a range of elements from a list or tuple. Therefore, 'slice' is not a valid string function in Terraform.

Discussion

41 comments
Sign in to comment
testtaker_1885
Apr 22, 2022

answer is c slice not listed in official docs https://www.terraform.io/language/functions

bp339
May 20, 2022

https://www.terraform.io/language/functions/slice

doumx
Jun 1, 2022

string function

samkobadev
Feb 9, 2023

so the correct answer is?

Shane_C
Jul 4, 2023

Answer is C

Shane_C
Jul 4, 2023

The question asked for a function that is not a string function. Slice is a collection function, all other answers are string functions. Answer is C

Shane_C
Jul 4, 2023

Answer is C

doumx
Jun 1, 2022

string function

samkobadev
Feb 9, 2023

so the correct answer is?

Shane_C
Jul 4, 2023

Answer is C

Shane_C
Jul 4, 2023

The question asked for a function that is not a string function. Slice is a collection function, all other answers are string functions. Answer is C

Shane_C
Jul 4, 2023

Answer is C

coco10kOption: C
Apr 22, 2022

slice is not in string function list.

Selvan1978Option: D
Sep 24, 2024

A. split: The split function is used to split a string into a list of substrings based on a specified delimiter. B. join: The join function is used to concatenate a list of strings into a single string with a specified delimiter. C. slice: The slice function is used to extract a range of elements from a list or tuple. D. chomp: The chomp function is not a valid string function in Terraform. It is not part of Terraform's standard function set for working with strings. So, the correct answer is D. chomp.

fabiomlopOption: C
Jun 18, 2022

Altough slice is a valid function, it is not a string function. The equivalent for string would be substr.

EdwardBHall
Jun 10, 2023

Why are the correct answers SO bad in this site? Someone is an absolute idiot.

FarziWaliMarziOption: C
Apr 10, 2023

Slice is a collection function, while chomp is a string function. refer URL https://developer.hashicorp.com/terraform/language/functions

Mehedidevops
May 9, 2023

why they put in here wrong ans?

cminor01Option: C
May 12, 2022

Slice is not listed in docs as others have stated.

LongKBOption: C
Jun 14, 2022

slice is correct

charlesguowh
Aug 25, 2022

answer is c slice is a collection function

staunchdaddy69
Sep 15, 2022

What is with all these wrong answers?? You have provided the docs for literally a correct answer C! SORT IT OUT

vikramvlr
Dec 13, 2022

Answer is C. Split,join and chomp - string functions slice - collection function https://developer.hashicorp.com/terraform/language/functions/slice

BereOption: C
Dec 19, 2022

String Functions: https://developer.hashicorp.com/terraform/language/functions/split https://developer.hashicorp.com/terraform/language/functions/join https://developer.hashicorp.com/terraform/language/functions/chomp Collection Functions: https://developer.hashicorp.com/terraform/language/functions/slice

alexsandroeOption: C
Feb 25, 2023

C - Slice thats used for list, not string, chomp is for used in string

acheironOption: C
Mar 17, 2023

Slice() is a list function, not a string function. Chomp() is a string function.

Nunyabiznes
Mar 19, 2023

The correct answer is indeed C. slice is not a valid string function in Terraform. Terraform provides several built-in functions for manipulating strings, but slice is not one of them. The valid string functions in Terraform are: A. split: This function splits a string into a list of substrings based on a delimiter. Example: split(",", "a,b,c") returns ["a", "b", "c"] B. join: This function joins a list of strings into a single string using a delimiter. Example: join(",", ["a", "b", "c"]) returns "a,b,c" C. chomp: This function removes trailing newline characters from a string. Example: chomp("hello\n") returns "hello" D. substr: This function returns a substring from a string based on a start index and an optional length. Example: substr("hello", 1, 3) returns "ell"

AzRNoob
Apr 7, 2023

Answer is C The slice function is not a valid string function in Terraform. The split function can split a string into a list of substrings based on a specified separator, the join function can concatenate a list of strings into a single string using a specified separator, and the chomp function can remove any trailing newline characters from a string. However, the slice function is used to extract a consecutive subsequence of elements from a list or tuple. It is not a string function.

babs30
May 10, 2023

slice is the correct answer, C

kudakkOption: C
Aug 17, 2023

Slice Function is not part of the string function. Others like join, split, chomp are part of it.

bp339
May 20, 2022

https://www.terraform.io/language/functions/slice

bp339
May 20, 2022

sorry slice is not a string function but a collection.

EltoothOption: C
Jul 1, 2022

C is correct answer.

aiya
Aug 12, 2022

Answer is C - slice

geekneek
Aug 16, 2022

The answer is c. slice does not exist.

DataConsultant
Nov 29, 2022

Slice is in the collection function list not in the string function list : https://developer.hashicorp.com/terraform/language/functions/slice

Chaks1985
Jan 6, 2023

Ans: C https://developer.hashicorp.com/terraform/language/functions/slice - Slice is for list but not for strings

irisperes
Jan 11, 2023

Answer C "slice" is not a built-in function in terraform. it is not related to strings.

noobsterOption: C
Jan 25, 2023

https://developer.hashicorp.com/terraform/language/functions/chomp

TanacetOption: C
Jan 28, 2023

Slice is for the lists

Shane_COption: C
Jul 4, 2023

The question asked for a function that is not a string function. Slice is a collection function, all other answers are string functions. Answer is C

cdechery
Jul 16, 2023

Slice is not a string function. Why are so many answers here just plain wrong with 99% and sometimes 100% of votes on the correct answer?

Busi57Option: D
Jul 23, 2023

i hesitate between c and D , i choose D

Venki_dev
Apr 3, 2024

slice comes under collective function and not string functions. answer is C

Jayanth
Jul 28, 2023

C. slice

imkhan
Oct 18, 2023

The correct answer is C. Slice function is not listed in the official documentation of terraform string functions https://developer.hashicorp.com/terraform/language/functions slice is a collection function that extracts some consecutive elements from within a list. https://developer.hashicorp.com/terraform/language/functions/slice If you are interested to learn about the Terraform string functions you can visit the following link https://bitsto.cloud/terraform-string-functions/

MisterR0B0T
Oct 31, 2023

chomp is not a valid string function in Terraform. The other three options are all valid string functions: split splits a string into a list of strings, based on a delimiter. join joins a list of strings into a single string, using a separator. slice extracts a substring from a string, starting at a specified position and ending at a specified position or length.

mohamed1999
Dec 25, 2023

that is not correct : chomp removes newline characters at the end of a string. This can be useful if, for example, the string was read from a file that has a newline character at the end. https://developer.hashicorp.com/terraform/language/functions/chomp

samimshaikhOption: C
Dec 29, 2023

slice is collection function and chomp is string function so SLICE is correct answer as not a valid string function "C"

Venki_devOption: C
Apr 3, 2024

slice comes under collective function and not string functions. answer is C

Molly1994
Jun 1, 2024

answer is C slice. slice is collection function. all other three are string function

MisterR0B0T
Sep 24, 2024

ANSWER IS D. Chomp is not valid Here are some examples of how to use these string functions in Terraform: # Split a string into a list of strings, based on a comma delimiter variable "tags" { type = string } output "tags_list" { value = split(var.tags, ",") } # Join a list of strings into a single string, using a space separator variable "regions" { type = list(string) } output "regions_string" { value = join(var.regions, " ") } # Extract a substring from a string, starting at position 5 and ending at position 10 variable "hostname" { type = string } output "hostname_suffix" { value = slice(var.hostname, 5, 10) }

mohamed1999
Dec 25, 2023

that is not correct : chomp removes newline characters at the end of a string. This can be useful if, for example, the string was read from a file that has a newline character at the end. https://developer.hashicorp.com/terraform/language/functions/chomp

samirsetcOption: C
Feb 4, 2025

slice is a collections function

gswarOption: D
Feb 16, 2025

terraform does support the other functions.

b890ycOption: C
Mar 31, 2025

slice extracts some consecutive elements from within a list. https://developer.hashicorp.com/terraform/language/functions/slice