CDKTF GitHub Provider

raw JSON →
15.3.1 verified Fri May 01 auth: no python

Prebuilt Terraform CDK (CDKTF) provider for managing GitHub resources (repositories, teams, webhooks, etc.) programmatically with TypeScript/Python/Java/C#. Version 15.3.1 targets CDKTF 0.20+ and the GitHub Terraform provider ~> 6.0. Follows CDKTF's major version cadence.

pip install cdktf-cdktf-provider-github
error ModuleNotFoundError: No module named 'cdktf_cdktf_provider_github.github'
cause Trying to import from flat namespace after refactor to submodules.
fix
Use from cdktf_cdktf_provider_github.repository import Repository instead of from cdktf_cdktf_provider_github import Repository.
error jsii.errors.JSIIError: ...
cause Version mismatch between cdktf and provider package.
fix
Ensure cdktf and cdktf-cdktf-provider-github are compatible. Check release notes for compatibility matrix.
breaking Version 15.x requires cdktf >=0.20. Using with cdktf 0.19.x will cause import errors.
fix Upgrade cdktf: pip install 'cdktf>=0.20'
deprecated The old `cdktf_cdktf_provider_github.github` module (flat namespace) is deprecated; resources are now in submodules like `repository`, `team`, etc.
fix Use submodule imports (e.g., `from cdktf_cdktf_provider_github.repository import Repository`)
gotcha Provider token must be set via environment variable or explicitly. If not set, resource actions fail with 401.
fix Export GITHUB_TOKEN or pass token= parameter to GithubProvider

Minimal stack to create a public GitHub repository

from constructs import Construct
from cdktf import App, TerraformStack
from cdktf_cdktf_provider_github.provider import GithubProvider
from cdktf_cdktf_provider_github.repository import Repository
import os

class MyStack(TerraformStack):
    def __init__(self, scope: Construct, id: str):
        super().__init__(scope, id)
        GithubProvider(self, 'github',
            token = os.environ.get('GITHUB_TOKEN', '')
        )
        Repository(self, 'repo',
            name = 'my-repo',
            description = 'Created by CDKTF',
            visibility = 'public'
        )

app = App()
MyStack(app, 'github-stack')
app.synth()