Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to specify the Terraform version in the GitHub Actions workflow.
Terraform
jobs:
terraform:
runs-on: ubuntu-latest
steps:
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'latest' instead of a specific version number.
Using 'v1' which is not a valid version format.
Leaving the version blank.
✗ Incorrect
The terraform_version input expects a specific version number like '1.5.0' to install that Terraform version.
2fill in blank
mediumComplete the code to initialize Terraform in the GitHub Actions workflow.
Terraform
- name: Terraform Init
run: terraform [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'apply' instead of 'init' for initialization.
Using 'plan' which only previews changes.
Using 'validate' which only checks configuration syntax.
✗ Incorrect
The 'terraform init' command initializes the working directory containing Terraform configuration files.
3fill in blank
hardFix the error in the GitHub Actions step to apply Terraform changes automatically.
Terraform
- name: Terraform Apply
run: terraform apply -auto-[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-auto-confirm' which is invalid.
Using '-auto-accept' which is invalid.
Using '-auto-apply' which is invalid.
✗ Incorrect
The correct flag to auto-approve Terraform apply is '-auto-approve'.
4fill in blank
hardFill both blanks to configure the GitHub Actions workflow to checkout the repository and set environment variables.
Terraform
- name: Checkout code
uses: [1]
- name: Set environment variables
run: echo "TF_VAR_region=[2]" >> $GITHUB_ENV Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'hashicorp/setup-terraform@v1' instead of checkout action.
Setting region to an invalid value like 'terraform-latest'.
✗ Incorrect
The checkout action is 'actions/checkout@v3' and the region environment variable is set to 'us-west-2'.
5fill in blank
hardFill all three blanks to create a GitHub Actions step that runs 'terraform plan' and saves the output to a file.
Terraform
- name: Terraform Plan
run: terraform [1] -out=[2] && terraform show -json [2] > [3] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'apply' instead of 'plan' for the first blank.
Using invalid file names for output or JSON files.
✗ Incorrect
The command runs 'terraform plan' with output file 'tfplan' and then exports JSON to 'plan.json'.