Skip to content

hystking/terraform-provider-coderabbit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Provider for CodeRabbit

A Terraform provider for managing CodeRabbit seat assignments.

Features

  • coderabbit_seats resource: Assign/unassign seats to GitHub users
  • coderabbit_seats data source: Retrieve current seat assignment status

Installation

Local Build

# Install dependencies
make deps

# Build and install locally
make install

Terraform Registry (after publication)

terraform {
  required_providers {
    coderabbit = {
      source  = "hystking/coderabbit"
      version = "~> 0.1.0"
    }
  }
}

Usage

Provider Configuration

provider "coderabbit" {
  # API key can also be set via CODERABBITAI_API_KEY environment variable
  api_key = "your-api-key"

  # Optional: Custom API endpoint (default: https://api.coderabbit.ai)
  # base_url = "https://api.coderabbit.ai"

  # Optional: GitHub token for API authentication (higher rate limits)
  # Can also be set via GITHUB_TOKEN environment variable
  # github_token = "ghp_xxxxxxxxxxxx"
}

Environment Variables

Variable Description
CODERABBITAI_API_KEY CodeRabbit API authentication key
CODERABBIT_BASE_URL API base URL (optional)
GITHUB_TOKEN GitHub personal access token for higher rate limits (optional)

Assigning Seats

Specify a GitHub username to assign a seat. The provider automatically resolves the username to a numeric user ID via the GitHub API.

resource "coderabbit_seats" "developer1" {
  github_id = "octocat"
}

resource "coderabbit_seats" "developer2" {
  github_id = "defunkt"
}

Attributes

Attribute Type Required Description
github_id string Yes GitHub username (e.g., "octocat")
git_user_id string - Resolved numeric GitHub user ID (computed)
id string - Resource ID (computed)

Retrieving Seat Information

data "coderabbit_seats" "all" {}

output "users_with_seats" {
  value = data.coderabbit_seats.all.users_with_seats
}

output "users_without_seats" {
  value = data.coderabbit_seats.all.users_without_seats
}

Attributes

Attribute Type Description
users_with_seats list(string) List of user IDs with assigned seats
users_without_seats list(string) List of user IDs without assigned seats

Complete Example

terraform {
  required_providers {
    coderabbit = {
      source = "hystking/coderabbit"
    }
  }
}

provider "coderabbit" {}

# Assign seats to team members
resource "coderabbit_seats" "team" {
  for_each  = toset(["alice", "bob", "charlie"])
  github_id = each.value
}

# Check current seat status
data "coderabbit_seats" "current" {}

output "assigned_users" {
  value = data.coderabbit_seats.current.users_with_seats
}

Development

Requirements

  • Go 1.21+
  • Terraform 1.0+

Commands

# Build
make build

# Local install
make install

# Test
make test

# Format
make fmt

# Static analysis
make vet

# Clean up
make clean

Reference Documentation

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors