0
0
Terraformcloud~10 mins

Provider versioning constraints in Terraform - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the AWS provider version constraint.

Terraform
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = [1]
    }
  }
}
Drag options to blanks, or click blank then click option'
A"^5.0"
B"~> 4.0"
C"= 3.0"
D"< 2.0"
Attempts:
3 left
💡 Hint
Common Mistakes
Using exact version '=' which is too restrictive.
Using '^' which is not supported in Terraform version constraints.
2fill in blank
medium

Complete the code to require provider version 3.5 or higher but less than 4.0.

Terraform
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = [1]
    }
  }
}
Drag options to blanks, or click blank then click option'
A"= 3.5"
B"~> 3.5"
C">= 3.5, < 4.0"
D"< 3.5"
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which fixes the version exactly.
Using '~> 3.5' instead of the range constraint.
3fill in blank
hard

Fix the error in the provider version constraint to allow any 2.x version.

Terraform
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = [1]
    }
  }
}
Drag options to blanks, or click blank then click option'
A"~> 2.0"
B"= 2"
C">= 2.0, < 3.0"
D"2.x"
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' with incomplete version number.
Using invalid version syntax like '2.x'.
4fill in blank
hard

Fill both blanks to specify the provider source and version constraint for Azure provider version 3.0 or higher but less than 4.0.

Terraform
terraform {
  required_providers {
    azure = {
      source  = [1]
      version = [2]
    }
  }
}
Drag options to blanks, or click blank then click option'
A"hashicorp/azurerm"
B"~> 3.0"
C">= 3.0, < 4.0"
D"hashicorp/azure"
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect provider source name.
Using '~> 3.0' instead of the range constraint.
5fill in blank
hard

Fill all three blanks to specify the Google provider with source, version constraint for any 4.x version, and a required Terraform version of at least 1.2.0.

Terraform
terraform {
  required_version = [1]
  required_providers {
    google = {
      source  = [2]
      version = [3]
    }
  }
}
Drag options to blanks, or click blank then click option'
A">= 1.2.0"
B"hashicorp/google"
C"~> 4.0"
D"= 4.0"
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' for provider version which fixes it exactly.
Using incorrect provider source name.
Setting required_version too low or too high.