com.pulumi.gcp.runtimeconfig.kotlin.Variable.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.runtimeconfig.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 [Variable].
*/
@PulumiTagMarker
public class VariableResourceBuilder internal constructor() {
public var name: String? = null
public var args: VariableArgs = VariableArgs()
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 VariableArgsBuilder.() -> Unit) {
val builder = VariableArgsBuilder()
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(): Variable {
val builtJavaResource = com.pulumi.gcp.runtimeconfig.Variable(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Variable(builtJavaResource)
}
}
/**
* ## Example Usage
* Example creating a RuntimeConfig variable.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const my_runtime_config = new gcp.runtimeconfig.Config("my-runtime-config", {
* name: "my-service-runtime-config",
* description: "Runtime configuration values for my service",
* });
* const environment = new gcp.runtimeconfig.Variable("environment", {
* parent: my_runtime_config.name,
* name: "prod-variables/hostname",
* text: "example.com",
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* my_runtime_config = gcp.runtimeconfig.Config("my-runtime-config",
* name="my-service-runtime-config",
* description="Runtime configuration values for my service")
* environment = gcp.runtimeconfig.Variable("environment",
* parent=my_runtime_config.name,
* name="prod-variables/hostname",
* text="example.com")
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var my_runtime_config = new Gcp.RuntimeConfig.Config("my-runtime-config", new()
* {
* Name = "my-service-runtime-config",
* Description = "Runtime configuration values for my service",
* });
* var environment = new Gcp.RuntimeConfig.Variable("environment", new()
* {
* Parent = my_runtime_config.Name,
* Name = "prod-variables/hostname",
* Text = "example.com",
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/runtimeconfig"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := runtimeconfig.NewConfig(ctx, "my-runtime-config", &runtimeconfig.ConfigArgs{
* Name: pulumi.String("my-service-runtime-config"),
* Description: pulumi.String("Runtime configuration values for my service"),
* })
* if err != nil {
* return err
* }
* _, err = runtimeconfig.NewVariable(ctx, "environment", &runtimeconfig.VariableArgs{
* Parent: my_runtime_config.Name,
* Name: pulumi.String("prod-variables/hostname"),
* Text: pulumi.String("example.com"),
* })
* 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.runtimeconfig.Config;
* import com.pulumi.gcp.runtimeconfig.ConfigArgs;
* import com.pulumi.gcp.runtimeconfig.Variable;
* import com.pulumi.gcp.runtimeconfig.VariableArgs;
* 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 my_runtime_config = new Config("my-runtime-config", ConfigArgs.builder()
* .name("my-service-runtime-config")
* .description("Runtime configuration values for my service")
* .build());
* var environment = new Variable("environment", VariableArgs.builder()
* .parent(my_runtime_config.name())
* .name("prod-variables/hostname")
* .text("example.com")
* .build());
* }
* }
* ```
* ```yaml
* resources:
* my-runtime-config:
* type: gcp:runtimeconfig:Config
* properties:
* name: my-service-runtime-config
* description: Runtime configuration values for my service
* environment:
* type: gcp:runtimeconfig:Variable
* properties:
* parent: ${["my-runtime-config"].name}
* name: prod-variables/hostname
* text: example.com
* ```
*
* You can also encode binary content using the `value` argument instead. The
* value must be base64 encoded.
* Example of using the `value` argument.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* import * as std from "@pulumi/std";
* const my_runtime_config = new gcp.runtimeconfig.Config("my-runtime-config", {
* name: "my-service-runtime-config",
* description: "Runtime configuration values for my service",
* });
* const my_secret = new gcp.runtimeconfig.Variable("my-secret", {
* parent: my_runtime_config.name,
* name: "secret",
* value: std.filebase64({
* input: "my-encrypted-secret.dat",
* }).then(invoke => invoke.result),
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* import pulumi_std as std
* my_runtime_config = gcp.runtimeconfig.Config("my-runtime-config",
* name="my-service-runtime-config",
* description="Runtime configuration values for my service")
* my_secret = gcp.runtimeconfig.Variable("my-secret",
* parent=my_runtime_config.name,
* name="secret",
* value=std.filebase64(input="my-encrypted-secret.dat").result)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* using Std = Pulumi.Std;
* return await Deployment.RunAsync(() =>
* {
* var my_runtime_config = new Gcp.RuntimeConfig.Config("my-runtime-config", new()
* {
* Name = "my-service-runtime-config",
* Description = "Runtime configuration values for my service",
* });
* var my_secret = new Gcp.RuntimeConfig.Variable("my-secret", new()
* {
* Parent = my_runtime_config.Name,
* Name = "secret",
* Value = Std.Filebase64.Invoke(new()
* {
* Input = "my-encrypted-secret.dat",
* }).Apply(invoke => invoke.Result),
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/runtimeconfig"
* "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 {
* _, err := runtimeconfig.NewConfig(ctx, "my-runtime-config", &runtimeconfig.ConfigArgs{
* Name: pulumi.String("my-service-runtime-config"),
* Description: pulumi.String("Runtime configuration values for my service"),
* })
* if err != nil {
* return err
* }
* invokeFilebase64, err := std.Filebase64(ctx, &std.Filebase64Args{
* Input: "my-encrypted-secret.dat",
* }, nil)
* if err != nil {
* return err
* }
* _, err = runtimeconfig.NewVariable(ctx, "my-secret", &runtimeconfig.VariableArgs{
* Parent: my_runtime_config.Name,
* Name: pulumi.String("secret"),
* Value: invokeFilebase64.Result,
* })
* 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.runtimeconfig.Config;
* import com.pulumi.gcp.runtimeconfig.ConfigArgs;
* import com.pulumi.gcp.runtimeconfig.Variable;
* import com.pulumi.gcp.runtimeconfig.VariableArgs;
* 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 my_runtime_config = new Config("my-runtime-config", ConfigArgs.builder()
* .name("my-service-runtime-config")
* .description("Runtime configuration values for my service")
* .build());
* var my_secret = new Variable("my-secret", VariableArgs.builder()
* .parent(my_runtime_config.name())
* .name("secret")
* .value(StdFunctions.filebase64(Filebase64Args.builder()
* .input("my-encrypted-secret.dat")
* .build()).result())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* my-runtime-config:
* type: gcp:runtimeconfig:Config
* properties:
* name: my-service-runtime-config
* description: Runtime configuration values for my service
* my-secret:
* type: gcp:runtimeconfig:Variable
* properties:
* parent: ${["my-runtime-config"].name}
* name: secret
* value:
* fn::invoke:
* Function: std:filebase64
* Arguments:
* input: my-encrypted-secret.dat
* Return: result
* ```
*
* ## Import
* Runtime Config Variables can be imported using the `name` or full variable name, e.g.
* * `projects/my-gcp-project/configs/{{config_id}}/variables/{{name}}`
* * `{{config_id}}/{{name}}`
* When using the `pulumi import` command, Runtime Config Variables can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:runtimeconfig/variable:Variable default projects/my-gcp-project/configs/{{config_id}}/variables/{{name}}
* ```
* ```sh
* $ pulumi import gcp:runtimeconfig/variable:Variable default {{config_id}}/{{name}}
* ```
* When importing using only the name, the provider project must be set.
*/
public class Variable internal constructor(
override val javaResource: com.pulumi.gcp.runtimeconfig.Variable,
) : KotlinCustomResource(javaResource, VariableMapper) {
/**
* The name of the variable to manage. Note that variable
* names can be hierarchical using slashes (e.g. "prod-variables/hostname").
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* The name of the RuntimeConfig resource containing this
* variable.
*/
public val parent: Output
get() = javaResource.parent().applyValue({ args0 -> args0 })
/**
* The ID of the project in which the resource belongs. If it
* is not provided, the provider project is used.
*/
public val project: Output
get() = javaResource.project().applyValue({ args0 -> args0 })
/**
* or `value` - (Required) The content to associate with the variable.
* Exactly one of `text` or `variable` must be specified. If `text` is specified,
* it must be a valid UTF-8 string and less than 4096 bytes in length. If `value`
* is specified, it must be base64 encoded and less than 4096 bytes in length.
* - - -
*/
public val text: Output?
get() = javaResource.text().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* (Computed) The timestamp in RFC3339 UTC "Zulu" format,
* accurate to nanoseconds, representing when the variable was last updated.
* Example: "2016-10-09T12:33:37.578138407Z".
*/
public val updateTime: Output
get() = javaResource.updateTime().applyValue({ args0 -> args0 })
public val `value`: Output?
get() = javaResource.`value`().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
}
public object VariableMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.runtimeconfig.Variable::class == javaResource::class
override fun map(javaResource: Resource): Variable = Variable(
javaResource as
com.pulumi.gcp.runtimeconfig.Variable,
)
}
/**
* @see [Variable].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [Variable].
*/
public suspend fun variable(name: String, block: suspend VariableResourceBuilder.() -> Unit): Variable {
val builder = VariableResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [Variable].
* @param name The _unique_ name of the resulting resource.
*/
public fun variable(name: String): Variable {
val builder = VariableResourceBuilder()
builder.name(name)
return builder.build()
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy