TF File structure:
- ./
- main.tf (see code below, github provider defined here)
-
module1 (folder)
- module1.tfvars
- github-repos.tf (see code below)
- main.tf (blank)
- variables.tf (defined for the module, value comes from tfvar file)
- module2 (folder)
- module3 (folder)
I have setup the GitHub integration in my root main.tf
file like so:
./main.tf
terraform {
required_version = ">= 1.0.9"
backend "s3" {
}
required_providers {
github = {
source = "integrations/github"
version = "~> 4.0"
}
}
}
provider "github" {
owner = "githuborgname"
base_url = "https://github.com/githuborgname/" # we have GitHub Enterprise
token = github_mgmt_token
}
The github_mgmt_token
is coming from an output later in the same main.tf
file and seems to be working well (since the repo is getting successfully created under the PAT user repos).
Inside a module I have a github-repos.tf
file that looks like so:
./moduel1/github-repos.tf
resource "github_repository" "ssc" {
name = "ssc"
description = "text"
homepage_url = "https://internalurl.com"
visibility = "private"
delete_branch_on_merge = true
auto_init = true
gitignore_template = "Python"
archive_on_destroy = true
vulnerability_alerts = true
}
This successfully creates the repo without issue but its inside the PAT user account instead of the GitHub org.
How do you create an organization repo?