Troubleshooting¶
Common issues and their solutions.
Authentication Issues¶
Invalid Token Error¶
Causes: - Token is incorrect or expired - Token environment variable not set - Token has been revoked
Solutions:
-
Verify token is set:
-
Check token hasn't expired in GitHub settings
-
Regenerate token if needed:
- Go to GitHub Settings → Developer settings → Personal access tokens
- Generate new token with required scopes
-
Update environment variable
-
Ensure token is exported in current shell:
Insufficient Permissions¶
Causes: - Token missing required scopes - User lacks necessary organization permissions - Resource requires higher access level
Solutions:
- Verify token has required scopes:
repo- Full control of private repositoriesadmin:org- Full control of orgs and teams-
delete_repo- Delete repositories (if destroying) -
Check your organization role:
- Must be Owner or Admin
-
Go to organization → People → Check your role
-
For GitHub Apps, verify app permissions match requirements
Terraform Issues¶
State Lock Error¶
Causes: - Another Terraform process is running - Previous process crashed without releasing lock - Lock timeout
Solutions:
-
Wait for other operation to complete
-
If process crashed, force unlock:
Use Carefully
Only force unlock if you're certain no other process is running.
- Check for running Terraform processes:
Provider Initialization Failed¶
Causes: - Network connectivity issues - Invalid provider version - Registry unavailable
Solutions:
-
Retry initialization:
-
Check network connectivity:
-
Clear Terraform cache:
Plan Shows Unexpected Changes¶
Causes: - Manual changes made in GitHub UI - Configuration drift - State file out of sync
Solutions:
-
Refresh state:
-
Review the changes carefully:
-
If drift is intentional, import the changes:
-
If drift is not desired, apply to revert:
Repository Issues¶
Repository Already Exists¶
Causes: - Repository with same name already exists - Previous Terraform run was incomplete
Solutions:
-
Import existing repository:
-
Use a different repository name
-
Delete existing repository (if safe to do so)
Cannot Delete Repository¶
Causes:
- Token lacks delete_repo scope
- Repository has protection against deletion
- User lacks admin access
Solutions:
-
Add
delete_reposcope to token -
Remove lifecycle protection if configured:
-
Verify admin access to repository
Ruleset Creation Failed¶
Causes: - Invalid branch pattern - Status check doesn't exist - Bypass actor ID invalid - Free tier limitation
Solutions:
-
Verify branch patterns are valid:
-
Ensure status checks exist in CI:
-
Verify bypass actor IDs:
-
For org rulesets, ensure you have Team/Enterprise plan
Team Issues¶
User Not Found¶
Causes: - Username is incorrect - User hasn't accepted organization invitation - User account doesn't exist
Solutions:
-
Verify username is correct (case-sensitive)
-
Check if user has accepted org invitation:
-
Go to organization → People → Invitations
-
Send invitation if needed:
Cannot Add User to Team¶
Causes: - User not in organization - Insufficient permissions - Team privacy restrictions
Solutions:
-
Ensure user is organization member first
-
For secret teams, verify you have appropriate access
-
Check token has
admin:orgscope
Repository Access Not Working¶
Causes: - Repository doesn't exist - Repository name incorrect - Team doesn't have required permissions
Solutions:
-
Verify repository exists:
-
Check repository name (don't include org prefix):
-
Ensure repository is created before granting team access
Organization Issues¶
Cannot Modify Organization Settings¶
Causes: - User is not organization owner - Token lacks admin:org scope
Solutions:
- Verify you're an organization owner:
- Go to organization → People
-
Check your role
-
Ask organization owner to run Terraform
-
Or ask owner to promote you to owner role
Organization Rulesets Not Available¶
Causes: - Organization is on Free plan - Feature not available on current plan
Solutions:
-
Use repository-level rulesets instead:
-
Upgrade to GitHub Team or Enterprise plan
YAML Configuration Issues¶
YAML Syntax Error¶
Causes: - Invalid YAML syntax - Incorrect indentation - Missing required fields
Solutions:
-
Validate YAML syntax:
-
Check indentation (use spaces, not tabs):
-
Verify required fields are present:
Cannot Load Configuration¶
Causes: - File doesn't exist - File path incorrect - Permission denied
Solutions:
-
Verify file exists:
-
Check file path in
locals.tf: -
Ensure file is readable:
GitHub API Issues¶
Rate Limit Exceeded¶
Causes: - Too many API requests - Using unauthenticated requests
Solutions:
-
Wait for rate limit to reset (usually 1 hour)
-
Ensure token is set (authenticated requests have higher limits)
-
Check rate limit status:
-
Use caching or reduce plan frequency
Service Unavailable¶
Causes: - GitHub API temporarily unavailable - Network connectivity issues
Solutions:
- Check GitHub status:
-
Retry after a few minutes
-
Check network connectivity:
CI/CD Issues¶
GitHub Actions Token Not Set¶
Causes: - Secret not configured - Secret name incorrect
Solutions:
- Add secret to repository:
- Settings → Secrets and variables → Actions
-
Add secret:
TERRAFORM_GITHUB_TOKEN -
Verify secret name in workflow:
Workflow Fails on Apply¶
Causes: - State lock held by another workflow - Concurrent runs - Permissions issue
Solutions:
-
Ensure only one workflow runs at a time:
-
Use workflow locks:
-
Check workflow permissions:
Getting Help¶
Enable Debug Logging¶
# Terraform debug logging
export TF_LOG=DEBUG
terraform apply
# GitHub CLI debug
gh api /repos/org/repo -H "Authorization: token $GITHUB_TOKEN" --include
Collect Information¶
When reporting issues, include:
-
Terraform version:
-
Provider version:
-
Error message (full output)
-
Relevant configuration (sanitize sensitive data)
-
Steps to reproduce
Resources¶
- Terraform GitHub Provider Documentation
- GitHub REST API Documentation
- GitHub Status
- Terraform Documentation
Community Support¶
Next Steps¶
- YAML Schema Reference - Complete configuration reference
- Best Practices - Avoid common pitfalls
- Getting Started Guide - Start fresh