Hi, I am trying to understand how to incorporate mandatory gates for Pull request, as mentioned at Terraform Registry want to include “required_status_check”, “required_pull_request_reviews”
Please suggest
I have tried this way, getting error, please suggest.
My main.tf:
terraform {
required_providers {
github = {
source = “integrations/github”
version = “4.3.0”
}
}
}
resource “github_branch_protection_v3” “main_protection” {
repository = “${var.repository}”
branch = “main”
enforce_admins = true
required_pull_request_reviews {
dismiss_stale_reviews = true
required_approving_review_count = 2
}
required_status_checks {
strict = false
contexts = [“terraform-fmt”]
}
}
.github/workflows/terraform.yml has
name: terraform
on:
push:
branches:
- main
pull_request:
branches: [ main ]
#To trigger manual
workflow_dispatch:
jobs:
terraform:
runs-on: ubuntu-latest
container:
image: hashicorp/terraform
# image: .github/workflows/Dockerfile
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v2.4.0
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform init
# Checks that all Terraform configuration files adhere to a canonical format
- name: Terraform Format
run: terraform fmt -check
# Generates an execution plan for Terraform
- name: Terraform Plan
run: terraform plan
Getting error at Terraform-Format step, Error process completed with exit code 3