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
- Clone the repository
- Enter the repository directory
- 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/"
}
Challenges
data "ctfd_challenges" "challenges" {}
output "challenges" {
value = data.ctfd_challenges.challenges
}
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