Beginner Terraform test (Beginner)
25 questions · 30 minutes · Free
Providers, resources, variables and the plan/apply workflow.
Take the Beginner Terraform test
What it covers
- Providers and resources
- Variables and outputs
- plan and apply
- State basics
- HCL syntax
Interview format
- Questions: 25 questions — 15 multiple choice, 10 multi-answer
- Time: 30 minutes, timed from the first question
- Difficulty: Beginner
- Skill area: DevOps & cloud
- Price: Free
Earn a certificate
The Beginner Terraform test is one of the 7 tests of the DevOps Engineer learning path. Pass it and the other 6 tests at 70% or more and readyforhires issues you a verifiable certificate in your name, with its own code and verify link to share or add to LinkedIn.
Sample questions
5 sample questions from the Beginner Terraform test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.
What will happen when the following Terraform code is executed? `resource "aws_s3_bucket" "example" { value = "test" }`
- The resource will be created with the name 'example' and the attribute 'value' set to 'test' and the provider 'aws' will be configured with region 'ap-south-1'.
- The resource will be created with the name 'example' and the attribute 'value' set to 'test' and the provider 'aws' will be configured with region 'us-east-1'.
- The resource will not be created because the provider is not configured.
- The resource will be created with the name 'example' and the attribute 'value' set to 'test'.
Answer: D. The resource will be created with the name 'example' and the attribute 'value' set to 'test'.
The resource block `resource "aws_s3_bucket" "example" { value = "test" }` correctly creates an AWS S3 bucket with the local name 'example' and the attribute 'value' set to 'test'. The other options contain syntax errors or incorrect usage of HCL.
Which of the following correctly uses HCL string interpolation to construct a bucket name for an AWS S3 bucket using a variable named 'env'?
- aws_s3_bucket.example.bucket = var.env + "-logs"
- aws_s3_bucket.example.bucket = var.env.logs
- aws_s3_bucket.example.bucket = var.env - logs
- aws_s3_bucket.example.bucket = "${var.env}-logs"
Answer: D. aws_s3_bucket.example.bucket = "${var.env}-logs"
In Terraform HCL, string interpolation is done using the ${} syntax. This allows variables to be inserted into strings, making it possible to dynamically construct values such as resource names or other attributes. The correct option demonstrates this with the use of ${var.env} inside the string.
Which of the following statements correctly describes the difference between the provider block and the required_providers block in Terraform?
- The provider block is used to configure the endpoint details for the provider, such as region or authentication credentials, while the required_providers block is used to declare the provider and its version constraints.
- The provider block is used to declare the provider and its version constraints, while the required_providers block is used to configure the endpoint details for the provider, such as region or authentication credentials.
- Both the provider block and the required_providers block are used to configure the endpoint details for the provider, such as region or authentication credentials.
- Both the provider block and the required_providers block are used to declare the provider and its version constraints.
Answer: A. The provider block is used to configure the endpoint details for the provider, such as region or authentication credentials, while the required_providers block is used to declare the provider and its version constraints.
The provider block is used to configure the endpoint details for the provider, such as region or authentication credentials, while the required_providers block is used to declare the provider and its version constraints. The required_providers block does not contain endpoint configuration details. The provider block is used to configure the provider's endpoint details, and the required_providers block is used to declare the provider and its version constraints.
Which of the following is the correct HCL syntax for defining a list containing the elements 'apple', 'banana', and 'cherry'?
- list = (apple, banana, cherry)
- list = { apple, banana, cherry }
- list = ["apple", "banana", "cherry"]
- list = apple, banana, cherry
Answer: C. list = ["apple", "banana", "cherry"]
In HCL, a list is defined using square brackets [ ] with elements separated by commas. The correct syntax for a list is to enclose the elements in square brackets and use quotes around string values. The other options either use incorrect syntax or do not represent a list structure.
Which of the following is a best practice for Terraform state file backup?
- Terraform state files should only be backed up after applying changes to the infrastructure.
- Terraform state files should be backed up regularly to prevent data loss in case of accidental deletion or corruption.
- Terraform state files should never be backed up as they are automatically managed by Terraform.
- Terraform state files should be backed up only if the infrastructure is complex.
Answer: B. Terraform state files should be backed up regularly to prevent data loss in case of accidental deletion or corruption.
State files contain critical information about the infrastructure managed by Terraform. Backing them up regularly ensures that if the state file is lost or corrupted, it can be recovered, minimizing the risk of infrastructure misconfiguration or data loss. Other options may be misleading or not directly related to the best practice of state file backup.
Frequently asked questions
- How many questions are in the Beginner Terraform test?
- 25 questions (15 multiple choice, 10 multi-answer), with 30 minutes to answer them.
- What does the Beginner Terraform test cover?
- Providers and resources, Variables and outputs, plan and apply, State basics, HCL syntax.
- Is the Beginner Terraform test free?
- Yes. It is free to take with a readyforhires account.
- What level is the Beginner Terraform test?
- Beginner, in DevOps & cloud.