terraform-provider-ctfd

command module
v0.0.0-...-18cdda1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2022 License: MPL-2.0 Imports: 5 Imported by: 0

README

terraform-provider-ctfd

This repository is a built from the terraform-provider-scaffolding GitHub template.

The contents of the api package are taken from the hashicups-client-go demo. API client.

Requirements

Building The Provider

  1. Clone the repository
  2. Enter the repository directory
  3. Build the provider using the Go install command:
go install

Adding Dependencies

This provider uses Go modules. Please see the Go documentation for the most up to date information about using Go modules.

To add a new dependency github.com/PsypherPunk/ctfd to your Terraform provider:

go get github.com/PsypherPunk/ctfd
go mod tidy

Then commit the changes to go.mod and go.sum.

Using the provider

The provider assumes a running CTFd instance with the Admin. user already created: this is used to interact with the CTFd instance:

provider "ctfd" {
  username = "admin"
  password = "admin"
  url      = "http://0.0.0.0:8000/"
}
Data Sources
Challenges
data "ctfd_challenges" "challenges" {}

output "challenges" {
  value = data.ctfd_challenges.challenges
}
Resources
Setup

i.e. the initial configuration of the Admin. user and import of challenges from a juice-shop-ctf) instance:

resource "ctfd_setup" "setup" {
  name               = "CTFd Instance"
  description        = "This is a test CTFd intance."
  admin_email        = "ctfd.admin@example.com"
  configuration_path = "/tmp/juice-shop-ctf-export.zip"
}
Teams
resource "ctfd_team" "first_team" {
  name     = "First Team"
  email    = "first.team@example.com"
  password = "pass"
}
Users
resource "ctfd_user" "first_user" {
  name     = "First User"
  email    = "first.user@example.com"
  password = "pass"
  type     = "user"
}
Membership
resource "ctfd_user_team_membership" "first_user" {
  team_id = ctfd_team.first_team.id
  user_id = ctfd_user.first_user.id
}

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).

To compile the provider, run go install. This will build the provider and put the provider binary in the $GOPATH/bin directory.

To generate or update documentation, run go generate.

In order to run the full suite of Acceptance tests, run make testacc.

Note: Acceptance tests create real resources, and often cost money to run.

make testacc

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL