Exam Prep v2 Flashcards
Skillcertpro
How to taint the resource of a child module?
Ex: Parent Module == foo
Child Module == bar
terraform taint module.foo.module.bar.aws_instance.qux
Which config block assigns a name to an expression that can be used multiple times w/in a module w/out having to repeat it?
Locals block.
What operating systems are supported by Terraform?
Linux distributions (Debian, ubuntu,centOS)
macOS (Darwin)
Windows
Solaris
FreeBSD
OpenBSD
Hashicorp recommends how many spaces fore each nesting level?
2
How are environment variables set on the command line?
TF_VAR_name
Ex. export TF_VAR_region=us-west-1
Does HCP Terraform/Terraform Enterprise install provers as part of every run?
Yes
Which command is u sed to get a human-friendly output of the resources contained in your state?
terraform show
What source types can be considered while providing source arguments in module block?
Local paths
Terraform registry
Github
Bitbucket
HTTP URL’s
S3 buckets
Is Terraform a configuration management tool?
No, its an IaC tool.
What two use cases does terraform mv do?
It can move resources from one state file to another and also rename resources.
terraform state mv -state-out=../terraform.tfstate aws_instance.example_new aws_instance.example_new
Regarding module meta arguments, if your instances are almost identical, does the count need to be used?
Yes
Regarding module meta arguments, if your instance arguments need distinct values that cant be directly derived from an integer, is it safer to use a for_each?
Yes
What function is used to explicitly convert a list of integers to a set?
toset
Is it true that a child module can use outputs to expose a subset of its resources to a parent module?
Yes, think of outputs as the “return values” of a TF module, enabling info to flow from a child back to its parent.
Is it true that a parent module can reference that result using the expression module.<MODULE_NAME>. <output_name>?</output_name></MODULE_NAME>
Yes,
the module_name is the name given to the child module instance and the output_name is the name of the output variable declared in the child module.
How to load custom tfvars file as an input variable during terraform apply?
terraform apply -var-file=”name.tfvars”
Can you mix/match creation and destruction provisioners in the same file?
Yes
Whats true w.r to storing sensitive data in a remote locaiton?
TF Cloud always encrypts state at rest and protects w/TLS in transit.
TF Enterprise also supports detailed audit logging
TF CLoud knows the identity of the user requesting state and maintains a history of state changes.
Can you enable logging separately for Terraform itself?
Yes, you’d use the command
export TF_LOG_CORE=TRACE
Can you enable logging separately for the provider plugins?
Yes, you’d use the command
export TF_LOG_PROVIDER=TRUE
Are modules containers for multiple resources that are used together?
Yes
Does a module consist of a collection of .tf and/or .tf.json files kept together in a directory?
Yes
Are modules the main way to package and reuse resource configs w/TF?
Yes
What are the different planning modes available in TF?
- Destroy mode (-destroy) - plan to destroy all remote objects
- Refresh only (-refresh-only) - to update TF state/root module output values
How to disable state lock during operation?
-lock=false
Most resource types in different providers do not support the timeouts block at all?
False, while its true some resource types in diff providers might not support the timeout block, many do.
What is the timeout block?
Its a common feature that alows you to specific time limits for various operations, such as creating, updating, and deleting resources.
Whats the benefits of the timeout block?
- Prevent long-running operations
- Improve reliability
- Increase efficiency
Can a remote backend work with multiple similarily-named remote workspace?
False, a remote backend in TF can only work with a single remote TF Cloud workspace.
Does the child module inherit all of the default provider configs from the parent module if it doesn’t declare any configuration aliases?
Yes
Does TF Cloud Agents allow TF CLoud to communicate with isolated, private, or on-prem infra?
Yes
While logging into TF Cloud, TF will store the API token in plain text in which file?
/users/username/.terraform.d/credentials.tfrc.json
Can a map (or larger object) be converted to an object if it has at least the keys required by the object schema?
Yes.
Any extra keys in the map are discarded during the conversion.
What are objects within Terraform?
Objects are like structured maps with a defined schema, while maps are more flexible with any key-value pair.
Can a list be converted to a tuple?
Yes, only if it has exactly the required number of elements
What is a tuple?
A tupe represented as tuple([type1, type2..]), specifying the types of elements in a fixed sequence. They are used when you have a fixed # of elements that may have different types while lists are elements of the same type.
What are the frequent use cases of TF as IaC?
- Multi-tier application setup
- Self-service clusters
- Software demos
- Easily disposable environments
- Software-defined networking
- Resource schedulers
How do you update a specific module in TF?
terraform get -update Modulepath
What are some potential issues you will encounter when debugging TF?
Issues with syntax errors
state synchronization
terraform core
provider authentication, provider errors
dependency issues
resource conflicts
What is the syntax for specifying a private registry module?
///
<HOSTNAME>/<NAMESPACE>/<NAME>/<PROVIDER>.
Hostname = hostname of public TF registry
Namespace = organizational namespace w/in specific registry (Ex. Hashicorp)
</PROVIDER></NAME></NAMESPACE></HOSTNAME>
How do remote backends perform API operations?
Remotely, using TF Cloud or TF Enterprise.
How to authenticate with TF Cloud using CLI?
terraform login
TF will generate a new .terraform.lock.hcl file in the CWD when you intitialize a TF config for the first time for what TF version?
TF 0.14 or later.
Earlier version dont do it automatically.
Whats the correct way to declare input values through ENV variables in TF?
export TF_VAR_image_id=ami-abc123
What are the features of TF Cloud Business accounts?
- Team Mgmt & Governance
- Advanced Sec, Compliance, and Governance
- Self-service infra
- Additional concurrent runs
How to pass variable definitions (testing.tfvars) files as input during TF apply?
terraform apply -var-file=”testing.tfvars”
What are the problems of using resource tags instead of state files?
- Not all resources support tags
- Not all cloud providers support tags.
What’s the resource address for a for_each element if the resource is aws_instance “Bryan-demo”
aws_instance.bryan-demo[“vault”]
Is float a valid variable type?
No
Is GitHub a supported backend type?
No
In TF Cloud, are TF creds/secrets stored inside the workspace as sensitive variables?
Yes, they are marked as such in the UI and not directly viewable by users, ensuring confidentiality.
Do default arguments require a literal value and cannot reference other objects in the config?
Yes
How to specify arbitrary custom validation rules for a particular variable in TF?
Use a validation block nested within the corresponding condition argument?
What will happen if you use a sensitive variable inside a nested block in TF?
Terraform may treat the entire block as redacted and its contents will not be displayed.
Where does Terraform Open Source (OSS) store the local state for workspaces?
Dictory called terraform.tfstate.d/
How to create a new workspace?
Terraform workspace new
Whats a module that includes a module block?
Calling Module
What is the purpose of using the local-exec provisioner?
- to execute one or more commands on the machine running Terraform
- to invoke a local executable
When using Terraform workpaces does each one use a different Terraform backend?
No, you’re essentially using the same TF config files, therefore the backend will remain the same for all of your workspaces.
What can you do to provide a “friendly name” for the DNS of a new web server so you can simply click the CLI output and access a website IF you are using modules?
Add some code to the parent/calling module.
value = “https://${aws_instance.web.public_dns}:8080/index.html“
Output blocks of a module won’t show up in the CLI output and can’t be used for this purpose.
In Terraform OSS, workspaces generally use the same code repository while workspaces in Terraform Enterprise/Cloud are often mapped to different code repositories.
True
What commands should be run in order to complete a state migration from local to Amazon S3 while copying the existing state to the new backend?
terraform init -migrate-state
Are variables declared inside of a module able to be referenced outside that module directly?
No, you can however create an output in the module to export any values that might be needed outside the module.
When working with variables in TF, will the variable name or description be fond in the state file?
No, they are simply used on the dev side of TF and not on the backend operational aspect of how TF works.
However, the value that is used in the TF config will be stored in the state file