Exam Prep v2 Flashcards

Skillcertpro

1
Q

How to taint the resource of a child module?
Ex: Parent Module == foo
Child Module == bar

A

terraform taint module.foo.module.bar.aws_instance.qux

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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?

A

Locals block.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What operating systems are supported by Terraform?

A

Linux distributions (Debian, ubuntu,centOS)
macOS (Darwin)
Windows
Solaris
FreeBSD
OpenBSD

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Hashicorp recommends how many spaces fore each nesting level?

A

2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How are environment variables set on the command line?

A

TF_VAR_name
Ex. export TF_VAR_region=us-west-1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Does HCP Terraform/Terraform Enterprise install provers as part of every run?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which command is u sed to get a human-friendly output of the resources contained in your state?

A

terraform show

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What source types can be considered while providing source arguments in module block?

A

Local paths
Terraform registry
Github
Bitbucket
HTTP URL’s
S3 buckets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Is Terraform a configuration management tool?

A

No, its an IaC tool.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What two use cases does terraform mv do?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Regarding module meta arguments, if your instances are almost identical, does the count need to be used?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What function is used to explicitly convert a list of integers to a set?

A

toset

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Is it true that a child module can use outputs to expose a subset of its resources to a parent module?

A

Yes, think of outputs as the “return values” of a TF module, enabling info to flow from a child back to its parent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Is it true that a parent module can reference that result using the expression module.<MODULE_NAME>. <output_name>?</output_name></MODULE_NAME>

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How to load custom tfvars file as an input variable during terraform apply?

A

terraform apply -var-file=”name.tfvars”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Can you mix/match creation and destruction provisioners in the same file?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Whats true w.r to storing sensitive data in a remote locaiton?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Can you enable logging separately for Terraform itself?

A

Yes, you’d use the command

export TF_LOG_CORE=TRACE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Can you enable logging separately for the provider plugins?

A

Yes, you’d use the command

export TF_LOG_PROVIDER=TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Are modules containers for multiple resources that are used together?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Does a module consist of a collection of .tf and/or .tf.json files kept together in a directory?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Are modules the main way to package and reuse resource configs w/TF?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What are the different planning modes available in TF?

A
  1. Destroy mode (-destroy) - plan to destroy all remote objects
  2. Refresh only (-refresh-only) - to update TF state/root module output values
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

How to disable state lock during operation?

A

-lock=false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Most resource types in different providers do not support the timeouts block at all?

A

False, while its true some resource types in diff providers might not support the timeout block, many do.

27
Q

What is the timeout block?

A

Its a common feature that alows you to specific time limits for various operations, such as creating, updating, and deleting resources.

28
Q

Whats the benefits of the timeout block?

A
  1. Prevent long-running operations
  2. Improve reliability
  3. Increase efficiency
29
Q

Can a remote backend work with multiple similarily-named remote workspace?

A

False, a remote backend in TF can only work with a single remote TF Cloud workspace.

30
Q

Does the child module inherit all of the default provider configs from the parent module if it doesn’t declare any configuration aliases?

31
Q

Does TF Cloud Agents allow TF CLoud to communicate with isolated, private, or on-prem infra?

32
Q

While logging into TF Cloud, TF will store the API token in plain text in which file?

A

/users/username/.terraform.d/credentials.tfrc.json

33
Q

Can a map (or larger object) be converted to an object if it has at least the keys required by the object schema?

A

Yes.

Any extra keys in the map are discarded during the conversion.

34
Q

What are objects within Terraform?

A

Objects are like structured maps with a defined schema, while maps are more flexible with any key-value pair.

35
Q

Can a list be converted to a tuple?

A

Yes, only if it has exactly the required number of elements

36
Q

What is a tuple?

A

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.

37
Q

What are the frequent use cases of TF as IaC?

A
  1. Multi-tier application setup
  2. Self-service clusters
  3. Software demos
  4. Easily disposable environments
  5. Software-defined networking
  6. Resource schedulers
38
Q

How do you update a specific module in TF?

A

terraform get -update Modulepath

39
Q

What are some potential issues you will encounter when debugging TF?

A

Issues with syntax errors
state synchronization
terraform core
provider authentication, provider errors
dependency issues
resource conflicts

40
Q

What is the syntax for specifying a private registry module?

A

///

<HOSTNAME>/<NAMESPACE>/<NAME>/<PROVIDER>.

Hostname = hostname of public TF registry
Namespace = organizational namespace w/in specific registry (Ex. Hashicorp)
</PROVIDER></NAME></NAMESPACE></HOSTNAME>

41
Q

How do remote backends perform API operations?

A

Remotely, using TF Cloud or TF Enterprise.

42
Q

How to authenticate with TF Cloud using CLI?

A

terraform login

43
Q

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?

A

TF 0.14 or later.

Earlier version dont do it automatically.

44
Q

Whats the correct way to declare input values through ENV variables in TF?

A

export TF_VAR_image_id=ami-abc123

45
Q

What are the features of TF Cloud Business accounts?

A
  1. Team Mgmt & Governance
  2. Advanced Sec, Compliance, and Governance
  3. Self-service infra
  4. Additional concurrent runs
46
Q

How to pass variable definitions (testing.tfvars) files as input during TF apply?

A

terraform apply -var-file=”testing.tfvars”

47
Q

What are the problems of using resource tags instead of state files?

A
  1. Not all resources support tags
  2. Not all cloud providers support tags.
48
Q

What’s the resource address for a for_each element if the resource is aws_instance “Bryan-demo”

A

aws_instance.bryan-demo[“vault”]

49
Q

Is float a valid variable type?

50
Q

Is GitHub a supported backend type?

51
Q

In TF Cloud, are TF creds/secrets stored inside the workspace as sensitive variables?

A

Yes, they are marked as such in the UI and not directly viewable by users, ensuring confidentiality.

52
Q

Do default arguments require a literal value and cannot reference other objects in the config?

53
Q

How to specify arbitrary custom validation rules for a particular variable in TF?

A

Use a validation block nested within the corresponding condition argument?

54
Q

What will happen if you use a sensitive variable inside a nested block in TF?

A

Terraform may treat the entire block as redacted and its contents will not be displayed.

55
Q

Where does Terraform Open Source (OSS) store the local state for workspaces?

A

Dictory called terraform.tfstate.d/

56
Q

How to create a new workspace?

A

Terraform workspace new

57
Q

Whats a module that includes a module block?

A

Calling Module

58
Q

What is the purpose of using the local-exec provisioner?

A
  1. to execute one or more commands on the machine running Terraform
  2. to invoke a local executable
59
Q

When using Terraform workpaces does each one use a different Terraform backend?

A

No, you’re essentially using the same TF config files, therefore the backend will remain the same for all of your workspaces.

60
Q

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?

A

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.

61
Q

In Terraform OSS, workspaces generally use the same code repository while workspaces in Terraform Enterprise/Cloud are often mapped to different code repositories.

62
Q

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?

A

terraform init -migrate-state

63
Q

Are variables declared inside of a module able to be referenced outside that module directly?

A

No, you can however create an output in the module to export any values that might be needed outside the module.

64
Q

When working with variables in TF, will the variable name or description be fond in the state file?

A

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