Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Hashicorp Terraform Associate Exam Preparation: Questions and Answers, Exams of Nursing

A comprehensive set of questions and answers designed to help individuals prepare for the hashicorp terraform associate certification exam. It covers key concepts, commands, and best practices related to terraform, including initialization, planning, applying, destroying, and managing infrastructure resources. The document also explores advanced topics such as variables, modules, data sources, provisioners, and dynamic blocks, providing practical examples and explanations to enhance understanding.

Typology: Exams

2024/2025

Available from 11/16/2024

EXAMDOC
EXAMDOC 🇺🇸

4

(6)

7.6K documents

Partial preview of the text

Download Hashicorp Terraform Associate Exam Preparation: Questions and Answers and more Exams Nursing in PDF only on Docsity!

Hashicorp TF Associate questions with correct

answers

init CORRECT ANSWER "terraform ________" is the first command you should enter to initialize your Terraform environment and download any necessary configuration/provider files. plan CORRECT ANSWER "terraform ______" is the command you should run to view resources that will be generated from your various .tf files. It will also run a validation check on your code to ensure proper syntax. apply CORRECT ANSWER "terraform ______" is the command you should run that will result in a confirmation prompt. This will actually spin up the resources defined in your .tf files. destroy CORRECT ANSWER "terraform ______" is the command you should run to tear down your terraform managed resource(s). resource=aws_instance , block=myec2 CORRECT ANSWER In the below code snippet, identify which is the resource and which is the block identifiers (i.e. resource=_______ , block=_______) resource "aws_instance" "myec2" { ... } .tfstate CORRECT ANSWER Terraform stores the current state of the infrastructure that is being created from .tf files in the ________ file This allows terraform to map real world resources to your current configuration.

T CORRECT ANSWER T/F: If your desired state differs from your current state (i.e. manual changes occurred outside of terraform), then using "terraform apply" will reset your configuration settings (revert any manual changes) refresh CORRECT ANSWER "terraform ______" fetches the latest configuration state of your resources (checks your current managed state vs real world infrastructure) T CORRECT ANSWER T/F: terraform plan always makes terraform check for mismatches with current vs. desired state show CORRECT ANSWER "terraform ________" gives you information from your state file on your current configuration. T CORRECT ANSWER T/F: If your desired state does not define/mention a property of your resources that is later modified (manually), terraform will NOT track any drift from those manual changes. F (outputted resources can be used as inputs for other resources definitions -- make sure you specify attributes in your outputs or it will list the entire list of attributes as an output) CORRECT ANSWER T/F: Outputted attributes CANNOT be used as inputs to other resources being created via terraform. variables, -vars CORRECT ANSWER You can use a ________.tf file to reference vars. Alternatively, you can use the ______ command line flag to override variables. default, prompted CORRECT ANSWER If no override value(s) are defined in the command line for variables, the _______ variable value(s) are used. If no default

value is supplied for your variables, you will be ___________ by terraform to specify value(s). tfvars, override CORRECT ANSWER You can specify a file called "terraform.__________" to define variable assignments. The values assigned to variables in this file will _______________ the var values defined in the variables.tf file (including any defaults). type CORRECT ANSWER the ______ arg in a variable block will restrict the type of value that will be accepted as the value for the variable. count CORRECT ANSWER The _______ parameter on resources can simplify configurations and allow you to scale resources by increasing a number (rather than defining the resources multiple times) count object CORRECT ANSWER In the resource blocks where count is set, an additional ______ _______ is available in expressions so you can modify the configuration of each instance. index CORRECT ANSWER The count object has one attribute: the count._______ -- the distinct index number (starting with 0) corresponding to this instance. true_value, false_value CORRECT ANSWER Fill in the blanks to complete the bool expression: condition? ____________ : __________ local CORRECT ANSWER ________ values assigns a name to an expression, allowing it to be used multiple times within a module without repeating it.

repeating, moderation CORRECT ANSWER Local values can be helpful to avoid _______ the same values/expressions multiple times in a configuration. If overused, they can actually make a configuration harder to read and therefore should be used in ________. functions CORRECT ANSWER The terraform language includes a number of built-in __________ that you can use to transform and combine values. Data Sources CORRECT ANSWER _________ _________ allow data to be fetched or computed for use elsewhere in terraform configurations. (I.e. retrieving latest AMI for a particular AWS region) TF_LOG CORRECT ANSWER Terraform has detailed logs which can be enabled by setting the __________________ environment variable to any value. TF_LOG_PATH CORRECT ANSWER To persist logged output, you can set the ______________________ in order to force the log to always be appended to a specific file when logging is enabled. fmt CORRECT ANSWER Use the "terraform _____" command to rewrite/adjust configuration files to remediate formatting and help with readability. validate CORRECT ANSWER Use the "terraform __________" command to check whether a configuration is syntactically valid (automatically run when you use "terraform plan") alphabetical CORRECT ANSWER Terraform generally loads all the configuration files within a directory specific in __________ order.

Dynamic Blocks CORRECT ANSWER D_________ B_________ allow you to dynamically construct repeatable nested blocks which is supported inside resource, data, provider, and provisioner blocks. Iterator, label CORRECT ANSWER The __________ argument (optional) sets the name of a temporary variable that represents the current element of the complex value. If omitted, the name of the iterator variable defaults to the _______ of the dynamic block. taint CORRECT ANSWER The "terraform _______" command manually makes a terraform-managed resource as tainted, forcing it to be destroyed and recreated on the next apply. Splat CORRECT ANSWER _______ Expressions allow you to get a list of all the attributes. i.e.: output "arns" { value = aws_iam_user.lb[*].arn } ^ will list all Arn's of every created IAM user graph CORRECT ANSWER the "terraform ________" command allows you to generate a visual representation of either a configuration or execution plan. (Requires graphviz to covert to .svg in order to view full visual representation). -out CORRECT ANSWER You can use the "terraform plan _______=path" flag to save your execution/plan to a specific path. This can then be referenced/used later with "terraform apply path" to ensure changes to the .tf file do not affect future plans (preserve current state of plan).

output CORRECT ANSWER "terraform ________" command is used to extract the value of an output variable from the state file. i.e. terraform __________ iam_names

[ "iamuser.0", "iamuser.1", "iamuser.2", ] configuration CORRECT ANSWER The special terraform ____________ block type is used to configure some behaviors of Terraform itself, such as requiring a minimum Terraform version to apply to your configuration. smaller CORRECT ANSWER To avoid API rate limits for providers when dealing with a large infrastructure, it is best practice to separate out to ___________ configurations where each component can be applied independently. -refresh=false CORRECT ANSWER You can prevent terraform from querying the current state during operations like terraform plan with the _________=_________ flag -target=resource CORRECT ANSWER Another way to prevent terraform from refreshing the state of your entire infrastructure is to use the targeted _________=___________ flag which will specify a specific target. tilde CORRECT ANSWER The ___ (~) means that resource will be updated in place (if you see this in your terraform plan)

Provisioners CORRECT ANSWER Terraform __________ are used to execute scripts on a local/remove machine as part of the resource creation or destruction process. (i.e. install apache after ec2 instance creation) local-exec CORRECT ANSWER _______-______ provisioners allow you to invoke local executable(s) after resource creation. These run on the machine that invoked the "terraform apply" and NOT on the newly created remote machine(s). remote-exec CORRECT ANSWER ________-_____ provisioners allow you to invoke scripts directly on the newly created remote server. creation CORRECT ANSWER __________-time provisioners only run during the creation, not during the update or any other lifecycle. tainted CORRECT ANSWER If a creation-time provisioner fails, the resource(s) affected is/are marked as ________ destroy CORRECT ANSWER __________-time provisioners are run before the resource is destroyed (i.e. uninstall antivirus agent) on-failure CORRECT ANSWER The ____-_________ setting/switch for provisioners allow you to change the default behavior of provisioner failures continue, fail CORRECT ANSWER The two switch options for on-failure setting within provisioners are: T CORRECT ANSWER T/F: By default, provisioners that fail will also cause terraform apply to fail itself

modules CORRECT ANSWER Terraform ___________ allow you to define commonly used infrastructure resources and reference those resources in a repeatable manner conforming to the DRY SWE principle. variables, default CORRECT ANSWER Within modules, you can set certain overridable resource attributes as _________. It is also important to define _______ values for any values you set. (i.e. instance type) static CORRECT ANSWER Within modules, you can prevent overriding of certain resource attributes by using ______ values for those attributes (i.e. ami ID of a hardened ami) Terraform Registry CORRECT ANSWER This is a repository of modules written by the Terraform Community. They help you get started quickly with Terraform. It also contained verified modules maintained by various third party vendors (i.e. GCP, Azure, IBM, AWS) Terraform Workspace CORRECT ANSWER This feature of terraform allows us to have multiple workspaces. Each workspace can have different sets fo environment variables defined for them (i.e. default/prod/dev) git CORRECT ANSWER To include any arbitrary Git repository within a module source, you must utilize the special ____ prefix. default, ref CORRECT ANSWER By default, terraform will use the _____ branch (references by HEAD) in the repository. You can overwrite this by using the ____ argument to reference other branches within your module source argument.

standard CORRECT ANSWER The ________ Backend type for storing your terraform .tfstate file supports state storage & locking. enhanced CORRECT ANSWER The _______ backend type supports all features of the standard backend type + remote state management. lock CORRECT ANSWER Whenever you are performing write operations, terraform will ______ the state file. corrupt CORRECT ANSWER If others are also trying to perform write operations on the same state file at the same time, this could _______ your state file (if no locking mechanism is in place) LockID CORRECT ANSWER To use a DynamoDB with S3 for implementing state locking, you must create a table with the primary key of _____________. never, directly CORRECT ANSWER As a general principle, you should ______ modify the terraform state file ______. list CORRECT ANSWER the "terraform state _____" command lists your resources within a tfstate file. mv CORRECT ANSWER the "terraform state ___" command is used to move items in a terraform state file. It is used in many cases where you want to rename an existing resource without destroying & recreating it. pull CORRECT ANSWER the "terraform state _____" command is used to manually download & output states from remote states

import CORRECT ANSWER The "terraform ________" command is very useful in the situation where a resource was manually created and you would like it to be managed by terraform. This requires the manual creation of the resource code block(s) before this command can be utilized. profile CORRECT ANSWER Instead of hard coding your secret/access key into the provider block, you can use the ______ assignment alias CORRECT ANSWER In order to use multiple providers (i.e. deploy to multiple regions), you must specify the _____ parameter in the providers block and reference this within your resource block(s). aws.north_cali CORRECT ANSWER What code snippet would I fill in here to reference the following specific Northern California provider alias in my resource block? // providers.tf provider "aws" { region = "us-west-1" alias = "north_cali" } // resource.tf resource "aws_eip" "myeip" { vpc = "true" provider = _____________________?

}

profiles CORRECT ANSWER Within the providers block, you can use a combination of aliases and multiple ________ in order to deploy resources to multiple regions/accounts. assume_role CORRECT ANSWER In order to avoid having to configure multiple access/secret keys for different accounts within your provider, you can simply utilize the a________r________ block and subsequent parameters within the provider. This coupled with aliases provide you a way to deploy to multiple regions/accounts without having to manage multiple sets of credentials. sensitive CORRECT ANSWER When working with a field that contains information likely to be considered sensitive, it is best to set the _________ property on its schema to true. T CORRECT ANSWER T/F: Setting the "sensitive = true" property within a schema does NOT encrypt/obscure the value. It will only hide it from showing up in the CLI output. Terraform Cloud CORRECT ANSWER ___________ __________ managed Terraform runs in a consistent & reliable environment. It extends the features of Terraform CLI with a self-service SaaS platform. It allows for remote Terraform functionality from a web GUI that is perfect for collaboration across a DevOps team. Sentinel CORRECT ANSWER An embedded policy-as-code framework integrated with Hashicorp Enterprise products. It enabled fine-grained, logic-based policy decisions and can be extended to use information from external sources.

zipmap CORRECT ANSWER The _________ function constructs a map from a list of keys & and corresponding list of values. (Very useful for combining values for outputs into a map that can later be used i.e. IAM Name to ARN init -upgrade CORRECT ANSWER you can run the "terraform _______ _______" command to upgrade your provider(s) to the latest acceptable version. inside, last CORRECT ANSWER Provisioners are located ________ a resource block. Additionally, they should only be used as a _______ resort. Often times there are better methods to install applications/software (i.e. custom AMI). multiple CORRECT ANSWER The advantages of Terraform Workspaces is that it allows _______ state files for a single configuration. It also allows different environment variable sets for each workspace. T CORRECT ANSWER T/F: A module can call other modules to include the child module's resources in a concise way. Namespace, Name, Provider CORRECT ANSWER Terraform Module sources follows the following format: ________/________/_________? F (you can define local values and output them -- no need for provider here since no resources are being instantiated) CORRECT ANSWER Provider configuration block IS mandatory for all terraform configurations. Automation, reusability, versioning CORRECT ANSWER Name 3 benefits of IaC:

Does CORRECT ANSWER Terraform refresh ________ modify the configuration's state file but does NOT modify resources. not CORRECT ANSWER The Slice Function is ______ part of the String subset of Terraform functions. environment, TF_VAR_name CORRECT ANSWER In additionally to variables.tf and terraform.tfvars for defining variables, you can also utilize ____________ variables by setting the __________________. object, list CORRECT ANSWER _________ structural data type allows multiple values of several distinct types together. Conversely, _______ contains multiple values of the SAME type. directly, initialized CORRECT ANSWER Backends are configured __________ in Terraform files in the terraform section. After configuring a backend, it must be


Partial CORRECT ANSWER A _________ time configuration for backends may be suitable where omitting certain configuration details are beneficial to protecting sensitive data (i.e. secret keys) but must be provided during the initializing process to Terraform. ssh, winrm CORRECT ANSWER The remote-exec provisioner supports which two connection types for connecting to machines to execute commands? last CORRECT ANSWER If the same variable defined in Terraform is assigned multiple values, Terraform uses the _______ value it finds.

var.ami_ids["mumbai"] CORRECT ANSWER Within the defined map structure below, provide the line of code that will allow you to reference the "mumbai" AMI ID: //variables.tf variable "ami_ids" { type = "map" default = { "mumbai" = "ami-409sdfj24093" "north_virginia" = "ami-sj39sdfj93" "south_america" = "ami-dio39j390393" } } strong CORRECT ANSWER Terraform workspaces are not suitable for ________ isolation between desired configuration environment (i.e. dev/prod) implicit CORRECT ANSWER With ________ dependency, Terraform automatically can order resource creation based on one resource using the attribute of another resource. i.e. // example.tf resource "aws_instance" "myec2" { instance_type = "blah" public_ip = aws_eip.myeip.private_ip // HERE }

explicit CORRECT ANSWER With ________ dependency, you can use the depends_on argument to explicitly tell Terraform one resource must be created before another when it does not utilize the attribute of another resource. i.e. // example.tf resource "aws_instance" "myec2" { instance_type = "blah" depends_on = [aws_s3_bucket.mybucket] // HERE } air CORRECT ANSWER If terraform needs to be installed in an environment without internet access, the installation is referred to as ____-gapped T CORRECT ANSWER T/F: Local values can reference other local values T CORRECT ANSWER T/F: Terraform automatically converts number and bool values to strings when needed. Slice CORRECT ANSWER What of function is NOT part of string functions in terraform? proactive CORRECT ANSWER Sentinel is a _________ service. HCL, JSON CORRECT ANSWER Which configurations formats are supported by terraform?

inline CORRECT ANSWER What command does the remote-exec provisioner use to provide commands for the remote server? Go CORRECT ANSWER There has been an open issue related to Terraform. You have figured out a solution and would like to add a fix to the terraform project. Which language you will need to write the fix?