Basic Flashcards
Installation of Terraform
- Download Terraform binaries
- Set path
- Run command: terraform -version
Is Terraform a functional language?
No, it’s an declarative language
What is “main.tf”? Where should we put this file?
This is main file from which Terraform starts it’s execution. It’s location should be “root” folder.
What is the “general” syntax of any Terraform object?
… {}
How to mention the provider in terraform?
It should be mentioned inside the “main.tf” file.
provider “aws” {
region = “ap-south-1”
}
What is the “general” syntax of “resource” object?
resource { }
How arguments are named inside any object?
It is named as “key-value” pair. The name should be all small and “snake-case”.
my_attrbute = “value”
How to create instance via Terraform
resource "aws_instance" "myInstance" { ami = "asaas" instance_type = "t2.micro" vpc_security_group_ids = [ "id1", "id2"] user_data = "heredoc" tags = { name = "test" } }
What are different terraform files we should ignore from being pushing to source code?
.terraform
.tfstate
.tfstate.backup
How to use “heredoc” inside the terraform?
user_data =
How to create a security group resource in terraform?
resource "aws_security_group" "instance" { name = "mySecurityGroup" ingress = { from_port = 8080 to_port = 8080 protocol = "tcp" cidr_block = [ "0.0.0.0/0"] } }
What is interpolation syntax used in Terraform?
inside double quote and starting with $
“${}
What is the general syntax of interpolation syntax in Terraform?
”${resourceType.resourceName.resourceAttribute}”
What is the general syntax of variable object?
variable {
configs..[]
}
What are the different config parameters which we can use inside the variable object?
- description
- type
- default
Are config arguments of variable object mandatory?
No, those are all optional.