To constrain the GitHub provider to version 2.1 or greater in Terraform 0.12 configuration's provider block, which option would you use?

Prepare for the HashiCorp Terraform Associate Exam with quizzes, flashcards, and multiple-choice questions. Each question includes hints and explanations. Boost your confidence and ace your exam!

Multiple Choice

To constrain the GitHub provider to version 2.1 or greater in Terraform 0.12 configuration's provider block, which option would you use?

Explanation:
In Terraform you specify provider version constraints as a string value in the required_providers block, not directly in the provider block. To allow the GitHub provider version 2.1 or newer, you express the constraint with the greater-than-or-equal operator inside that string: version = ">= 2.1". This means any release from 2.1 onward is acceptable. Using a constraint like ~> 2.1 would limit you to 2.1.x only, not 3.x, and using <= 2.1 would restrict to 2.1 or earlier. Here’s a quick example: terraform { required_providers { github = { source = "integrations/github" version = ">= 2.1" } } } This approach ensures you’re specifying the intended range and that Terraform 0.12 will enforce it.

In Terraform you specify provider version constraints as a string value in the required_providers block, not directly in the provider block. To allow the GitHub provider version 2.1 or newer, you express the constraint with the greater-than-or-equal operator inside that string: version = ">= 2.1". This means any release from 2.1 onward is acceptable. Using a constraint like ~> 2.1 would limit you to 2.1.x only, not 3.x, and using <= 2.1 would restrict to 2.1 or earlier. Here’s a quick example:

terraform {

required_providers {

github = {

source = "integrations/github"

version = ">= 2.1"

}

}

}

This approach ensures you’re specifying the intended range and that Terraform 0.12 will enforce it.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy