Infrastructure as Code (IaC)-Concepts
Infrastructure as Code (IaC) is an approach to managing and provisioning IT infrastructure through code.
---
shuffleAnswers: true
shuffleQuestions: true
nQuestions: 25
introduction: >
--- # When multiple team members are working on the same state file, the state file gets locked, how to remove the lock? 1. [x] terraform force-unlock LOCK_ID 1. [ ] terraform force-unlock STATE_FILE 1. [ ] terraform unlock LOCK_ID 1. [ ] terraform force-unlock=true # Which of the following command can be used to syntactically check to terraform configuration before using apply or plan command? 1. [ ] terraform fmt 1. [x] terraform validate 1. [ ] terraform show 1. [ ] terraform check # Which among the following are not module source options? 1. [ ] Local Path 1. [ ] Terraform registry 1. [ ] Bit bucket 1. [ ] HTTP URLs 1. [x] BLOB storage # Which among the following log command should be set to get Maximum verbosity of terraform logs? 1. [ ] set the TF_LOG=DEBUG in environment variable 1. [ ] set the TF_LOG=INFO in environment variable 1. [x] set the TF_LOG=TRACE in environment variable 1. [ ] set the TF_LOG=WARN in environment variable # A user wants to list all resources which are deployed using Terraform. How can this be done? 1. [ ] terraform state show 1. [x] terraform state list 1. [ ] terraform show 1. [ ] terraform show list # By using the count meta-argument, you can scale the resources by incrementing the number. 1. [x] True 1. [ ] False # Community providers are downloaded automatically using terraform init command. True or False? 1. [x] True 1. [ ] False # SMB(Server Message Block) and RDP(Remote Desktop) are supported connection types in the remote-exec provisioner. True or False? 1. [ ] True 1. [x] False # Is terraform state-unlock command used to unlock the locked state file? 1. [ ] True 1. [x] False # What are the main benefits of a multi-cloud deployment? 1. [ ] There are no benefits, multi-cloud just increase the billing and also add complexity to the infrastructure management > because it has a number of advantages, including fault tolerance. Terraform, which manages multiple providers, can also help with infrastructure management. 1. [x] Multi-cloud deployment allows us to create the same infrastructure in multiple regions or multi-cloud providers, having a fault tolerance application in case of a region or cloud provider is failing > We will use Terraform to deploy the same code in different regions for the same cloud providers, increasing the infrastructure's fault tolerance. 1. [ ] Have multiple applications distributed in geographically distributed to reduce latency for your customers > because multi-cloud deployments do not imply that your applications are deployed across multiple regions, but rather that your infrastructure is deployed across multiple cloud providers. > Reference: https://www.terraform.io/intro/use-cases.html#multi-clouddeployment # What means that Terraform is cloud-agnostic? 1. [ ] You can deploy your infrastructure into different cloud providers using the same code. > You won't be able to deploy using the same code, but you will be able to use the same language. You must modify your code to match the provider's definition and settings. 1. [x] You can deploy your infrastructure into different cloud providers using the same language and different providers > You can use HCL to create and deploy your infrastructure by defining the resources according to the providers' specifications. 1. [ ] You can create infrastructure into different cloud providers using the same language without managing dependencies between them > because you can manage dependencies between cloud providers' resources. 1. [ ] Terraform is not cloud-agnostic > because one of Terraform's main benefits is that it is cloud-agnostic. > Reference: https://www.terraform.io/intro/use-cases.html # What are the main benefits to have a Terraform State? 1. [ ] Mapping to the real world 1. [ ] Dependencies between resources 1. [ ] Synchronization 1. [x] All the options > Using the real world as a map. Terraform needs to know that when we create a resource in a cloud provider, it is mapped to our code. Terraform manages resource dependencies using metadata information. When you delete a resource, Terraform, for example, uses this metadata to figure out which order it should be deleted in. When multiple people are working on the same code, the state must be shared in order for the infrastructure deployment to be in sync. > Reference: https://www.terraform.io/docs/language/state/purpose.html # Where is the Terraform State written by default? 1. [ ] In an Amazon S3 Bucket. > because it requires configuration to use Amazon S3 as the backend, which is not done by default. 1. [x] In the local directory where you are planning and deploying your infrastructure > If you don't provide a backend configuration for your Terraform State, one will be created by default in the terraform directory where you're working. tfstate 1. [ ] $WORKDIRECTORY/.terraform/states/ > because you must configure this in your backend if you want Terraform to write your state to this directory. 1. [ ] Terraform doesn’t create a Terraform State by default > because Terraform will always create a terraform state when you run a terraform init command. > Reference: https://learn.hashicorp.com/tutorials/terraform/aws-build?in=terraform/aws-get-started # Is Terraform Cloud Agnostic? 1. [ ] No > Terraform is cloud agnostic, so B is incorrect. 1. [x] Yes > Terraform has the ability to connect to multiple cloud providers, which is one of its main advantages. > Reference: https://www.terraform.io/intro/use-cases#multi-cloud-deployment # You need to deploy your AWS infrastructure in a multi-region environment. How will you configure your provider to do this? 1. [x] ```terraform provider "aws" { region = "eu-west-1" } provider "aws" { alias = "frankfurt" region = "eu-central-1" } ``` > The alias meta-argument is required to use Terraform with a nondefault provider configuration. 1. [ ] ```terraform provider "aws" { region = "eu-west-1" } provider "aws2" { region = "eu-central-1" } ``` > because aws2 is not a valid provider. 1. [ ] ```terraform provider "aws" { region = "eu-west-1" } provider "aws" { region = "eu-central-1" } ``` > because you have two default providers with the same name, and you must refer to them differently. 1. [ ] ```terraform provider "aws" { region = "eu-west-1" } provider "aws" { name = aws region = "eu-central-1" } ``` > because the meta-argument name in the Terraform provider configuration is invalid. > References: https://www.terraform.io/docs/language/providers/configuration.html
> https://github.com/hashicorp/terraform-provider-aws
> https://registry.terraform.io/providers/hashicorp/aws/latest/docs # In your Terraform state, how can you list a specific resource identified by an ID? Consider the case where you want to check the AWS Security Group "sg-abcd1234". Please enter the complete command from the list below. 1. [ ] terraform list > because there is no command named "list" in Terraform 1. [ ] terraform state resources > The sub-command "resources" is not part of the terraform state 1. [x] terraform state list -id=sg-abcd1234 > The terraform state list -id command will display all of the resources in your terraform state. 1. [ ] terraform list state > because terraform does not have a "list" command. > References: > https://www.terraform.io/cli/commands/state/list#command-state-list > https://www.terraform.io/cli/commands/state/list#example-filtering-byid # What is a multicloud deployment? 1. [ ] The possibility to run a simple .tf into multiple cloud using a single provider to deploy into multiple cloud providers > because to deploy to multiple cloud providers, you must specify different providers. 1. [x] The possibility to run your Terraform code using multiple cloud providers to deploy your infrastructure into multiple cloud providers > The idea behind multi cloud deployment is to run our Terraform code on multiple providers, such as AWS, GCP, or Azure, and deploy infrastructure across multiple clouds in one terraform deployment. 1. [ ] The possibility to run your Terraform code using a single-global provider to deploy your infrastructure into multiple cloud providers > because the infrastructure cannot be deployed across multiple cloud providers because there is no single global provider. 1. [ ] The possibility to run your Terraform code by other tools such as Amazon Cloudformation > Terraform is not designed to be used in third-party applications > Reference: https://www.terraform.io/intro/use-cases#multi-cloud-deployment # What is not the use case of Terraform? 1. [ ] Heroku App Setup 1. [ ] Multi-Cloud Deployment 1. [ ] Multi-Tier Applications 1. [x] Database Replications Schemas > Database replication is not supported by Terraform. Databases can be created with various cloud providers, but replication is managed by a separate tool or software. > Reference: https://www.terraform.io/intro/use-cases # Talking about Infrastructure as Code, What is meant by idempotent for IaC? 1. [x] The same code applied, the result remains the same every time this is applied > When we have the same template and it hasn't been changed, the infrastructure shouldn't change. This usually occurs after our IaC has been applied for the second time. If this does not change, we can say that it is idempotent. 1. [ ] The same code applied, the result change every time when is applied > because the same code does not change the outcome when the same template is used. 1. [ ] The same code applied have random results > because the template is not supposed to generate random outputs. > https://terratest.gruntwork.io/docs/testing-best-practices/idempotent/ # What are the two supported backend types in Terraform? - [ ] Remote-backend - [x] Enhanced > Enhanced backends are capable of both storing and performing operations. Only two enhanced backends are available: local and remote. - [ ] Local- backend - [x] Standard > Backends that only store state and rely on the local backend to perform operations are known as standard backends. > https://www.terraform.io/docs/backends/types # You are trying to login into Terraform Enterprise. Which of the following command is used to save the API token? 1. [ ] terraform get 1. [ ] terraform API-get 1. [x] terraform login 1. [ ] terraform cloud – get api # What is the default number of concurrent operations supported by terraform apply command? 1. [ ] 100 1. [x] 10 1. [ ] 5 1. [ ] 1 # Which of the following flags can be used with terraform apply command? 1. [x] Auto-approve 1. [ ] Init 1. [ ] Get 1. [ ] Console # You have been asked to stop using static values and make code more dynamic. How can you achieve it? Select the correct option from below. 1. [ ] Local values 1. [x] Input variables 1. [ ] Depends_on 1. [ ] Functions # Which of the following below helps users to deploy policy as a code? 1. [ ] Resources 1. [ ] Functions 1. [x] Sentinel 1. [ ] Workspaces # Which command is used to launch terraform console? 1. [ ] terraform apply -config 1. [x] terraform console 1. [ ] terrafrom plan 1. [ ] terrafrom consul # Does terraform refresh command updates the state files? 1. [x] True 1. [ ] False # Does terraform standard backend type support remote management system? 1. [ ] True 1. [x] False # Do terraform workspaces help in adding/allowing multiple state files for a single configuration? 1. [x] True 1. [ ] False # On executing terraform plan, terraform scans the code and appends any missing argument before terraform apply. 1. [ ] True 1. [x] False # What is the provider version of Google Cloud being used in Terraform? ```terraform Google = “~> 1.9.0” ``` - [X] 1.9.1 - [ ] 1.0.0 - [ ] 1.8.0 - [X] 1.9.2 # Which language does terraform support from the below list? 1. [ ] XML 1. [ ] Javascript 1. [x] Hashicorp Language & JSON 1. [ ] Plaintext # Which option will you use to run provisioners that are not associated with any resources? 1. [ ] Local-exec 1. [x] Null_resource 1. [ ] Salt-masterless 1. [ ] Remote-exec # What benefits can provide the Infrastructure as Code for organizations? - [ ] IaC can be used to deploy the latest features of Cloud Services - [x] Share and reusability of the code - [x] Blueprint of the DataCenter - [x] Versioning # provider - meta - arguments Terraform is currently being used by your organisation to create resources on AWS for the development of a web application. One of your coworkers wants to change the instance type to `t2.large` while keeping the default set values. What adjustments does the teammate make in order to meet his goal? > https://www.terraform.io/docs/commandscod/environment-variables.html https://www.terraform.io/docs/commands/plan.html ``` terraform package main import "fmt" func main() { fmt.Println("Hello, World!") } ``` > - [ ] Issue Terraform plan instance.type”.t2.large” and it deploys the instance - [ ] Modify the tf.variables with the instance type and issue terraform apply - [ ] Create a new file my.tfvars and add the type of the instance and issue terraform plan and apply - [x] Modify the terraform.tfvars with the instance type and issue terraform plan and then terraform apply to deploy the instances # Force a version of providers --- shuffle_answers: true --- How do you force users to use a particular version of required providers in your terraform code? - [x] terraform { required_providers { aws = { source = “hashicorp/aws” version =”3.74.1″ } } } - [ ] `terraform { aws = { source = “hashicorp/aws” version ~> “3.74.1” } }` - [ ] `aws = { source = “hashicorp/aws” version = “3.74.1” } }` - [ ] `provider “aws” = { source = “hashicorp/aws” version = “3.74.1” }` # provider - meta - arguments --- shuffle_answers: true --- What of the following next arguments are not part of the generic meta-arguments for a provider? > https://www.terraform.io/language/resources/provisioners/local-exec#local-exec-provisioner - [ ] Alias - [ ] Version - [x] Profile - [x] Region # local-exec --- shuffle_answers: true --- Local-exec invokes a process on the resource that is being created by Terraform.? > https://www.terraform.io/language/resources/provisioners/local-exec#local-exec-provisioner 1. [ ] True 1. [x] False # Advantages of Terraform as Iac Tool --- shuffle_answers: true --- What are the main advantages to use Terraform as the IaC tool? > https://learn.hashicorp.com/tutorials/terraform/infrastructure-as-code - [ ] Versioning - [ ] Manage infrastructure on multiple cloud providers - [ ] Status of your infrastructure based on a State to track all the resources and components - [x] All the options. # Create new workspace --- shuffle_answers: true --- You colleague wants to add a new workspace named `staging`. What command she/he should execute from the following? 1. [ ] terraform workspace new=staging 1. [ ] terraform workspace --new staging 1. [x] terraform workspace new staging 1. [ ] terraform workspace ini staging # Troubleshooting and debugging --- shuffle_answers: true --- On executing `Terraform Apply` it fails with connection timeout, troubleshoot this how what environment variable should you set to enable the detailed logging? 1. [x] TF_LOG 1. [ ] TF_Debug 1. [ ] TF_warn 1. [ ] TF_error # State is a necessary requirement for Terraform to function. What of the following is not a purpose of Terraform State? 1. [ ] Mapping to the real world 1. [ ] Performance 1. [ ] Syncing 1. [x] Security # What are the main advantages to use Terraform as the IaC tool? 1. [ ] Manage infrastructure on multiple cloud providers 1. [ ] Versioning 1. [ ] Status of your infrastructure based on a State to track all the resources and components 1. [x] All the options are valid # You've been asked to present infrastructure benefits as code... please select all of the options. - [x] State management - [x] Operator confidence - [x] Platform agnostic - [ ] Not Supports multi-cloud > Reference: https://learn.hashicorp.com/tutorials/terraform/infrastructure-as-codE # You are a DevOps consultant and you have a customer that never has heard about IaC. How you will describe what IaC is? 1. [ ] IaC is a new way to create infrastructure using APIs from different providers. Has the disadvantage that is not modular and is not reusable > because you are missing the permissionscontrol, which is one of the main benefits of the IaC. 1. [x] IaC is the way to create infrastructure or resources using code where you can plan to check out the differences between the actual state and the new one and you can apply those changes to your infrastructure. This can be also destroyed > You write your infrastructure with IaC, and particularly with Terraform, and you can execute plans before seeing the differences with the current state of your infrastructure. Those changes can also be applied to the infrastructure. 1. [ ] Terraform is a OOO programing language which you can create infrastructure just on Amazon Web Services > because Terraform allows you to create infrastructure for a variety of providers, not just Amazon Web Services. Terraform is also a declarative language rather than an OOO. > References: > https://www.terraform.io/intro/index.html#infrastructure-as-code > https://registry.terraform.io/browse/providers # What are the main advantages of Terraform? - [x] Is agnostic to any platform - [x] Is reusable - [x] State management of the infrastructure > Reference: > https://learn.hashicorp.com/tutorials/terraform/infrastructure-ascode#advantages-of-terraform # What of the following statement is not a use-case of Terraform 1. [ ] Multi Cloud Deployments > because one of the main benefits of Terraform, and particularly one of the main advantages, is Multi Cloud Deployments. 1. [ ] Kubernetes Infrastructure Definition > because you can use Terraform to create your infrastructure and resource definitions using the Kubernetes provider. 1. [x] Data migration between a DC and a Cloud Provider > Terraform is not a tool for migrating data between providers, such as on-premise to cloud, but it can be used to build this infrastructure and use resources from various providers to design and build your data migration platform. 1. [ ] Creation of CI/CD Pipelines on GitLab > because you can use Terraform to define your pipelines using the GitLab provider. > References:
> https://www.terraform.io/intro/use-cases.html
> https://registry.terraform.io/providers/hashicorp/kubernetes/latest
> https://registry.terraform.io/providers/gitlabhq/gitlab/latest # You're the DevOps Team Lead at a company where every piece of infrastructure is built by hand. You have a meeting with the CTO, and you must persuade him to abandon the current strategy in favour of IaC. Your CTO believes that IaC will be costly and have a steep learning curve. How would you structure your speech to highlight the key benefits of using IaC and Terraform? 1. [ ] Terraform will introduce speed on the development of the applications of your company. > because, while you will gain speed developing your applications' infrastructure, Terraform is not a tool for software development. 1. [ ] Terraform is expensive because you have to pay for a license, but this cost is less than the time-consuming creating the infrastructure manually > because Terraform is available for free and you do not need to pay for it. 1. [ ] With Terraform, the possibility to have security incidents and leave a firewall open in your infrastructure is higher, but you can create firewalls in seconds > because with IaC, you can have a code review to double-check your changes before submitting them, providing an extra layer of security when your code is being used. 1. [x] Terraform has a free version and you don’t have to pay for it. IaC makes your infrastructure more reliable, repeatable, consistent, and secure gaining speed and velocity when you have to deploy your infrastructure multiple times. > Terraform has a free version that includes all of the features and requires no payment to use. Terraform can also use modules to make your IaC repeatable and reusable, as well as a management state of your infrastructure that is consistent with your code. > References: > https://www.hashicorp.com/blog/infrastructure-as-code-in-a-privateor-public-cloud > https://www.hashicorp.com/products/terraform/pricing # What are the main advantages to use Terraform as the IaC tool? 1. [ ] Manage infrastructure on multiple cloud providers 1. [ ] Versioning 1. [ ] Status of your infrastructure based on a State to track all the resources and components > Reference: https://learn.hashicorp.com/tutorials/terraform/infrastructure-as-code
Discover the real you
You're more awesome than you think! Take free quizzes to reveal your talents and skills. The test contains a set of questions and there is no time limit. The test is not official, it's just one of the most efficient ways to see how much you know, or don't know, about the subject.Count your score
You will get 1 point for each correct answer. At the end of the Quiz, your total score will be displayed.Reflect on you answers
Please conduct a self review of your answers once you complete the quiz test. Being an active participant in your own evaluation, honestly assess your strengths and also areas you need to improve. Good luck!--- # When multiple team members are working on the same state file, the state file gets locked, how to remove the lock? 1. [x] terraform force-unlock LOCK_ID 1. [ ] terraform force-unlock STATE_FILE 1. [ ] terraform unlock LOCK_ID 1. [ ] terraform force-unlock=true # Which of the following command can be used to syntactically check to terraform configuration before using apply or plan command? 1. [ ] terraform fmt 1. [x] terraform validate 1. [ ] terraform show 1. [ ] terraform check # Which among the following are not module source options? 1. [ ] Local Path 1. [ ] Terraform registry 1. [ ] Bit bucket 1. [ ] HTTP URLs 1. [x] BLOB storage # Which among the following log command should be set to get Maximum verbosity of terraform logs? 1. [ ] set the TF_LOG=DEBUG in environment variable 1. [ ] set the TF_LOG=INFO in environment variable 1. [x] set the TF_LOG=TRACE in environment variable 1. [ ] set the TF_LOG=WARN in environment variable # A user wants to list all resources which are deployed using Terraform. How can this be done? 1. [ ] terraform state show 1. [x] terraform state list 1. [ ] terraform show 1. [ ] terraform show list # By using the count meta-argument, you can scale the resources by incrementing the number. 1. [x] True 1. [ ] False # Community providers are downloaded automatically using terraform init command. True or False? 1. [x] True 1. [ ] False # SMB(Server Message Block) and RDP(Remote Desktop) are supported connection types in the remote-exec provisioner. True or False? 1. [ ] True 1. [x] False # Is terraform state-unlock command used to unlock the locked state file? 1. [ ] True 1. [x] False # What are the main benefits of a multi-cloud deployment? 1. [ ] There are no benefits, multi-cloud just increase the billing and also add complexity to the infrastructure management > because it has a number of advantages, including fault tolerance. Terraform, which manages multiple providers, can also help with infrastructure management. 1. [x] Multi-cloud deployment allows us to create the same infrastructure in multiple regions or multi-cloud providers, having a fault tolerance application in case of a region or cloud provider is failing > We will use Terraform to deploy the same code in different regions for the same cloud providers, increasing the infrastructure's fault tolerance. 1. [ ] Have multiple applications distributed in geographically distributed to reduce latency for your customers > because multi-cloud deployments do not imply that your applications are deployed across multiple regions, but rather that your infrastructure is deployed across multiple cloud providers. > Reference: https://www.terraform.io/intro/use-cases.html#multi-clouddeployment # What means that Terraform is cloud-agnostic? 1. [ ] You can deploy your infrastructure into different cloud providers using the same code. > You won't be able to deploy using the same code, but you will be able to use the same language. You must modify your code to match the provider's definition and settings. 1. [x] You can deploy your infrastructure into different cloud providers using the same language and different providers > You can use HCL to create and deploy your infrastructure by defining the resources according to the providers' specifications. 1. [ ] You can create infrastructure into different cloud providers using the same language without managing dependencies between them > because you can manage dependencies between cloud providers' resources. 1. [ ] Terraform is not cloud-agnostic > because one of Terraform's main benefits is that it is cloud-agnostic. > Reference: https://www.terraform.io/intro/use-cases.html # What are the main benefits to have a Terraform State? 1. [ ] Mapping to the real world 1. [ ] Dependencies between resources 1. [ ] Synchronization 1. [x] All the options > Using the real world as a map. Terraform needs to know that when we create a resource in a cloud provider, it is mapped to our code. Terraform manages resource dependencies using metadata information. When you delete a resource, Terraform, for example, uses this metadata to figure out which order it should be deleted in. When multiple people are working on the same code, the state must be shared in order for the infrastructure deployment to be in sync. > Reference: https://www.terraform.io/docs/language/state/purpose.html # Where is the Terraform State written by default? 1. [ ] In an Amazon S3 Bucket. > because it requires configuration to use Amazon S3 as the backend, which is not done by default. 1. [x] In the local directory where you are planning and deploying your infrastructure > If you don't provide a backend configuration for your Terraform State, one will be created by default in the terraform directory where you're working. tfstate 1. [ ] $WORKDIRECTORY/.terraform/states/ > because you must configure this in your backend if you want Terraform to write your state to this directory. 1. [ ] Terraform doesn’t create a Terraform State by default > because Terraform will always create a terraform state when you run a terraform init command. > Reference: https://learn.hashicorp.com/tutorials/terraform/aws-build?in=terraform/aws-get-started # Is Terraform Cloud Agnostic? 1. [ ] No > Terraform is cloud agnostic, so B is incorrect. 1. [x] Yes > Terraform has the ability to connect to multiple cloud providers, which is one of its main advantages. > Reference: https://www.terraform.io/intro/use-cases#multi-cloud-deployment # You need to deploy your AWS infrastructure in a multi-region environment. How will you configure your provider to do this? 1. [x] ```terraform provider "aws" { region = "eu-west-1" } provider "aws" { alias = "frankfurt" region = "eu-central-1" } ``` > The alias meta-argument is required to use Terraform with a nondefault provider configuration. 1. [ ] ```terraform provider "aws" { region = "eu-west-1" } provider "aws2" { region = "eu-central-1" } ``` > because aws2 is not a valid provider. 1. [ ] ```terraform provider "aws" { region = "eu-west-1" } provider "aws" { region = "eu-central-1" } ``` > because you have two default providers with the same name, and you must refer to them differently. 1. [ ] ```terraform provider "aws" { region = "eu-west-1" } provider "aws" { name = aws region = "eu-central-1" } ``` > because the meta-argument name in the Terraform provider configuration is invalid. > References: https://www.terraform.io/docs/language/providers/configuration.html
> https://github.com/hashicorp/terraform-provider-aws
> https://registry.terraform.io/providers/hashicorp/aws/latest/docs # In your Terraform state, how can you list a specific resource identified by an ID? Consider the case where you want to check the AWS Security Group "sg-abcd1234". Please enter the complete command from the list below. 1. [ ] terraform list > because there is no command named "list" in Terraform 1. [ ] terraform state resources > The sub-command "resources" is not part of the terraform state 1. [x] terraform state list -id=sg-abcd1234 > The terraform state list -id command will display all of the resources in your terraform state. 1. [ ] terraform list state > because terraform does not have a "list" command. > References: > https://www.terraform.io/cli/commands/state/list#command-state-list > https://www.terraform.io/cli/commands/state/list#example-filtering-byid # What is a multicloud deployment? 1. [ ] The possibility to run a simple .tf into multiple cloud using a single provider to deploy into multiple cloud providers > because to deploy to multiple cloud providers, you must specify different providers. 1. [x] The possibility to run your Terraform code using multiple cloud providers to deploy your infrastructure into multiple cloud providers > The idea behind multi cloud deployment is to run our Terraform code on multiple providers, such as AWS, GCP, or Azure, and deploy infrastructure across multiple clouds in one terraform deployment. 1. [ ] The possibility to run your Terraform code using a single-global provider to deploy your infrastructure into multiple cloud providers > because the infrastructure cannot be deployed across multiple cloud providers because there is no single global provider. 1. [ ] The possibility to run your Terraform code by other tools such as Amazon Cloudformation > Terraform is not designed to be used in third-party applications > Reference: https://www.terraform.io/intro/use-cases#multi-cloud-deployment # What is not the use case of Terraform? 1. [ ] Heroku App Setup 1. [ ] Multi-Cloud Deployment 1. [ ] Multi-Tier Applications 1. [x] Database Replications Schemas > Database replication is not supported by Terraform. Databases can be created with various cloud providers, but replication is managed by a separate tool or software. > Reference: https://www.terraform.io/intro/use-cases # Talking about Infrastructure as Code, What is meant by idempotent for IaC? 1. [x] The same code applied, the result remains the same every time this is applied > When we have the same template and it hasn't been changed, the infrastructure shouldn't change. This usually occurs after our IaC has been applied for the second time. If this does not change, we can say that it is idempotent. 1. [ ] The same code applied, the result change every time when is applied > because the same code does not change the outcome when the same template is used. 1. [ ] The same code applied have random results > because the template is not supposed to generate random outputs. > https://terratest.gruntwork.io/docs/testing-best-practices/idempotent/ # What are the two supported backend types in Terraform? - [ ] Remote-backend - [x] Enhanced > Enhanced backends are capable of both storing and performing operations. Only two enhanced backends are available: local and remote. - [ ] Local- backend - [x] Standard > Backends that only store state and rely on the local backend to perform operations are known as standard backends. > https://www.terraform.io/docs/backends/types # You are trying to login into Terraform Enterprise. Which of the following command is used to save the API token? 1. [ ] terraform get 1. [ ] terraform API-get 1. [x] terraform login 1. [ ] terraform cloud – get api # What is the default number of concurrent operations supported by terraform apply command? 1. [ ] 100 1. [x] 10 1. [ ] 5 1. [ ] 1 # Which of the following flags can be used with terraform apply command? 1. [x] Auto-approve 1. [ ] Init 1. [ ] Get 1. [ ] Console # You have been asked to stop using static values and make code more dynamic. How can you achieve it? Select the correct option from below. 1. [ ] Local values 1. [x] Input variables 1. [ ] Depends_on 1. [ ] Functions # Which of the following below helps users to deploy policy as a code? 1. [ ] Resources 1. [ ] Functions 1. [x] Sentinel 1. [ ] Workspaces # Which command is used to launch terraform console? 1. [ ] terraform apply -config 1. [x] terraform console 1. [ ] terrafrom plan 1. [ ] terrafrom consul # Does terraform refresh command updates the state files? 1. [x] True 1. [ ] False # Does terraform standard backend type support remote management system? 1. [ ] True 1. [x] False # Do terraform workspaces help in adding/allowing multiple state files for a single configuration? 1. [x] True 1. [ ] False # On executing terraform plan, terraform scans the code and appends any missing argument before terraform apply. 1. [ ] True 1. [x] False # What is the provider version of Google Cloud being used in Terraform? ```terraform Google = “~> 1.9.0” ``` - [X] 1.9.1 - [ ] 1.0.0 - [ ] 1.8.0 - [X] 1.9.2 # Which language does terraform support from the below list? 1. [ ] XML 1. [ ] Javascript 1. [x] Hashicorp Language & JSON 1. [ ] Plaintext # Which option will you use to run provisioners that are not associated with any resources? 1. [ ] Local-exec 1. [x] Null_resource 1. [ ] Salt-masterless 1. [ ] Remote-exec # What benefits can provide the Infrastructure as Code for organizations? - [ ] IaC can be used to deploy the latest features of Cloud Services - [x] Share and reusability of the code - [x] Blueprint of the DataCenter - [x] Versioning # provider - meta - arguments Terraform is currently being used by your organisation to create resources on AWS for the development of a web application. One of your coworkers wants to change the instance type to `t2.large` while keeping the default set values. What adjustments does the teammate make in order to meet his goal? > https://www.terraform.io/docs/commandscod/environment-variables.html https://www.terraform.io/docs/commands/plan.html ``` terraform package main import "fmt" func main() { fmt.Println("Hello, World!") } ``` > - [ ] Issue Terraform plan instance.type”.t2.large” and it deploys the instance - [ ] Modify the tf.variables with the instance type and issue terraform apply - [ ] Create a new file my.tfvars and add the type of the instance and issue terraform plan and apply - [x] Modify the terraform.tfvars with the instance type and issue terraform plan and then terraform apply to deploy the instances # Force a version of providers --- shuffle_answers: true --- How do you force users to use a particular version of required providers in your terraform code? - [x] terraform { required_providers { aws = { source = “hashicorp/aws” version =”3.74.1″ } } } - [ ] `terraform { aws = { source = “hashicorp/aws” version ~> “3.74.1” } }` - [ ] `aws = { source = “hashicorp/aws” version = “3.74.1” } }` - [ ] `provider “aws” = { source = “hashicorp/aws” version = “3.74.1” }` # provider - meta - arguments --- shuffle_answers: true --- What of the following next arguments are not part of the generic meta-arguments for a provider? > https://www.terraform.io/language/resources/provisioners/local-exec#local-exec-provisioner - [ ] Alias - [ ] Version - [x] Profile - [x] Region # local-exec --- shuffle_answers: true --- Local-exec invokes a process on the resource that is being created by Terraform.? > https://www.terraform.io/language/resources/provisioners/local-exec#local-exec-provisioner 1. [ ] True 1. [x] False # Advantages of Terraform as Iac Tool --- shuffle_answers: true --- What are the main advantages to use Terraform as the IaC tool? > https://learn.hashicorp.com/tutorials/terraform/infrastructure-as-code - [ ] Versioning - [ ] Manage infrastructure on multiple cloud providers - [ ] Status of your infrastructure based on a State to track all the resources and components - [x] All the options. # Create new workspace --- shuffle_answers: true --- You colleague wants to add a new workspace named `staging`. What command she/he should execute from the following? 1. [ ] terraform workspace new=staging 1. [ ] terraform workspace --new staging 1. [x] terraform workspace new staging 1. [ ] terraform workspace ini staging # Troubleshooting and debugging --- shuffle_answers: true --- On executing `Terraform Apply` it fails with connection timeout, troubleshoot this how what environment variable should you set to enable the detailed logging? 1. [x] TF_LOG 1. [ ] TF_Debug 1. [ ] TF_warn 1. [ ] TF_error # State is a necessary requirement for Terraform to function. What of the following is not a purpose of Terraform State? 1. [ ] Mapping to the real world 1. [ ] Performance 1. [ ] Syncing 1. [x] Security # What are the main advantages to use Terraform as the IaC tool? 1. [ ] Manage infrastructure on multiple cloud providers 1. [ ] Versioning 1. [ ] Status of your infrastructure based on a State to track all the resources and components 1. [x] All the options are valid # You've been asked to present infrastructure benefits as code... please select all of the options. - [x] State management - [x] Operator confidence - [x] Platform agnostic - [ ] Not Supports multi-cloud > Reference: https://learn.hashicorp.com/tutorials/terraform/infrastructure-as-codE # You are a DevOps consultant and you have a customer that never has heard about IaC. How you will describe what IaC is? 1. [ ] IaC is a new way to create infrastructure using APIs from different providers. Has the disadvantage that is not modular and is not reusable > because you are missing the permissionscontrol, which is one of the main benefits of the IaC. 1. [x] IaC is the way to create infrastructure or resources using code where you can plan to check out the differences between the actual state and the new one and you can apply those changes to your infrastructure. This can be also destroyed > You write your infrastructure with IaC, and particularly with Terraform, and you can execute plans before seeing the differences with the current state of your infrastructure. Those changes can also be applied to the infrastructure. 1. [ ] Terraform is a OOO programing language which you can create infrastructure just on Amazon Web Services > because Terraform allows you to create infrastructure for a variety of providers, not just Amazon Web Services. Terraform is also a declarative language rather than an OOO. > References: > https://www.terraform.io/intro/index.html#infrastructure-as-code > https://registry.terraform.io/browse/providers # What are the main advantages of Terraform? - [x] Is agnostic to any platform - [x] Is reusable - [x] State management of the infrastructure > Reference: > https://learn.hashicorp.com/tutorials/terraform/infrastructure-ascode#advantages-of-terraform # What of the following statement is not a use-case of Terraform 1. [ ] Multi Cloud Deployments > because one of the main benefits of Terraform, and particularly one of the main advantages, is Multi Cloud Deployments. 1. [ ] Kubernetes Infrastructure Definition > because you can use Terraform to create your infrastructure and resource definitions using the Kubernetes provider. 1. [x] Data migration between a DC and a Cloud Provider > Terraform is not a tool for migrating data between providers, such as on-premise to cloud, but it can be used to build this infrastructure and use resources from various providers to design and build your data migration platform. 1. [ ] Creation of CI/CD Pipelines on GitLab > because you can use Terraform to define your pipelines using the GitLab provider. > References:
> https://www.terraform.io/intro/use-cases.html
> https://registry.terraform.io/providers/hashicorp/kubernetes/latest
> https://registry.terraform.io/providers/gitlabhq/gitlab/latest # You're the DevOps Team Lead at a company where every piece of infrastructure is built by hand. You have a meeting with the CTO, and you must persuade him to abandon the current strategy in favour of IaC. Your CTO believes that IaC will be costly and have a steep learning curve. How would you structure your speech to highlight the key benefits of using IaC and Terraform? 1. [ ] Terraform will introduce speed on the development of the applications of your company. > because, while you will gain speed developing your applications' infrastructure, Terraform is not a tool for software development. 1. [ ] Terraform is expensive because you have to pay for a license, but this cost is less than the time-consuming creating the infrastructure manually > because Terraform is available for free and you do not need to pay for it. 1. [ ] With Terraform, the possibility to have security incidents and leave a firewall open in your infrastructure is higher, but you can create firewalls in seconds > because with IaC, you can have a code review to double-check your changes before submitting them, providing an extra layer of security when your code is being used. 1. [x] Terraform has a free version and you don’t have to pay for it. IaC makes your infrastructure more reliable, repeatable, consistent, and secure gaining speed and velocity when you have to deploy your infrastructure multiple times. > Terraform has a free version that includes all of the features and requires no payment to use. Terraform can also use modules to make your IaC repeatable and reusable, as well as a management state of your infrastructure that is consistent with your code. > References: > https://www.hashicorp.com/blog/infrastructure-as-code-in-a-privateor-public-cloud > https://www.hashicorp.com/products/terraform/pricing # What are the main advantages to use Terraform as the IaC tool? 1. [ ] Manage infrastructure on multiple cloud providers 1. [ ] Versioning 1. [ ] Status of your infrastructure based on a State to track all the resources and components > Reference: https://learn.hashicorp.com/tutorials/terraform/infrastructure-as-code
Key reasons to understand IaC concepts include
- Faster and more efficient infrastructure management: IaC enables teams to manage and deploy infrastructure at scale with greater speed and efficiency, reducing the time and effort required for manual configuration and provisioning.
- Improved consistency and reliability: By defining infrastructure as code, teams can ensure consistency and reliability across all environments, reducing the risk of errors and downtime caused by manual configuration.
- Better collaboration: IaC promotes collaboration between developers and operations teams by providing a common language and toolset for managing infrastructure, improving communication and alignment.
- Increased agility and flexibility: IaC allows teams to quickly adapt to changing business needs by enabling them to easily spin up and tear down infrastructure as needed, reducing costs and improving agility.
- Better security: IaC can help improve security by ensuring that all infrastructure is configured and managed consistently, reducing the risk of vulnerabilities caused by manual configuration.
Overall, understanding IaC concepts is essential for teams looking to streamline and optimize their infrastructure management processes, improve collaboration, and stay competitive in an increasingly fast-paced and complex technology landscape.