Mid-Senior Level Questions Flashcards

1
Q

Q: What is the purpose of Terraform in the context of infrastructure as code (IaC)?

A

Terraform is a tool used for provisioning and managing infrastructure resources through code. It allows you to define and deploy infrastructure in a declarative manner, making it easier to manage and scale your infrastructure.

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

How does Terraform handle state management?

A

Terraform uses a state file to store the current state of your infrastructure. This state file tracks the resources that Terraform manages, allowing it to plan and execute changes efficiently.

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

How can you authenticate Terraform to interact with AWS resources?

A

Terraform can authenticate with AWS using access keys

You can configure the AWS CLI or provide the keys directly in your Terraform configuration using environment variables or the aws provider block.

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

How can you create an EC2 instance using Terraform with AWS provider?

A

To create an EC2 instance using Terraform, you can define a resource block of type aws_instance in your Terraform configuration file. Within this block, you specify the desired attributes of the EC2 instance, such as the instance type, AMI ID, security groups, and key pair. When you apply the configuration, Terraform will provision the EC2 instance based on the defined specifications.

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

What happens when you run the Terraform plan command?

A

Terraform analyzes your configuration files and compares it with the current state to determine what changes will be applied.

Then provides an execution plan of the resources that will be created, modified, or deleted without actually executing those changes.

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

What are modules in Terraform?

A

Modules are Terraform configuration that can be used multiple times across different projects. They can define a set of resources, inputs, and outputs, providing a way to abstract and reuse common infrastructure patterns.

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

What are some options for managing remote state backend in Terraform?

A

Terraform supports remote state management using various backends, such as AWS S3 & DynamoDB(Statelock), or Terraform Cloud

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

What are the benefits of a remote state backend? 3

A

By storing the state file remotely, you enable collaboration, versioning, and secure access to the state.

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

How is remote state backend configured?

A

Remote state is accessed using a backend configuration in your Terraform configuration files.

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

How can you manage infrastructure across multiple environments (e.g., development, staging, production) using Terraform?

A

You can use Terraform workspaces to manage infrastructure across different environments.

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

Explain how TF workspaces work?

A

Each workspace represents a separate instance of your infrastructure, allowing you to switch between environments and maintain separate state files and configuration.

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

What is the purpose of Terraform data sources?

A

Terraform data sources allow you to retrieve information about existing resources outside of the current Terraform configuration.

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

What are Terraform provisioners, and when are they used?

A

Terraform provisioners are used to execute actions or scripts on a local or remote machine after a resource is created or updated.

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

How can you leverage AWS services to manage secrets and sensitive data in Terraform when working with AWS services?

A

You can leverage AWS services like Secrets Manager or Parameter Store to store and manage secrets and sensitive data.

Terraform can then retrieve the values from these services during provisioning, ensuring secure storage and access to sensitive information

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

What are two command that you can use to ensure the correctness and integrity of Terraform configurations before applying them?.

A

You can use the terraform validate command to check the syntax and validate the correctness of your Terraform configurations.

terraform fmt can be used for aligning and formatting, to ensure adherence to best practices

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

How can you manage version control and collaboration when working with Terraform? 3

A

By storing your Terraform code in a Git repository, you can
-Track changes
-Create branches for different features, and
-Facilitate collaborative development and code reviews.

17
Q

What are some best practices for securing Terraform code and infrastructure configurations? 4

A

Implementing version control to track changes and ensure accountability.
updating and patching Terraform and its dependencies to address security vulnerabilities.
Applying least privilege principles to limit the permissions granted to Terraform accounts.
Regularly reviewing and scanning Terraform code for security flaws or misconfigurations.

18
Q

How to create and switch TF workspaces:

A

Create a new workspace:

terraform workspace new <workspace-name>

Switch to a specific workspace:

terraform workspace select <workspace-name>
19
Q

How to list and delete TF workspaces:

A

List available workspaces:

terraform workspace list
Destroy a workspace:

terraform workspace delete <workspace-name>

20
Q

What type of tasks is TF provisioners used for? 3

A

They are typically used for tasks such as software installation, configuration management, or running custom scripts during the provisioning process