com.pulumi.gcp.appengine.kotlin.ApplicationUrlDispatchRules.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-gcp-kotlin Show documentation
Show all versions of pulumi-gcp-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.gcp.appengine.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.appengine.kotlin.outputs.ApplicationUrlDispatchRulesDispatchRule
import com.pulumi.gcp.appengine.kotlin.outputs.ApplicationUrlDispatchRulesDispatchRule.Companion.toKotlin
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
import kotlin.collections.List
/**
* Builder for [ApplicationUrlDispatchRules].
*/
@PulumiTagMarker
public class ApplicationUrlDispatchRulesResourceBuilder internal constructor() {
public var name: String? = null
public var args: ApplicationUrlDispatchRulesArgs = ApplicationUrlDispatchRulesArgs()
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 ApplicationUrlDispatchRulesArgsBuilder.() -> Unit) {
val builder = ApplicationUrlDispatchRulesArgsBuilder()
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(): ApplicationUrlDispatchRules {
val builtJavaResource =
com.pulumi.gcp.appengine.ApplicationUrlDispatchRules(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return ApplicationUrlDispatchRules(builtJavaResource)
}
}
/**
* Rules to match an HTTP request and dispatch that request to a service.
* To get more information about ApplicationUrlDispatchRules, see:
* * [API documentation](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps#UrlDispatchRule)
* ## Example Usage
* ### App Engine Application Url Dispatch Rules Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const bucket = new gcp.storage.Bucket("bucket", {
* name: "appengine-test-bucket",
* location: "US",
* });
* const object = new gcp.storage.BucketObject("object", {
* name: "hello-world.zip",
* bucket: bucket.name,
* source: new pulumi.asset.FileAsset("./test-fixtures/hello-world.zip"),
* });
* const adminV3 = new gcp.appengine.StandardAppVersion("admin_v3", {
* versionId: "v3",
* service: "admin",
* runtime: "nodejs20",
* entrypoint: {
* shell: "node ./app.js",
* },
* deployment: {
* zip: {
* sourceUrl: pulumi.interpolate`https://storage.googleapis.com/${bucket.name}/${object.name}`,
* },
* },
* envVariables: {
* port: "8080",
* },
* deleteServiceOnDestroy: true,
* });
* const webService = new gcp.appengine.ApplicationUrlDispatchRules("web_service", {dispatchRules: [
* {
* domain: "*",
* path: "/*",
* service: "default",
* },
* {
* domain: "*",
* path: "/admin/*",
* service: adminV3.service,
* },
* ]});
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* bucket = gcp.storage.Bucket("bucket",
* name="appengine-test-bucket",
* location="US")
* object = gcp.storage.BucketObject("object",
* name="hello-world.zip",
* bucket=bucket.name,
* source=pulumi.FileAsset("./test-fixtures/hello-world.zip"))
* admin_v3 = gcp.appengine.StandardAppVersion("admin_v3",
* version_id="v3",
* service="admin",
* runtime="nodejs20",
* entrypoint=gcp.appengine.StandardAppVersionEntrypointArgs(
* shell="node ./app.js",
* ),
* deployment=gcp.appengine.StandardAppVersionDeploymentArgs(
* zip=gcp.appengine.StandardAppVersionDeploymentZipArgs(
* source_url=pulumi.Output.all(bucket.name, object.name).apply(lambda bucketName, objectName: f"https://storage.googleapis.com/{bucket_name}/{object_name}"),
* ),
* ),
* env_variables={
* "port": "8080",
* },
* delete_service_on_destroy=True)
* web_service = gcp.appengine.ApplicationUrlDispatchRules("web_service", dispatch_rules=[
* gcp.appengine.ApplicationUrlDispatchRulesDispatchRuleArgs(
* domain="*",
* path="/*",
* service="default",
* ),
* gcp.appengine.ApplicationUrlDispatchRulesDispatchRuleArgs(
* domain="*",
* path="/admin/*",
* service=admin_v3.service,
* ),
* ])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var bucket = new Gcp.Storage.Bucket("bucket", new()
* {
* Name = "appengine-test-bucket",
* Location = "US",
* });
* var @object = new Gcp.Storage.BucketObject("object", new()
* {
* Name = "hello-world.zip",
* Bucket = bucket.Name,
* Source = new FileAsset("./test-fixtures/hello-world.zip"),
* });
* var adminV3 = new Gcp.AppEngine.StandardAppVersion("admin_v3", new()
* {
* VersionId = "v3",
* Service = "admin",
* Runtime = "nodejs20",
* Entrypoint = new Gcp.AppEngine.Inputs.StandardAppVersionEntrypointArgs
* {
* Shell = "node ./app.js",
* },
* Deployment = new Gcp.AppEngine.Inputs.StandardAppVersionDeploymentArgs
* {
* Zip = new Gcp.AppEngine.Inputs.StandardAppVersionDeploymentZipArgs
* {
* SourceUrl = Output.Tuple(bucket.Name, @object.Name).Apply(values =>
* {
* var bucketName = values.Item1;
* var objectName = values.Item2;
* return $"https://storage.googleapis.com/{bucketName}/{objectName}";
* }),
* },
* },
* EnvVariables =
* {
* { "port", "8080" },
* },
* DeleteServiceOnDestroy = true,
* });
* var webService = new Gcp.AppEngine.ApplicationUrlDispatchRules("web_service", new()
* {
* DispatchRules = new[]
* {
* new Gcp.AppEngine.Inputs.ApplicationUrlDispatchRulesDispatchRuleArgs
* {
* Domain = "*",
* Path = "/*",
* Service = "default",
* },
* new Gcp.AppEngine.Inputs.ApplicationUrlDispatchRulesDispatchRuleArgs
* {
* Domain = "*",
* Path = "/admin/*",
* Service = adminV3.Service,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "fmt"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/appengine"
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/storage"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* bucket, err := storage.NewBucket(ctx, "bucket", &storage.BucketArgs{
* Name: pulumi.String("appengine-test-bucket"),
* Location: pulumi.String("US"),
* })
* if err != nil {
* return err
* }
* object, err := storage.NewBucketObject(ctx, "object", &storage.BucketObjectArgs{
* Name: pulumi.String("hello-world.zip"),
* Bucket: bucket.Name,
* Source: pulumi.NewFileAsset("./test-fixtures/hello-world.zip"),
* })
* if err != nil {
* return err
* }
* adminV3, err := appengine.NewStandardAppVersion(ctx, "admin_v3", &appengine.StandardAppVersionArgs{
* VersionId: pulumi.String("v3"),
* Service: pulumi.String("admin"),
* Runtime: pulumi.String("nodejs20"),
* Entrypoint: &appengine.StandardAppVersionEntrypointArgs{
* Shell: pulumi.String("node ./app.js"),
* },
* Deployment: &appengine.StandardAppVersionDeploymentArgs{
* Zip: &appengine.StandardAppVersionDeploymentZipArgs{
* SourceUrl: pulumi.All(bucket.Name, object.Name).ApplyT(func(_args []interface{}) (string, error) {
* bucketName := _args[0].(string)
* objectName := _args[1].(string)
* return fmt.Sprintf("https://storage.googleapis.com/%v/%v", bucketName, objectName), nil
* }).(pulumi.StringOutput),
* },
* },
* EnvVariables: pulumi.StringMap{
* "port": pulumi.String("8080"),
* },
* DeleteServiceOnDestroy: pulumi.Bool(true),
* })
* if err != nil {
* return err
* }
* _, err = appengine.NewApplicationUrlDispatchRules(ctx, "web_service", &appengine.ApplicationUrlDispatchRulesArgs{
* DispatchRules: appengine.ApplicationUrlDispatchRulesDispatchRuleArray{
* &appengine.ApplicationUrlDispatchRulesDispatchRuleArgs{
* Domain: pulumi.String("*"),
* Path: pulumi.String("/*"),
* Service: pulumi.String("default"),
* },
* &appengine.ApplicationUrlDispatchRulesDispatchRuleArgs{
* Domain: pulumi.String("*"),
* Path: pulumi.String("/admin/*"),
* Service: adminV3.Service,
* },
* },
* })
* 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.gcp.storage.Bucket;
* import com.pulumi.gcp.storage.BucketArgs;
* import com.pulumi.gcp.storage.BucketObject;
* import com.pulumi.gcp.storage.BucketObjectArgs;
* import com.pulumi.gcp.appengine.StandardAppVersion;
* import com.pulumi.gcp.appengine.StandardAppVersionArgs;
* import com.pulumi.gcp.appengine.inputs.StandardAppVersionEntrypointArgs;
* import com.pulumi.gcp.appengine.inputs.StandardAppVersionDeploymentArgs;
* import com.pulumi.gcp.appengine.inputs.StandardAppVersionDeploymentZipArgs;
* import com.pulumi.gcp.appengine.ApplicationUrlDispatchRules;
* import com.pulumi.gcp.appengine.ApplicationUrlDispatchRulesArgs;
* import com.pulumi.gcp.appengine.inputs.ApplicationUrlDispatchRulesDispatchRuleArgs;
* import com.pulumi.asset.FileAsset;
* 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 bucket = new Bucket("bucket", BucketArgs.builder()
* .name("appengine-test-bucket")
* .location("US")
* .build());
* var object = new BucketObject("object", BucketObjectArgs.builder()
* .name("hello-world.zip")
* .bucket(bucket.name())
* .source(new FileAsset("./test-fixtures/hello-world.zip"))
* .build());
* var adminV3 = new StandardAppVersion("adminV3", StandardAppVersionArgs.builder()
* .versionId("v3")
* .service("admin")
* .runtime("nodejs20")
* .entrypoint(StandardAppVersionEntrypointArgs.builder()
* .shell("node ./app.js")
* .build())
* .deployment(StandardAppVersionDeploymentArgs.builder()
* .zip(StandardAppVersionDeploymentZipArgs.builder()
* .sourceUrl(Output.tuple(bucket.name(), object.name()).applyValue(values -> {
* var bucketName = values.t1;
* var objectName = values.t2;
* return String.format("https://storage.googleapis.com/%s/%s", bucketName,objectName);
* }))
* .build())
* .build())
* .envVariables(Map.of("port", "8080"))
* .deleteServiceOnDestroy(true)
* .build());
* var webService = new ApplicationUrlDispatchRules("webService", ApplicationUrlDispatchRulesArgs.builder()
* .dispatchRules(
* ApplicationUrlDispatchRulesDispatchRuleArgs.builder()
* .domain("*")
* .path("/*")
* .service("default")
* .build(),
* ApplicationUrlDispatchRulesDispatchRuleArgs.builder()
* .domain("*")
* .path("/admin/*")
* .service(adminV3.service())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* webService:
* type: gcp:appengine:ApplicationUrlDispatchRules
* name: web_service
* properties:
* dispatchRules:
* - domain: '*'
* path: /*
* service: default
* - domain: '*'
* path: /admin/*
* service: ${adminV3.service}
* adminV3:
* type: gcp:appengine:StandardAppVersion
* name: admin_v3
* properties:
* versionId: v3
* service: admin
* runtime: nodejs20
* entrypoint:
* shell: node ./app.js
* deployment:
* zip:
* sourceUrl: https://storage.googleapis.com/${bucket.name}/${object.name}
* envVariables:
* port: '8080'
* deleteServiceOnDestroy: true
* bucket:
* type: gcp:storage:Bucket
* properties:
* name: appengine-test-bucket
* location: US
* object:
* type: gcp:storage:BucketObject
* properties:
* name: hello-world.zip
* bucket: ${bucket.name}
* source:
* fn::FileAsset: ./test-fixtures/hello-world.zip
* ```
*
* ## Import
* ApplicationUrlDispatchRules can be imported using any of these accepted formats:
* * `{{project}}`
* When using the `pulumi import` command, ApplicationUrlDispatchRules can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:appengine/applicationUrlDispatchRules:ApplicationUrlDispatchRules default {{project}}
* ```
* */*/*/*/*/*/*/*/*/*/*/*/
*/
public class ApplicationUrlDispatchRules internal constructor(
override val javaResource: com.pulumi.gcp.appengine.ApplicationUrlDispatchRules,
) : KotlinCustomResource(javaResource, ApplicationUrlDispatchRulesMapper) {
/**
* Rules to match an HTTP request and dispatch that request to a service.
* Structure is documented below.
*/
public val dispatchRules: Output>
get() = javaResource.dispatchRules().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> toKotlin(args0) })
})
})
public val project: Output
get() = javaResource.project().applyValue({ args0 -> args0 })
}
public object ApplicationUrlDispatchRulesMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.appengine.ApplicationUrlDispatchRules::class == javaResource::class
override fun map(javaResource: Resource): ApplicationUrlDispatchRules =
ApplicationUrlDispatchRules(
javaResource as
com.pulumi.gcp.appengine.ApplicationUrlDispatchRules,
)
}
/**
* @see [ApplicationUrlDispatchRules].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [ApplicationUrlDispatchRules].
*/
public suspend fun applicationUrlDispatchRules(
name: String,
block: suspend ApplicationUrlDispatchRulesResourceBuilder.() -> Unit,
): ApplicationUrlDispatchRules {
val builder = ApplicationUrlDispatchRulesResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [ApplicationUrlDispatchRules].
* @param name The _unique_ name of the resulting resource.
*/
public fun applicationUrlDispatchRules(name: String): ApplicationUrlDispatchRules {
val builder = ApplicationUrlDispatchRulesResourceBuilder()
builder.name(name)
return builder.build()
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy