1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. runtimeconfig
  5. Variable
Google Cloud v8.26.0 published on Thursday, Apr 10, 2025 by Pulumi

gcp.runtimeconfig.Variable

Explore with Pulumi AI

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

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/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
	})
}
Copy
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",
    });

});
Copy
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());

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

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

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/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
	})
}
Copy
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),
    });

});
Copy
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.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());

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

Create Variable Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Variable(name: string, args: VariableArgs, opts?: CustomResourceOptions);
@overload
def Variable(resource_name: str,
             args: VariableArgs,
             opts: Optional[ResourceOptions] = None)

@overload
def Variable(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             parent: Optional[str] = None,
             name: Optional[str] = None,
             project: Optional[str] = None,
             text: Optional[str] = None,
             value: Optional[str] = None)
func NewVariable(ctx *Context, name string, args VariableArgs, opts ...ResourceOption) (*Variable, error)
public Variable(string name, VariableArgs args, CustomResourceOptions? opts = null)
public Variable(String name, VariableArgs args)
public Variable(String name, VariableArgs args, CustomResourceOptions options)
type: gcp:runtimeconfig:Variable
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. VariableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. VariableArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. VariableArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. VariableArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. VariableArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var variableResource = new Gcp.RuntimeConfig.Variable("variableResource", new()
{
    Parent = "string",
    Name = "string",
    Project = "string",
    Text = "string",
    Value = "string",
});
Copy
example, err := runtimeconfig.NewVariable(ctx, "variableResource", &runtimeconfig.VariableArgs{
	Parent:  pulumi.String("string"),
	Name:    pulumi.String("string"),
	Project: pulumi.String("string"),
	Text:    pulumi.String("string"),
	Value:   pulumi.String("string"),
})
Copy
var variableResource = new Variable("variableResource", VariableArgs.builder()
    .parent("string")
    .name("string")
    .project("string")
    .text("string")
    .value("string")
    .build());
Copy
variable_resource = gcp.runtimeconfig.Variable("variableResource",
    parent="string",
    name="string",
    project="string",
    text="string",
    value="string")
Copy
const variableResource = new gcp.runtimeconfig.Variable("variableResource", {
    parent: "string",
    name: "string",
    project: "string",
    text: "string",
    value: "string",
});
Copy
type: gcp:runtimeconfig:Variable
properties:
    name: string
    parent: string
    project: string
    text: string
    value: string
Copy

Variable Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Variable resource accepts the following input properties:

Parent
This property is required.
Changes to this property will trigger replacement.
string
The name of the RuntimeConfig resource containing this variable.
Name Changes to this property will trigger replacement. string
The name of the variable to manage. Note that variable names can be hierarchical using slashes (e.g. "prod-variables/hostname").
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Text 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.


Value string
Parent
This property is required.
Changes to this property will trigger replacement.
string
The name of the RuntimeConfig resource containing this variable.
Name Changes to this property will trigger replacement. string
The name of the variable to manage. Note that variable names can be hierarchical using slashes (e.g. "prod-variables/hostname").
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Text 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.


Value string
parent
This property is required.
Changes to this property will trigger replacement.
String
The name of the RuntimeConfig resource containing this variable.
name Changes to this property will trigger replacement. String
The name of the variable to manage. Note that variable names can be hierarchical using slashes (e.g. "prod-variables/hostname").
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
text 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.


value String
parent
This property is required.
Changes to this property will trigger replacement.
string
The name of the RuntimeConfig resource containing this variable.
name Changes to this property will trigger replacement. string
The name of the variable to manage. Note that variable names can be hierarchical using slashes (e.g. "prod-variables/hostname").
project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
text 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.


value string
parent
This property is required.
Changes to this property will trigger replacement.
str
The name of the RuntimeConfig resource containing this variable.
name Changes to this property will trigger replacement. str
The name of the variable to manage. Note that variable names can be hierarchical using slashes (e.g. "prod-variables/hostname").
project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
text str
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.


value str
parent
This property is required.
Changes to this property will trigger replacement.
String
The name of the RuntimeConfig resource containing this variable.
name Changes to this property will trigger replacement. String
The name of the variable to manage. Note that variable names can be hierarchical using slashes (e.g. "prod-variables/hostname").
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
text 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.


value String

Outputs

All input properties are implicitly available as output properties. Additionally, the Variable resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
UpdateTime 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".
Id string
The provider-assigned unique ID for this managed resource.
UpdateTime 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".
id String
The provider-assigned unique ID for this managed resource.
updateTime 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".
id string
The provider-assigned unique ID for this managed resource.
updateTime 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".
id str
The provider-assigned unique ID for this managed resource.
update_time str
(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".
id String
The provider-assigned unique ID for this managed resource.
updateTime 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".

Look up Existing Variable Resource

Get an existing Variable resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: VariableState, opts?: CustomResourceOptions): Variable
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        name: Optional[str] = None,
        parent: Optional[str] = None,
        project: Optional[str] = None,
        text: Optional[str] = None,
        update_time: Optional[str] = None,
        value: Optional[str] = None) -> Variable
func GetVariable(ctx *Context, name string, id IDInput, state *VariableState, opts ...ResourceOption) (*Variable, error)
public static Variable Get(string name, Input<string> id, VariableState? state, CustomResourceOptions? opts = null)
public static Variable get(String name, Output<String> id, VariableState state, CustomResourceOptions options)
resources:  _:    type: gcp:runtimeconfig:Variable    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Name Changes to this property will trigger replacement. string
The name of the variable to manage. Note that variable names can be hierarchical using slashes (e.g. "prod-variables/hostname").
Parent Changes to this property will trigger replacement. string
The name of the RuntimeConfig resource containing this variable.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Text 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.


UpdateTime 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".
Value string
Name Changes to this property will trigger replacement. string
The name of the variable to manage. Note that variable names can be hierarchical using slashes (e.g. "prod-variables/hostname").
Parent Changes to this property will trigger replacement. string
The name of the RuntimeConfig resource containing this variable.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Text 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.


UpdateTime 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".
Value string
name Changes to this property will trigger replacement. String
The name of the variable to manage. Note that variable names can be hierarchical using slashes (e.g. "prod-variables/hostname").
parent Changes to this property will trigger replacement. String
The name of the RuntimeConfig resource containing this variable.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
text 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.


updateTime 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".
value String
name Changes to this property will trigger replacement. string
The name of the variable to manage. Note that variable names can be hierarchical using slashes (e.g. "prod-variables/hostname").
parent Changes to this property will trigger replacement. string
The name of the RuntimeConfig resource containing this variable.
project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
text 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.


updateTime 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".
value string
name Changes to this property will trigger replacement. str
The name of the variable to manage. Note that variable names can be hierarchical using slashes (e.g. "prod-variables/hostname").
parent Changes to this property will trigger replacement. str
The name of the RuntimeConfig resource containing this variable.
project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
text str
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.


update_time str
(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".
value str
name Changes to this property will trigger replacement. String
The name of the variable to manage. Note that variable names can be hierarchical using slashes (e.g. "prod-variables/hostname").
parent Changes to this property will trigger replacement. String
The name of the RuntimeConfig resource containing this variable.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
text 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.


updateTime 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".
value String

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}}
Copy
$ pulumi import gcp:runtimeconfig/variable:Variable default {{config_id}}/{{name}}
Copy

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

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Google Cloud (GCP) Classic pulumi/pulumi-gcp
License
Apache-2.0
Notes
This Pulumi package is based on the google-beta Terraform Provider.