Example Terraform code to Create Github Repository

Generate GITHUB ACCESS Token

Write Providers.tf

terraform {
  required_providers {
    github = {
      source  = "integrations/github"
      version = "~> 4.0"
    }
  }
}

# Configure the GitHub Provider

provider "github" {
  token = "XXXXXXXXXXX"
  owner = "devopsschool-demo-temporary"
}

Write Resources-github.tf

resource "github_repository" "github-repo-1" {
  name        = "terraform-demo-1"
  description = "My awesome codebase"

  visibility = "public"
}

Run Following Commands

$ terraform init
	- Download Providers & Modules
$ terraform validate
	- Validate .tf profile
$ terraform plan
	- DRY RUN
$ terraform apply
	- Create a resources &&& store a resonse IN STATE file(json)
$ terraform destroy
	- Destroy a resources using STATE file(json)
Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)