Variable class

Manages a RuntimeConfig variable in Google Cloud. For more information, see the official documentation, or the JSON API.

> Warning: This resource is in beta, and should be used with the terraform-provider-google-beta provider. See Provider Versions for more details on beta resources.

Example Usage

Example creating a RuntimeConfig variable.

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",
});
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")
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",
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/runtimeconfig"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		my_runtime_config, 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
	})
}
pulumi {
  required_providers {
    gcp = {
      source = "pulumi/gcp"
    }
  }
}

resource "gcp_runtimeconfig_config" "my-runtime-config" {
  name        = "my-service-runtime-config"
  description = "Runtime configuration values for my service"
}
resource "gcp_runtimeconfig_variable" "environment" {
  parent = gcp_runtimeconfig_config.my-runtime-config.name
  name   = "prod-variables/hostname"
  text   = "example.com"
}
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.ArrayList;
import java.util.Arrays;
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());

    }
}
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.

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),
});
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)
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),
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/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 {
		my_runtime_config, 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:  pulumi.String(invokeFilebase64.Result),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    gcp = {
      source = "pulumi/gcp"
    }
    std = {
      source = "pulumi/std"
    }
  }
}

resource "gcp_runtimeconfig_config" "my-runtime-config" {
  name        = "my-service-runtime-config"
  description = "Runtime configuration values for my service"
}
resource "gcp_runtimeconfig_variable" "my-secret" {
  parent = gcp_runtimeconfig_config.my-runtime-config.name
  name   = "secret"
  value  = filebase64("my-encrypted-secret.dat")
}
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 com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.Filebase64Args;
import java.util.ArrayList;
import java.util.Arrays;
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());

    }
}
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:

$ pulumi import gcp:runtimeconfig/variable:Variable default projects/my-gcp-project/configs/{{config_id}}/variables/{{name}}
$ pulumi import gcp:runtimeconfig/variable:Variable default {{config_id}}/{{name}}

When importing using only the name, the provider project must be set.

Constructors

Variable(String name, {VariableArgs? args, CustomResourceOptions? options})
Creates a new Variable. name The Pulumi resource name. args Arguments used to configure this Variable. The set of arguments for Variable. options Resource options controlling this resource's behavior.
Variable.reference(String urn)
Creates a typed reference to an existing Variable resource.

Properties

childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
deletionPolicy ↔ Output<String>
Whether Terraform will be prevented from destroying the resource. Defaults to "DELETE". When a 'terraform destroy' or 'pulumi up' would delete the resource, the command will fail if this field is set to "PREVENT" in Terraform state. When set to "ABANDON", the command will remove the resource from Terraform management without updating or deleting the resource in the API. When set to "DELETE", deleting the resource is allowed.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
name ↔ Output<String>
The name of the variable to manage. Note that variable names can be hierarchical using slashes (e.g. "prod-variables/hostname").
latefinal
parent ↔ Output<String>
The name of the RuntimeConfig resource containing this variable.
latefinal
project ↔ Output<String>
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
text ↔ Output<String?>
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.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
updateTime ↔ Output<String>
(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".
latefinal
urn ↔ Output<String>
latefinalinherited
value ↔ Output<String?>
latefinal

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {VariableState? state, CustomResourceOptions? options}) → Variable
Gets an existing Variable resource's state with the given name and id.