Terraform Language Functions and Features, Exams of Social Sciences

An overview of various terraform language functions and features, including the element function, the file function, dynamic blocks, the taint command, terraform graph, the output command, terraform settings, debugging terraform, the terraform format command, meta-arguments like ignore_changes and replace_triggered_by, data types, the dry principle, terraform modules, terraform workspaces, remote state management, terraform backends, state locking, terraform state management commands, terraform import, the sensitive parameter, the dependency lock file, terraform cloud, vcs providers, and sentinel. The structure, usage, and benefits of these terraform concepts, making it a valuable resource for terraform users, particularly those interested in understanding the language's advanced features and capabilities.

Typology: Exams

2023/2024

Available from 09/22/2024

ROCKY-B
ROCKY-B 🇰🇪

4.4

(16)

40K documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
HASHICORP TERRAFORM ASSOCIATE EXAM
What are the Terraform language functions? - Answers -1. Numeric
2. String
3. Collection
4. Encoding
5. Filesystem
6. Date and Time
7. Hash and Crypto
8. IP Network
9. Type Conversion
True/False: Terraform only supports built in functions, not user defined - Answers -
TRUE
What is the structure of the LOOKUP function? - Answers -{map, key, default}
What does the element function do? - Answers -Retrieves a singe element from a list
What is the structure of the element function? - Answers -(list, index)
example: (["a", "b", "c"], 1)
ANSWER = B (because it is place 1 in the list)
TRUE/FALSE: If given index is longer than the list length, the index is wrapped around
back to the beginning - Answers -TRUE
example: (["a", "b", "c"], 3)
ANSWER = A
What does the FILE function do? - Answers -READS the content of a file at the given
path and RETURNS them as a string
What is the structure of the FILE function? - Answers -file ("${path.module}/hello.txt)
What are Data Sources? - Answers -Allow data to be fetched or computer for use
elsewhere in the Terraform configuration
What is the Dynamic Block in Terraform? - Answers -Allows us to dynamically construct
repeatable nested blocks which is supported inside resource, data, provider, and
provisioner blocks
When would tainting resources become applicable? - Answers -When recreating a
resource to fix
Describe the Terraform TAINT command: - Answers -Informs Terraform that a particular
object has become degraded or damaged.
pf3
pf4
pf5
pf8

Partial preview of the text

Download Terraform Language Functions and Features and more Exams Social Sciences in PDF only on Docsity!

HASHICORP TERRAFORM ASSOCIATE EXAM

What are the Terraform language functions? - Answers -1. Numeric

  1. String
  2. Collection
  3. Encoding
  4. Filesystem
  5. Date and Time
  6. Hash and Crypto
  7. IP Network
  8. Type Conversion True/False: Terraform only supports built in functions, not user defined - Answers - TRUE What is the structure of the LOOKUP function? - Answers -{map, key, default} What does the element function do? - Answers -Retrieves a singe element from a list What is the structure of the element function? - Answers -(list, index) example: (["a", "b", "c"], 1) ANSWER = B (because it is place 1 in the list) TRUE/FALSE: If given index is longer than the list length, the index is wrapped around back to the beginning - Answers -TRUE example: (["a", "b", "c"], 3) ANSWER = A What does the FILE function do? - Answers -READS the content of a file at the given path and RETURNS them as a string What is the structure of the FILE function? - Answers -file ("${path.module}/hello.txt) What are Data Sources? - Answers -Allow data to be fetched or computer for use elsewhere in the Terraform configuration What is the Dynamic Block in Terraform? - Answers -Allows us to dynamically construct repeatable nested blocks which is supported inside resource, data, provider, and provisioner blocks When would tainting resources become applicable? - Answers -When recreating a resource to fix Describe the Terraform TAINT command: - Answers -Informs Terraform that a particular object has become degraded or damaged.

What are splat expressions? - Answers -It provides a more concise way to express a common operation

  • symbol iterates over all of the elements of the list` var.list[*].id What is Terraform Graph? - Answers -A way to generate a visual representation of either a configuration or execution plan What is the format of terraform graph? - Answers -DOT Format that gets converted into an image TRUE/FALSE: A generated terraform plan can NOT be saved to a specific path - Answers -FALSE What is the Terraform OUTPUT command? - Answers -The terraform output command is used to extract the value of an output variable from the state file. example: terraform output iam_arn TRUE/FALSE: If the running version does not match the specified constraints, then an error will persist - Answers -TRUE What is Terraform Settings? - Answers -The special terraform configuration block type is used to configure some behaviors of Terraform itself, such as requiring a minimum Terraform version to apply your configuration. What are examples of terraform settings? - Answers -Terraform version and Provider version Describe required_versions: - Answers -Accepts a version constraint string Where is data source defined within the Terraform code? - Answers -Under the data block How do you DEBUG Terraform? - Answers -Terraform has detailed logs which are enabled by setting the TF_LOG environment variable to any value. What are the log levels that TF_LOG can be set to? - Answers -TRACE, DEBUG, INFO, WARN, ERROR What does Terraform Format (terraform fmt) do? - Answers -Rewrites configuration (i.e. removes indentation and aligns commands)

What is the DRY Principle? - Answers -Don't Repeat Yourself - limits the amount of repeated code as much as possible What is a challenge with directly using MODULES in respect to infrastructure management? - Answers -Resources will be a REPLIA of code in the module. It is hard- coded in the module as one resource, but in a different environment, you might not want that hard-coded resource What is a challenge with using locals to assign values within a module instead of using a variable? - Answers -Unable to override What is the Terraform Registry? - Answers -A repository of modules written by the Terraform community with a goal to get started in Terraform more quickly. Verified modules are actively updated and indicated by a blue badge What are the requirements for publishing to the Terraform Registry? - Answers -1. Must be on Github and a PUBLIC repository

  1. Have the 3 part name format terraform - -
  2. Must have a repository description
  3. Standard module structure (file/directory layout) (readme.tf, main.tf, variables.tf, and outputs.tf)
  4. x.y.z tags for releasers v.1.0. What are the two types of modules? - Answers -Minimal and complete What encompasses a minimal module? - Answers -readme.tf, main.tf, variables.tf, outputs.tf What encompasses a complete module? - Answers -readme.tf, main.tf, variables.tf, outputs.tf PLUS examples and modules folder What is a Terraform Workspace? - Answers --Terraform allows us to have multiple workspaces; with each of the workspaces, we can have a different set of environment variables associated. -Workspaces allow multiple state files of a single configuration.

-Example: can launch two different instance types in two different environments (staging and production) within the workspace What does the command terraform workspace -h do? - Answers -Shows a list of subcommands (delete, list, new, select, show) What is Remote State Management? - Answers -Terraform writes the state data to a remote data store, which can then be shared between all members of a team. What is the benefit of using remote state? - Answers -It alleviates the issue caused by Terraform's default.; Terraform stores state locally in a file named terraform.tfstate. When working with Terraform in a team, use of a local file makes Terraform usage complicated because each user must make sure they always have the latest state data before running Terraform and make sure that nobody else runs Terraform at the same time. Why are downside of local changes? - Answers -- Not collaborative

  • Crashes can occur What are the benefits of centralized management in GIT repository? - Answers -- Allows for team collaboration/managemnet
  • Utilizing git commands to push to the central repo TRUE/FALSE: You can store passwords, secret keys, and access keys in the central repository - Answers -FALSE - NEVER do it What is the most secure way to store passwords? - Answers -Using a pathway command to indirectly add to the terraform code NEVER hardcode the password into the central repo What is the Module Source? - Answers -The source argument in a module block tells Terraform where to find source code for desired child module. Terraform uses this during the module installation step of terraform init to download the source code to a directory on local disk so that other Terraform commands can use it. What are examples of supported source types? - Answers -- local path
  • terraform registry
  • GitHub
  • Bitbucket
  • Generic Git
  • HTTP URLs

What would be a reason to have to conduct terraform state management? - Answers - When terraform usage becomes more advanced and there is a need to modify the terraform state What are the common terraform state management commands? - Answers -1. list - list resources within TF state file

  1. mv - moves items within the TF state file
  2. pull - manually download and output the state from remote state
  3. push - manually upload a local state file to remote state
  4. rm - remove items from the terraform state
  5. show - show the attributes of a single resource in the state TRUE/FALSE: rm is not physically destroying, but it is not used and recongized by terraform - Answers -TRUE TRUE/FALSE: mv command will not output a backup copy as it does not have destructive properties - Answers -FALSE What is terraform import? - Answers -Terraform can import existing infrastructure resources. This functionality lets you bring existing resources under Terraform management. Both resources and state file will be created for you What is Terraform Remote State? - Answers -Where Terraform writes the state data to a remote data store, which can then be shared between all members of a team. terraform_remote_state data source gets the root module output values from some other terraform configuration What is the sensitive parameter? - Answers -when sensitive = true, it prevents the field's value from showing up db_password = password --> db_password = TRUE/FALSE: The sensitive parameter will encrypt or obscure the value - Answers - FALSE What is the HashiCorp Vault? - Answers -A way to allow organizations to securely store secrets (tokens, passwords) along with access management for protecting secrets Features include:
  • Rotating keys
  • Supply your key
  • Can help encrypt your data

Vault + Terraform = any secrets that you read/write are persisted in state file Describe the Dependency Lock File: - Answers -The dependency lock file is a file that belongs to the configuration as a whole, rather than to each separate module in the configuration. What are version dependencies? - Answers -Version constraints within configuration determines which versions of dependencies are compatible Terraform remembers which version of each dependency in a dependency lock file What happens when you update the terraform file with versions that doesn't match the terraform.lock.hcl (terraform lock file)? - Answers -An error will happen What is the Terraform Cloud? - Answers -Manages Terraform runs in a consistent/reliable environment It shows runs, commentary, and status of runs What is the VCS Provider? - Answers -Where you can configure the Terraform Cloud with the Git repository to fetch Terraform code What must you connect to in the Terraform Workspace when working with VCS Provider? - Answers -version control provider What is Sentinel? - Answers -- policy-as-code framework meshed with HashiCorp products

  • enables logic based policy decisions
  • PAID feature terraform plan > sentinel checks > terraform apply What are air-gapped environments? - Answers -Network security measure employed to ensure that a secure computer network is physically isolated from unsecured networks (public internet).