Terraform Basics Flashcards

1
Q

The core Terraform workflow consists of three stages:

A

Write
Plan
Apply

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

The write stage of the Terraform Workflow

A

First Step in the workflow.

Define infra in config files

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

The Review stage of the Terraform workflow

A

2nd stage in workflow after Write

Review the changes Terraform will make to your infra

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

The Apply stage in the workflow

A

Final stage in the workflow

Terraform provisions your infra and updates the state file

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

State File

A

Keeps track of your infrastructure.

Used to determined the changes to make to your infra.

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

Modules

A

Reusable configuration components called modules that define configurable collections of infra.

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

To deploy infrastructure with Terraform (5 Steps):

A

Scope - Identify the infrastructure for your project.
Author - Write the configuration for your infrastructure.
Initialize - Install the plugins Terraform needs to manage the infrastructure.
Plan - Preview the changes Terraform will make to match your configuration.
Apply - Make the planned changes.

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

Configuration file: The Terraform Block

A

terraform {} block contains Terraform settings, including the required providers Terraform will use to provision your infrastructure.

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

Configuration File: The provider block

A

The provider block configures the specified provider

A provider is a plugin that Terraform uses to create and manage your resources. You can define multiple provider blocks in a Terraform configuration to manage resources from different providers.

provider “azurerm” {
features {}
}

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

Configuration File: Resources Block

A

Use resource blocks to define components of your infrastructure.

Resource blocks have two strings before the block: the resource type and the resource name.

Together, the resource type and resource name form a unique ID for the resource.

resource “azurerm_resource_group” “rg” {
name = “myTFResourceGroup”
location = “westus2”
}

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

Terraform State

A

Terraform must store state about your managed infrastructure and configuration.

This state is stored by default in a local file named “terraform.tfstate”, but it can also be stored remotely, which works better in a team environment.

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

What “Day 0” and “Day 1” activities?

A

“Day 0” code provisions and configures your initial infrastructure.

“Day 1” refers to OS and application configurations you apply after you’ve initially built your infrastructure.

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

What are providers?

A

A provider is a plugin that Terraform uses to translate the API interactions with the service. A provider is responsible for understanding API interactions and exposing resources.

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

How to configure a provider?

A

With a provider block

provider “google” {
project = “acme-app”
region = “us-central1”
}

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

meta-arguments defined by Terraform and available for all provider blocks?

A

version: Constraining the allowed provider versions
alias: using the same provider with different configurations for different resources

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

What happens during provider initialization?

A

Terraform downloads and installs the plugin so that it can later be executed.

17
Q

How to initialize any provider?

A

terraform init

18
Q

how to configure multiple provider instances?

A

alias

You can optionally define multiple configurations for the same provider, and select which one to use on a per-resource or per-module basis.

# The default provider configuration
provider "aws" {
  region = "us-east-1"
}
# Additional provider configuration for west coast region
provider "aws" {
  alias  = "west"
  region = "us-west-2"
}
19
Q

Alternate providers have been defined using alias, how to specify which provider to resources?

A

by default, resources infer the provider from resource id.

use provider argument to override

resource “aws_instance” “foo” {
provider = aws.west

  # ...
}
20
Q

Installing third party plugins

A

Cannot be installed using terraform init.

Must be manually installed

21
Q

Provider naming scheme

A

terraform-provider-[NAME]_vX.Y.Z