Basic Terrafom usage Flashcards

1
Q

**

What is the purpose of the terraform init command?

A

The terraform init command initializes a Terraform project, downloading necessary plugins and setting up the backend for storing the state file.

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

What does the terraform plan command do?

A

The terraform plan command compares the desired state defined in the Terraform configuration with the current state of the infrastructure. It generates an execution plan, outlining the actions needed to achieve the desired state.

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

What is the purpose of the terraform apply command?

A

The terraform apply command executes the actions specified in the plan generated by Terraform. It makes the necessary changes to provision or modify the infrastructure based on the desired state.

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

How does the terraform destroy command work?

A

The terraform destroy command removes all the resources provisioned by Terraform, effectively tearing down the infrastructure defined in the Terraform configuration.

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

What is the state file in Terraform?

A

The state file is Terraform’s representation of the current state of the infrastructure. It contains information about every resource and data object managed by Terraform and serves as the source of truth for tracking the infrastructure state.

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

What are the differences between local and remote backend for the Terraform state file?

A

Local Backend: The state file is stored locally on the machine where Terraform is executed. It offers easy setup and accessibility but lacks collaboration features and can be prone to loss or corruption.
Remote Backend: The state file is stored remotely, enabling enhanced collaboration, version control, and auditability. It requires setup and configuration but offers benefits like better integrity and scalability.

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

What does the terraform plan command do?

A

The terraform plan command compares the desired state defined in the Terraform configuration with the current state of the infrastructure. It generates an execution plan, outlining the actions needed to reach the desired state.

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

What does the terraform apply command do?

A

The terraform apply command executes the actions specified in the plan generated by Terraform. It makes the necessary changes to provision or modify the infrastructure based on the desired state.

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

How does Terraform utilize AWS for remote backend?

A

Terraform can store the state file in an AWS S3 bucket and use DynamoDB for state locking. This provides durability, availability, and locking mechanisms for managing the Terraform state in a collaborative environment.

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

Why is the state file important in Terraform?

A

The state file is important because it serves as Terraform’s source of truth for tracking the current state of the infrastructure. It contains information about provisioned resources, dependencies, and attributes.

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

What are the benefits of using a remote backend for the Terraform state file?

A

Enhanced collaboration: A remote backend allows multiple team members to access and manage the state file concurrently.
Version control: The state file can be versioned and stored in a version control system for tracking changes over time.
Improved security: A remote backend can provide secure storage for sensitive information, such as database passwords.
Scalability: Remote backends typically offer scalable storage solutions suitable for larger infrastructure deployments.

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

Can multiple Terraform runs modify the state file simultaneously with a remote backend?

A

No, a remote backend typically uses a locking mechanism to ensure that only one Terraform run can modify the state file at a time. This prevents conflicts and data corruption in collaborative environments.

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

What is Terraform Cloud?

A

Terraform Cloud is a remote backend and collaboration platform provided by HashiCorp. It offers features such as remote state storage, version control integration, and workspace management for managing Terraform deployments.

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

How does Terraform integrate with AWS for the remote backend?

A

Terraform can use an S3 bucket in AWS for storing the state file. This provides durability and availability for the state file. Additionally, DynamoDB can be utilized for state locking to ensure exclusive access during Terraform runs.

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

What are some common challenges when managing the state file locally?

A

Lack of collaboration: It can be difficult for multiple team members to access and manage the state file simultaneously.
Risk of loss or corruption: If the local machine or storage becomes inaccessible or corrupted, the state file may be lost, leading to potential inconsistencies in infrastructure management.

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

How can remote backends help with infrastructure management in a distributed team?

A

Remote backends provide a centralized location for storing and accessing the state file, allowing team members from different locations to collaborate on infrastructure management seamlessly.

17
Q

Can Terraform work without a state file?

A

No, Terraform requires a state file to manage infrastructure. The state file tracks the current state of the infrastructure and is used for planning, applying changes, and tracking resource dependencies.