Skip to content

ctfer-io/terraform-provider-ctfdcm

Terraform Provider for CTFd Chall-Manager plugin

Time for CTF(d) as Code, with Chall-Manager

reference go report Coverage Status
License CI CodeQL
OpenSSF Scoreboard

Why this ?

To manipulate our Terraform Provider for CTFd along with the Chall-Manager plugin. This enable reusing the configuration thus integrate seamlessly.

How to use it ?

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

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

provider "ctfdcm" {
    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 ctfdcm_challenge resource to setup your CTFd challenge, with for instance the following configuration.

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

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

    shared          = true
    destroy_on_flag = true
    mana_cost       = 1
    scenario_id     = ctfd_file.scenario.id
    timeout         = 600
}

resource "ctfd_file" "scenario" {
    name       = "scenario.zip"
    contentb64 = filebase64(".../scenario.zip")
}