com.pulumi.cloudflare.kotlin.WorkersRoute.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.
The newest version!
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.cloudflare.kotlin
import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
/**
* Builder for [WorkersRoute].
*/
@PulumiTagMarker
public class WorkersRouteResourceBuilder internal constructor() {
public var name: String? = null
public var args: WorkersRouteArgs = WorkersRouteArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend WorkersRouteArgsBuilder.() -> Unit) {
val builder = WorkersRouteArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): WorkersRoute {
val builtJavaResource = com.pulumi.cloudflare.WorkersRoute(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return WorkersRoute(builtJavaResource)
}
}
/**
* Provides a Cloudflare worker route resource. A route will also require a `cloudflare.WorkerScript`.
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as cloudflare from "@pulumi/cloudflare";
* const myScript = new cloudflare.WorkersScript("my_script", {});
* // Runs the specified worker script for all URLs that match `example.com/*`
* const myRoute = new cloudflare.WorkersRoute("my_route", {
* zoneId: "0da42c8d2132a9ddaf714f9e7c920711",
* pattern: "example.com/*",
* scriptName: myScript.name,
* });
* ```
* ```python
* import pulumi
* import pulumi_cloudflare as cloudflare
* my_script = cloudflare.WorkersScript("my_script")
* # Runs the specified worker script for all URLs that match `example.com/*`
* my_route = cloudflare.WorkersRoute("my_route",
* zone_id="0da42c8d2132a9ddaf714f9e7c920711",
* pattern="example.com/*",
* script_name=my_script.name)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Cloudflare = Pulumi.Cloudflare;
* return await Deployment.RunAsync(() =>
* {
* var myScript = new Cloudflare.WorkersScript("my_script");
* // Runs the specified worker script for all URLs that match `example.com/*`
* var myRoute = new Cloudflare.WorkersRoute("my_route", new()
* {
* ZoneId = "0da42c8d2132a9ddaf714f9e7c920711",
* Pattern = "example.com/*",
* ScriptName = myScript.Name,
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* myScript, err := cloudflare.NewWorkersScript(ctx, "my_script", nil)
* if err != nil {
* return err
* }
* // Runs the specified worker script for all URLs that match `example.com/*`
* _, err = cloudflare.NewWorkersRoute(ctx, "my_route", &cloudflare.WorkersRouteArgs{
* ZoneId: pulumi.String("0da42c8d2132a9ddaf714f9e7c920711"),
* Pattern: pulumi.String("example.com/*"),
* ScriptName: myScript.Name,
* })
* 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.WorkersScript;
* import com.pulumi.cloudflare.WorkersRoute;
* import com.pulumi.cloudflare.WorkersRouteArgs;
* 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 myScript = new WorkersScript("myScript");
* // Runs the specified worker script for all URLs that match `example.com/*`
* var myRoute = new WorkersRoute("myRoute", WorkersRouteArgs.builder()
* .zoneId("0da42c8d2132a9ddaf714f9e7c920711")
* .pattern("example.com/*")
* .scriptName(myScript.name())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* # Runs the specified worker script for all URLs that match `example.com/*`
* myRoute:
* type: cloudflare:WorkersRoute
* name: my_route
* properties:
* zoneId: 0da42c8d2132a9ddaf714f9e7c920711
* pattern: example.com/*
* scriptName: ${myScript.name}
* myScript:
* type: cloudflare:WorkersScript
* name: my_script
* ```
*
* ## Import
* ```sh
* $ pulumi import cloudflare:index/workersRoute:WorkersRoute example /
* ```
* */*/*/*/*/*/*/*/*/*/*/*/
*/
public class WorkersRoute internal constructor(
override val javaResource: com.pulumi.cloudflare.WorkersRoute,
) : KotlinCustomResource(javaResource, WorkersRouteMapper) {
/**
* The [route pattern](https://developers.cloudflare.com/workers/about/routes/) to associate the Worker with.
*/
public val pattern: Output
get() = javaResource.pattern().applyValue({ args0 -> args0 })
/**
* Worker script name to invoke for requests that match the route pattern.
*/
public val scriptName: Output?
get() = javaResource.scriptName().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* The zone identifier to target for the resource. **Modifying this attribute will force creation of a new resource.**
*/
public val zoneId: Output
get() = javaResource.zoneId().applyValue({ args0 -> args0 })
}
public object WorkersRouteMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.cloudflare.WorkersRoute::class == javaResource::class
override fun map(javaResource: Resource): WorkersRoute = WorkersRoute(
javaResource as
com.pulumi.cloudflare.WorkersRoute,
)
}
/**
* @see [WorkersRoute].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [WorkersRoute].
*/
public suspend fun workersRoute(
name: String,
block: suspend WorkersRouteResourceBuilder.() -> Unit,
): WorkersRoute {
val builder = WorkersRouteResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [WorkersRoute].
* @param name The _unique_ name of the resulting resource.
*/
public fun workersRoute(name: String): WorkersRoute {
val builder = WorkersRouteResourceBuilder()
builder.name(name)
return builder.build()
}