ctfd.File
Explore with Pulumi AI
A CTFd file for a challenge.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as ctfd from "@ctfer-io/pulumi-ctfd";
import * as fs from "fs";
const http = new ctfd.Challenge("http", {
category: "misc",
description: "...",
value: 500,
decay: 100,
minimum: 50,
state: "visible",
"function": "logarithmic",
topics: ["Misc"],
tags: [
"misc",
"basic",
],
});
const httpFile = new ctfd.File("httpFile", {
challengeId: http.id,
contentb64: fs.readFileSync(".../image.png", { encoding: "base64" }),
});
import pulumi
import base64
import ctfer-io_pulumi-ctfd as ctfd
http = ctfd.Challenge("http",
category="misc",
description="...",
value=500,
decay=100,
minimum=50,
state="visible",
function="logarithmic",
topics=["Misc"],
tags=[
"misc",
"basic",
])
http_file = ctfd.File("httpFile",
challenge_id=http.id,
contentb64=(lambda path: base64.b64encode(open(path).read().encode()).decode())(".../image.png"))
package main
import (
"encoding/base64"
"os"
"github.com/ctfer-io/pulumi-ctfd/sdk/go/ctfd"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func filebase64OrPanic(path string) string {
if fileData, err := os.ReadFile(path); err == nil {
return base64.StdEncoding.EncodeToString(fileData[:])
} else {
panic(err.Error())
}
}
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
http, err := ctfd.NewChallenge(ctx, "http", &ctfd.ChallengeArgs{
Category: pulumi.String("misc"),
Description: pulumi.String("..."),
Value: pulumi.Int(500),
Decay: pulumi.Int(100),
Minimum: pulumi.Int(50),
State: pulumi.String("visible"),
Function: pulumi.String("logarithmic"),
Topics: pulumi.StringArray{
pulumi.String("Misc"),
},
Tags: pulumi.StringArray{
pulumi.String("misc"),
pulumi.String("basic"),
},
})
if err != nil {
return err
}
_, err = ctfd.NewFile(ctx, "httpFile", &ctfd.FileArgs{
ChallengeId: http.ID(),
Contentb64: filebase64OrPanic(".../image.png"),
})
if err != nil {
return err
}
return nil
})
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Pulumi;
using Ctfd = CTFerio.Ctfd;
string ReadFileBase64(string path)
{
return Convert.ToBase64String(Encoding.UTF8.GetBytes(File.ReadAllText(path)));
}
return await Deployment.RunAsync(() =>
{
var http = new Ctfd.Challenge("http", new()
{
Category = "misc",
Description = "...",
Value = 500,
Decay = 100,
Minimum = 50,
State = "visible",
Function = "logarithmic",
Topics = new[]
{
"Misc",
},
Tags = new[]
{
"misc",
"basic",
},
});
var httpFile = new Ctfd.File("httpFile", new()
{
ChallengeId = http.Id,
Contentb64 = ReadFileBase64(".../image.png"),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ctfd.Challenge;
import com.pulumi.ctfd.ChallengeArgs;
import com.pulumi.ctfd.File;
import com.pulumi.ctfd.FileArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var http = new Challenge("http", ChallengeArgs.builder()
.category("misc")
.description("...")
.value(500)
.decay(100)
.minimum(50)
.state("visible")
.function("logarithmic")
.topics("Misc")
.tags(
"misc",
"basic")
.build());
var httpFile = new File("httpFile", FileArgs.builder()
.challengeId(http.id())
.contentb64(Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get(".../image.png"))))
.build());
}
}
Coming soon!
Create File Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new File(name: string, args?: FileArgs, opts?: CustomResourceOptions);
@overload
def File(resource_name: str,
args: Optional[FileArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
def File(resource_name: str,
opts: Optional[ResourceOptions] = None,
challenge_id: Optional[str] = None,
content: Optional[str] = None,
contentb64: Optional[str] = None,
location: Optional[str] = None,
name: Optional[str] = None)
func NewFile(ctx *Context, name string, args *FileArgs, opts ...ResourceOption) (*File, error)
public File(string name, FileArgs? args = null, CustomResourceOptions? opts = null)
type: ctfd:File
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args FileArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args FileArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args FileArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args FileArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args FileArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var fileResource = new Ctfd.File("fileResource", new()
{
ChallengeId = "string",
Content = "string",
Contentb64 = "string",
Location = "string",
Name = "string",
});
example, err := ctfd.NewFile(ctx, "fileResource", &ctfd.FileArgs{
ChallengeId: pulumi.String("string"),
Content: pulumi.String("string"),
Contentb64: pulumi.String("string"),
Location: pulumi.String("string"),
Name: pulumi.String("string"),
})
var fileResource = new File("fileResource", FileArgs.builder()
.challengeId("string")
.content("string")
.contentb64("string")
.location("string")
.name("string")
.build());
file_resource = ctfd.File("fileResource",
challenge_id="string",
content="string",
contentb64="string",
location="string",
name="string")
const fileResource = new ctfd.File("fileResource", {
challengeId: "string",
content: "string",
contentb64: "string",
location: "string",
name: "string",
});
type: ctfd:File
properties:
challengeId: string
content: string
contentb64: string
location: string
name: string
File Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The File resource accepts the following input properties:
- Challenge
Id string - Challenge of the file.
- Content string
- Raw content of the file, perfectly fit the use-cases of a .txt document or anything with a simple binary content. You could provide it from the file-system using
file("${path.module}/...")
. - Contentb64 string
- Base 64 content of the file, perfectly fit the use-cases of complex binaries. You could provide it from the file-system using
filebase64("${path.module}/...")
. - Location string
- Location where the file is stored on the CTFd instance, for download purposes.
- Name string
- Name of the file as displayed to end-users.
- Challenge
Id string - Challenge of the file.
- Content string
- Raw content of the file, perfectly fit the use-cases of a .txt document or anything with a simple binary content. You could provide it from the file-system using
file("${path.module}/...")
. - Contentb64 string
- Base 64 content of the file, perfectly fit the use-cases of complex binaries. You could provide it from the file-system using
filebase64("${path.module}/...")
. - Location string
- Location where the file is stored on the CTFd instance, for download purposes.
- Name string
- Name of the file as displayed to end-users.
- challenge
Id String - Challenge of the file.
- content String
- Raw content of the file, perfectly fit the use-cases of a .txt document or anything with a simple binary content. You could provide it from the file-system using
file("${path.module}/...")
. - contentb64 String
- Base 64 content of the file, perfectly fit the use-cases of complex binaries. You could provide it from the file-system using
filebase64("${path.module}/...")
. - location String
- Location where the file is stored on the CTFd instance, for download purposes.
- name String
- Name of the file as displayed to end-users.
- challenge
Id string - Challenge of the file.
- content string
- Raw content of the file, perfectly fit the use-cases of a .txt document or anything with a simple binary content. You could provide it from the file-system using
file("${path.module}/...")
. - contentb64 string
- Base 64 content of the file, perfectly fit the use-cases of complex binaries. You could provide it from the file-system using
filebase64("${path.module}/...")
. - location string
- Location where the file is stored on the CTFd instance, for download purposes.
- name string
- Name of the file as displayed to end-users.
- challenge_
id str - Challenge of the file.
- content str
- Raw content of the file, perfectly fit the use-cases of a .txt document or anything with a simple binary content. You could provide it from the file-system using
file("${path.module}/...")
. - contentb64 str
- Base 64 content of the file, perfectly fit the use-cases of complex binaries. You could provide it from the file-system using
filebase64("${path.module}/...")
. - location str
- Location where the file is stored on the CTFd instance, for download purposes.
- name str
- Name of the file as displayed to end-users.
- challenge
Id String - Challenge of the file.
- content String
- Raw content of the file, perfectly fit the use-cases of a .txt document or anything with a simple binary content. You could provide it from the file-system using
file("${path.module}/...")
. - contentb64 String
- Base 64 content of the file, perfectly fit the use-cases of complex binaries. You could provide it from the file-system using
filebase64("${path.module}/...")
. - location String
- Location where the file is stored on the CTFd instance, for download purposes.
- name String
- Name of the file as displayed to end-users.
Outputs
All input properties are implicitly available as output properties. Additionally, the File resource produces the following output properties:
Look up Existing File Resource
Get an existing File resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: FileState, opts?: CustomResourceOptions): File
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
challenge_id: Optional[str] = None,
content: Optional[str] = None,
contentb64: Optional[str] = None,
location: Optional[str] = None,
name: Optional[str] = None,
sha1sum: Optional[str] = None) -> File
func GetFile(ctx *Context, name string, id IDInput, state *FileState, opts ...ResourceOption) (*File, error)
public static File Get(string name, Input<string> id, FileState? state, CustomResourceOptions? opts = null)
public static File get(String name, Output<String> id, FileState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Challenge
Id string - Challenge of the file.
- Content string
- Raw content of the file, perfectly fit the use-cases of a .txt document or anything with a simple binary content. You could provide it from the file-system using
file("${path.module}/...")
. - Contentb64 string
- Base 64 content of the file, perfectly fit the use-cases of complex binaries. You could provide it from the file-system using
filebase64("${path.module}/...")
. - Location string
- Location where the file is stored on the CTFd instance, for download purposes.
- Name string
- Name of the file as displayed to end-users.
- Sha1sum string
- The sha1 sum of the file.
- Challenge
Id string - Challenge of the file.
- Content string
- Raw content of the file, perfectly fit the use-cases of a .txt document or anything with a simple binary content. You could provide it from the file-system using
file("${path.module}/...")
. - Contentb64 string
- Base 64 content of the file, perfectly fit the use-cases of complex binaries. You could provide it from the file-system using
filebase64("${path.module}/...")
. - Location string
- Location where the file is stored on the CTFd instance, for download purposes.
- Name string
- Name of the file as displayed to end-users.
- Sha1sum string
- The sha1 sum of the file.
- challenge
Id String - Challenge of the file.
- content String
- Raw content of the file, perfectly fit the use-cases of a .txt document or anything with a simple binary content. You could provide it from the file-system using
file("${path.module}/...")
. - contentb64 String
- Base 64 content of the file, perfectly fit the use-cases of complex binaries. You could provide it from the file-system using
filebase64("${path.module}/...")
. - location String
- Location where the file is stored on the CTFd instance, for download purposes.
- name String
- Name of the file as displayed to end-users.
- sha1sum String
- The sha1 sum of the file.
- challenge
Id string - Challenge of the file.
- content string
- Raw content of the file, perfectly fit the use-cases of a .txt document or anything with a simple binary content. You could provide it from the file-system using
file("${path.module}/...")
. - contentb64 string
- Base 64 content of the file, perfectly fit the use-cases of complex binaries. You could provide it from the file-system using
filebase64("${path.module}/...")
. - location string
- Location where the file is stored on the CTFd instance, for download purposes.
- name string
- Name of the file as displayed to end-users.
- sha1sum string
- The sha1 sum of the file.
- challenge_
id str - Challenge of the file.
- content str
- Raw content of the file, perfectly fit the use-cases of a .txt document or anything with a simple binary content. You could provide it from the file-system using
file("${path.module}/...")
. - contentb64 str
- Base 64 content of the file, perfectly fit the use-cases of complex binaries. You could provide it from the file-system using
filebase64("${path.module}/...")
. - location str
- Location where the file is stored on the CTFd instance, for download purposes.
- name str
- Name of the file as displayed to end-users.
- sha1sum str
- The sha1 sum of the file.
- challenge
Id String - Challenge of the file.
- content String
- Raw content of the file, perfectly fit the use-cases of a .txt document or anything with a simple binary content. You could provide it from the file-system using
file("${path.module}/...")
. - contentb64 String
- Base 64 content of the file, perfectly fit the use-cases of complex binaries. You could provide it from the file-system using
filebase64("${path.module}/...")
. - location String
- Location where the file is stored on the CTFd instance, for download purposes.
- name String
- Name of the file as displayed to end-users.
- sha1sum String
- The sha1 sum of the file.
Package Details
- Repository
- ctfd ctfer-io/pulumi-ctfd
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
ctfd
Terraform Provider.