com.pulumi.cloudflare.kotlin.WorkersScriptArgs.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-cloudflare-kotlin Show documentation
Show all versions of pulumi-cloudflare-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.cloudflare.kotlin
import com.pulumi.cloudflare.WorkersScriptArgs.builder
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptAnalyticsEngineBindingArgs
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptAnalyticsEngineBindingArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptD1DatabaseBindingArgs
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptD1DatabaseBindingArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptKvNamespaceBindingArgs
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptKvNamespaceBindingArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptPlacementArgs
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptPlacementArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptPlainTextBindingArgs
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptPlainTextBindingArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptQueueBindingArgs
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptQueueBindingArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptR2BucketBindingArgs
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptR2BucketBindingArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptSecretTextBindingArgs
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptSecretTextBindingArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptServiceBindingArgs
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptServiceBindingArgsBuilder
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptWebassemblyBindingArgs
import com.pulumi.cloudflare.kotlin.inputs.WorkersScriptWebassemblyBindingArgsBuilder
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.jvm.JvmName
/**
* Provides a Cloudflare worker script resource. In order for a script to be active, you'll also need to setup a `cloudflare.WorkerRoute`.
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as cloudflare from "@pulumi/cloudflare";
* import * as std from "@pulumi/std";
* const myNamespace = new cloudflare.WorkersKvNamespace("my_namespace", {
* accountId: "f037e56e89293a057740de681ac9abbe",
* title: "example",
* });
* // Sets the script with the name "script_1"
* const myScript = new cloudflare.WorkersScript("my_script", {
* accountId: "f037e56e89293a057740de681ac9abbe",
* name: "script_1",
* content: std.file({
* input: "script.js",
* }).then(invoke => invoke.result),
* kvNamespaceBindings: [{
* name: "MY_EXAMPLE_KV_NAMESPACE",
* namespaceId: myNamespace.id,
* }],
* plainTextBindings: [{
* name: "MY_EXAMPLE_PLAIN_TEXT",
* text: "foobar",
* }],
* secretTextBindings: [{
* name: "MY_EXAMPLE_SECRET_TEXT",
* text: secretFooValue,
* }],
* webassemblyBindings: [{
* name: "MY_EXAMPLE_WASM",
* module: std.filebase64({
* input: "example.wasm",
* }).then(invoke => invoke.result),
* }],
* serviceBindings: [{
* name: "MY_SERVICE_BINDING",
* service: "MY_SERVICE",
* environment: "production",
* }],
* r2BucketBindings: [{
* name: "MY_BUCKET",
* bucketName: "MY_BUCKET_NAME",
* }],
* analyticsEngineBindings: [{
* name: "MY_DATASET",
* dataset: "dataset1",
* }],
* });
* ```
* ```python
* import pulumi
* import pulumi_cloudflare as cloudflare
* import pulumi_std as std
* my_namespace = cloudflare.WorkersKvNamespace("my_namespace",
* account_id="f037e56e89293a057740de681ac9abbe",
* title="example")
* # Sets the script with the name "script_1"
* my_script = cloudflare.WorkersScript("my_script",
* account_id="f037e56e89293a057740de681ac9abbe",
* name="script_1",
* content=std.file(input="script.js").result,
* kv_namespace_bindings=[{
* "name": "MY_EXAMPLE_KV_NAMESPACE",
* "namespace_id": my_namespace.id,
* }],
* plain_text_bindings=[{
* "name": "MY_EXAMPLE_PLAIN_TEXT",
* "text": "foobar",
* }],
* secret_text_bindings=[{
* "name": "MY_EXAMPLE_SECRET_TEXT",
* "text": secret_foo_value,
* }],
* webassembly_bindings=[{
* "name": "MY_EXAMPLE_WASM",
* "module": std.filebase64(input="example.wasm").result,
* }],
* service_bindings=[{
* "name": "MY_SERVICE_BINDING",
* "service": "MY_SERVICE",
* "environment": "production",
* }],
* r2_bucket_bindings=[{
* "name": "MY_BUCKET",
* "bucket_name": "MY_BUCKET_NAME",
* }],
* analytics_engine_bindings=[{
* "name": "MY_DATASET",
* "dataset": "dataset1",
* }])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Cloudflare = Pulumi.Cloudflare;
* using Std = Pulumi.Std;
* return await Deployment.RunAsync(() =>
* {
* var myNamespace = new Cloudflare.WorkersKvNamespace("my_namespace", new()
* {
* AccountId = "f037e56e89293a057740de681ac9abbe",
* Title = "example",
* });
* // Sets the script with the name "script_1"
* var myScript = new Cloudflare.WorkersScript("my_script", new()
* {
* AccountId = "f037e56e89293a057740de681ac9abbe",
* Name = "script_1",
* Content = Std.File.Invoke(new()
* {
* Input = "script.js",
* }).Apply(invoke => invoke.Result),
* KvNamespaceBindings = new[]
* {
* new Cloudflare.Inputs.WorkersScriptKvNamespaceBindingArgs
* {
* Name = "MY_EXAMPLE_KV_NAMESPACE",
* NamespaceId = myNamespace.Id,
* },
* },
* PlainTextBindings = new[]
* {
* new Cloudflare.Inputs.WorkersScriptPlainTextBindingArgs
* {
* Name = "MY_EXAMPLE_PLAIN_TEXT",
* Text = "foobar",
* },
* },
* SecretTextBindings = new[]
* {
* new Cloudflare.Inputs.WorkersScriptSecretTextBindingArgs
* {
* Name = "MY_EXAMPLE_SECRET_TEXT",
* Text = secretFooValue,
* },
* },
* WebassemblyBindings = new[]
* {
* new Cloudflare.Inputs.WorkersScriptWebassemblyBindingArgs
* {
* Name = "MY_EXAMPLE_WASM",
* Module = Std.Filebase64.Invoke(new()
* {
* Input = "example.wasm",
* }).Apply(invoke => invoke.Result),
* },
* },
* ServiceBindings = new[]
* {
* new Cloudflare.Inputs.WorkersScriptServiceBindingArgs
* {
* Name = "MY_SERVICE_BINDING",
* Service = "MY_SERVICE",
* Environment = "production",
* },
* },
* R2BucketBindings = new[]
* {
* new Cloudflare.Inputs.WorkersScriptR2BucketBindingArgs
* {
* Name = "MY_BUCKET",
* BucketName = "MY_BUCKET_NAME",
* },
* },
* AnalyticsEngineBindings = new[]
* {
* new Cloudflare.Inputs.WorkersScriptAnalyticsEngineBindingArgs
* {
* Name = "MY_DATASET",
* Dataset = "dataset1",
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
* "github.com/pulumi/pulumi-std/sdk/go/std"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* myNamespace, err := cloudflare.NewWorkersKvNamespace(ctx, "my_namespace", &cloudflare.WorkersKvNamespaceArgs{
* AccountId: pulumi.String("f037e56e89293a057740de681ac9abbe"),
* Title: pulumi.String("example"),
* })
* if err != nil {
* return err
* }
* invokeFile, err := std.File(ctx, &std.FileArgs{
* Input: "script.js",
* }, nil)
* if err != nil {
* return err
* }
* invokeFilebase641, err := std.Filebase64(ctx, &std.Filebase64Args{
* Input: "example.wasm",
* }, nil)
* if err != nil {
* return err
* }
* // Sets the script with the name "script_1"
* _, err = cloudflare.NewWorkersScript(ctx, "my_script", &cloudflare.WorkersScriptArgs{
* AccountId: pulumi.String("f037e56e89293a057740de681ac9abbe"),
* Name: pulumi.String("script_1"),
* Content: pulumi.String(invokeFile.Result),
* KvNamespaceBindings: cloudflare.WorkersScriptKvNamespaceBindingArray{
* &cloudflare.WorkersScriptKvNamespaceBindingArgs{
* Name: pulumi.String("MY_EXAMPLE_KV_NAMESPACE"),
* NamespaceId: myNamespace.ID(),
* },
* },
* PlainTextBindings: cloudflare.WorkersScriptPlainTextBindingArray{
* &cloudflare.WorkersScriptPlainTextBindingArgs{
* Name: pulumi.String("MY_EXAMPLE_PLAIN_TEXT"),
* Text: pulumi.String("foobar"),
* },
* },
* SecretTextBindings: cloudflare.WorkersScriptSecretTextBindingArray{
* &cloudflare.WorkersScriptSecretTextBindingArgs{
* Name: pulumi.String("MY_EXAMPLE_SECRET_TEXT"),
* Text: pulumi.Any(secretFooValue),
* },
* },
* WebassemblyBindings: cloudflare.WorkersScriptWebassemblyBindingArray{
* &cloudflare.WorkersScriptWebassemblyBindingArgs{
* Name: pulumi.String("MY_EXAMPLE_WASM"),
* Module: pulumi.String(invokeFilebase641.Result),
* },
* },
* ServiceBindings: cloudflare.WorkersScriptServiceBindingArray{
* &cloudflare.WorkersScriptServiceBindingArgs{
* Name: pulumi.String("MY_SERVICE_BINDING"),
* Service: pulumi.String("MY_SERVICE"),
* Environment: pulumi.String("production"),
* },
* },
* R2BucketBindings: cloudflare.WorkersScriptR2BucketBindingArray{
* &cloudflare.WorkersScriptR2BucketBindingArgs{
* Name: pulumi.String("MY_BUCKET"),
* BucketName: pulumi.String("MY_BUCKET_NAME"),
* },
* },
* AnalyticsEngineBindings: cloudflare.WorkersScriptAnalyticsEngineBindingArray{
* &cloudflare.WorkersScriptAnalyticsEngineBindingArgs{
* Name: pulumi.String("MY_DATASET"),
* Dataset: pulumi.String("dataset1"),
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.cloudflare.WorkersKvNamespace;
* import com.pulumi.cloudflare.WorkersKvNamespaceArgs;
* import com.pulumi.cloudflare.WorkersScript;
* import com.pulumi.cloudflare.WorkersScriptArgs;
* import com.pulumi.cloudflare.inputs.WorkersScriptKvNamespaceBindingArgs;
* import com.pulumi.cloudflare.inputs.WorkersScriptPlainTextBindingArgs;
* import com.pulumi.cloudflare.inputs.WorkersScriptSecretTextBindingArgs;
* import com.pulumi.cloudflare.inputs.WorkersScriptWebassemblyBindingArgs;
* import com.pulumi.cloudflare.inputs.WorkersScriptServiceBindingArgs;
* import com.pulumi.cloudflare.inputs.WorkersScriptR2BucketBindingArgs;
* import com.pulumi.cloudflare.inputs.WorkersScriptAnalyticsEngineBindingArgs;
* 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 myNamespace = new WorkersKvNamespace("myNamespace", WorkersKvNamespaceArgs.builder()
* .accountId("f037e56e89293a057740de681ac9abbe")
* .title("example")
* .build());
* // Sets the script with the name "script_1"
* var myScript = new WorkersScript("myScript", WorkersScriptArgs.builder()
* .accountId("f037e56e89293a057740de681ac9abbe")
* .name("script_1")
* .content(StdFunctions.file(FileArgs.builder()
* .input("script.js")
* .build()).result())
* .kvNamespaceBindings(WorkersScriptKvNamespaceBindingArgs.builder()
* .name("MY_EXAMPLE_KV_NAMESPACE")
* .namespaceId(myNamespace.id())
* .build())
* .plainTextBindings(WorkersScriptPlainTextBindingArgs.builder()
* .name("MY_EXAMPLE_PLAIN_TEXT")
* .text("foobar")
* .build())
* .secretTextBindings(WorkersScriptSecretTextBindingArgs.builder()
* .name("MY_EXAMPLE_SECRET_TEXT")
* .text(secretFooValue)
* .build())
* .webassemblyBindings(WorkersScriptWebassemblyBindingArgs.builder()
* .name("MY_EXAMPLE_WASM")
* .module(StdFunctions.filebase64(Filebase64Args.builder()
* .input("example.wasm")
* .build()).result())
* .build())
* .serviceBindings(WorkersScriptServiceBindingArgs.builder()
* .name("MY_SERVICE_BINDING")
* .service("MY_SERVICE")
* .environment("production")
* .build())
* .r2BucketBindings(WorkersScriptR2BucketBindingArgs.builder()
* .name("MY_BUCKET")
* .bucketName("MY_BUCKET_NAME")
* .build())
* .analyticsEngineBindings(WorkersScriptAnalyticsEngineBindingArgs.builder()
* .name("MY_DATASET")
* .dataset("dataset1")
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* myNamespace:
* type: cloudflare:WorkersKvNamespace
* name: my_namespace
* properties:
* accountId: f037e56e89293a057740de681ac9abbe
* title: example
* # Sets the script with the name "script_1"
* myScript:
* type: cloudflare:WorkersScript
* name: my_script
* properties:
* accountId: f037e56e89293a057740de681ac9abbe
* name: script_1
* content:
* fn::invoke:
* Function: std:file
* Arguments:
* input: script.js
* Return: result
* kvNamespaceBindings:
* - name: MY_EXAMPLE_KV_NAMESPACE
* namespaceId: ${myNamespace.id}
* plainTextBindings:
* - name: MY_EXAMPLE_PLAIN_TEXT
* text: foobar
* secretTextBindings:
* - name: MY_EXAMPLE_SECRET_TEXT
* text: ${secretFooValue}
* webassemblyBindings:
* - name: MY_EXAMPLE_WASM
* module:
* fn::invoke:
* Function: std:filebase64
* Arguments:
* input: example.wasm
* Return: result
* serviceBindings:
* - name: MY_SERVICE_BINDING
* service: MY_SERVICE
* environment: production
* r2BucketBindings:
* - name: MY_BUCKET
* bucketName: MY_BUCKET_NAME
* analyticsEngineBindings:
* - name: MY_DATASET
* dataset: dataset1
* ```
*
* ## Import
* ```sh
* $ pulumi import cloudflare:index/workersScript:WorkersScript example /
* ```
* @property accountId The account identifier to target for the resource.
* @property analyticsEngineBindings
* @property compatibilityDate The date to use for the compatibility flag.
* @property compatibilityFlags Compatibility flags used for Worker Scripts.
* @property content The script content.
* @property d1DatabaseBindings
* @property dispatchNamespace Name of the Workers for Platforms dispatch namespace.
* @property kvNamespaceBindings
* @property logpush Enabling allows Worker events to be sent to a defined Logpush destination.
* @property module Whether to upload Worker as a module.
* @property name The name for the script. **Modifying this attribute will force creation of a new resource.**
* @property placements
* @property plainTextBindings
* @property queueBindings
* @property r2BucketBindings
* @property secretTextBindings
* @property serviceBindings
* @property tags
* @property webassemblyBindings
*/
public data class WorkersScriptArgs(
public val accountId: Output? = null,
public val analyticsEngineBindings: Output>? = null,
public val compatibilityDate: Output? = null,
public val compatibilityFlags: Output>? = null,
public val content: Output? = null,
public val d1DatabaseBindings: Output>? = null,
public val dispatchNamespace: Output? = null,
public val kvNamespaceBindings: Output>? = null,
public val logpush: Output? = null,
public val module: Output? = null,
public val name: Output? = null,
public val placements: Output>? = null,
public val plainTextBindings: Output>? = null,
public val queueBindings: Output>? = null,
public val r2BucketBindings: Output>? = null,
public val secretTextBindings: Output>? = null,
public val serviceBindings: Output>? = null,
public val tags: Output>? = null,
public val webassemblyBindings: Output>? = null,
) : ConvertibleToJava {
override fun toJava(): com.pulumi.cloudflare.WorkersScriptArgs =
com.pulumi.cloudflare.WorkersScriptArgs.builder()
.accountId(accountId?.applyValue({ args0 -> args0 }))
.analyticsEngineBindings(
analyticsEngineBindings?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> args0.toJava() })
})
}),
)
.compatibilityDate(compatibilityDate?.applyValue({ args0 -> args0 }))
.compatibilityFlags(compatibilityFlags?.applyValue({ args0 -> args0.map({ args0 -> args0 }) }))
.content(content?.applyValue({ args0 -> args0 }))
.d1DatabaseBindings(
d1DatabaseBindings?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> args0.toJava() })
})
}),
)
.dispatchNamespace(dispatchNamespace?.applyValue({ args0 -> args0 }))
.kvNamespaceBindings(
kvNamespaceBindings?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> args0.toJava() })
})
}),
)
.logpush(logpush?.applyValue({ args0 -> args0 }))
.module(module?.applyValue({ args0 -> args0 }))
.name(name?.applyValue({ args0 -> args0 }))
.placements(
placements?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
args0.toJava()
})
})
}),
)
.plainTextBindings(
plainTextBindings?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
args0.toJava()
})
})
}),
)
.queueBindings(
queueBindings?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
args0.toJava()
})
})
}),
)
.r2BucketBindings(
r2BucketBindings?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
args0.toJava()
})
})
}),
)
.secretTextBindings(
secretTextBindings?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> args0.toJava() })
})
}),
)
.serviceBindings(
serviceBindings?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
args0.toJava()
})
})
}),
)
.tags(tags?.applyValue({ args0 -> args0.map({ args0 -> args0 }) }))
.webassemblyBindings(
webassemblyBindings?.applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> args0.toJava() })
})
}),
).build()
}
/**
* Builder for [WorkersScriptArgs].
*/
@PulumiTagMarker
public class WorkersScriptArgsBuilder internal constructor() {
private var accountId: Output? = null
private var analyticsEngineBindings: Output>? = null
private var compatibilityDate: Output? = null
private var compatibilityFlags: Output>? = null
private var content: Output? = null
private var d1DatabaseBindings: Output>? = null
private var dispatchNamespace: Output? = null
private var kvNamespaceBindings: Output>? = null
private var logpush: Output? = null
private var module: Output? = null
private var name: Output? = null
private var placements: Output>? = null
private var plainTextBindings: Output>? = null
private var queueBindings: Output>? = null
private var r2BucketBindings: Output>? = null
private var secretTextBindings: Output>? = null
private var serviceBindings: Output>? = null
private var tags: Output>? = null
private var webassemblyBindings: Output>? = null
/**
* @param value The account identifier to target for the resource.
*/
@JvmName("jgiyrelshovmmgjo")
public suspend fun accountId(`value`: Output) {
this.accountId = value
}
/**
* @param value
*/
@JvmName("cnayudslufgklqxh")
public suspend fun analyticsEngineBindings(`value`: Output>) {
this.analyticsEngineBindings = value
}
@JvmName("bjrxlmqirdymlsfe")
public suspend fun analyticsEngineBindings(vararg values: Output) {
this.analyticsEngineBindings = Output.all(values.asList())
}
/**
* @param values
*/
@JvmName("qpqpesebapkisjgw")
public suspend fun analyticsEngineBindings(values: List