Skip to content

ctfer-io/terraform-provider-ctfd

Terraform Provider for CTFd

Time for CTF(d) as Code

reference go report Coverage Status
License CI CodeQL
OpenSSF Scoreboard

Why creating this ?

Terraform is used to manage resources that have lifecycles, configurations, to sum it up.

That is the case of CTFd: it handles challenges that could be created, modified and deleted. With some work to leverage the unsteady CTFd's API, Terraform is now able to manage them as cloud resources bringing you to opportunity of CTF as Code.

With a paradigm-shifting vision of setting up CTFs, the Terraform Provider for CTFd avoid shitty scripts, ctfcli and other tools that does not solve the problem of reproductibility, ease of deployment and resiliency.

How to use it ?

Install the Terraform Provider for CTFd by setting the following in your main.tf file.

terraform {
    required_providers {
        ctfd = {
            source = "registry.terraform.io/ctfer-io/ctfd"
        }
    }
}

provider "ctfd" {
    url = "https://my-ctfd.lan"
}

We recommend setting the environment variable CTFD_API_KEY to enable the provider to communicate with your CTFd instance.

Then, you could use a ctfd_challenge resource to setup your CTFd challenge, with for instance the following configuration.

resource "ctfd_challenge" "my_challenge" {
    name        = "My Challenge"
    category    = "Some category"
    description = <<-EOT
        My superb description !

        And it's multiline :o
    EOT
    state       = "visible"
    value       = 500
}