1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. composer
  5. getUserWorkloadsSecret
Google Cloud v8.35.0 published on Wednesday, Jun 18, 2025 by Pulumi

gcp.composer.getUserWorkloadsSecret

Explore with Pulumi AI

Google Cloud v8.35.0 published on Wednesday, Jun 18, 2025 by Pulumi

Provides access to Kubernetes Secret configuration for a given project, region and Composer Environment.

To get more information about Composer User Workloads Secrets, see:

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
import * as std from "@pulumi/std";

const exampleEnvironment = new gcp.composer.Environment("example", {
    name: "example-environment",
    config: {
        softwareConfig: {
            imageVersion: "composer-3-airflow-2",
        },
    },
});
const exampleUserWorkloadsSecret = new gcp.composer.UserWorkloadsSecret("example", {
    environment: exampleEnvironment.name,
    name: "example-secret",
    data: {
        username: std.base64encode({
            input: "username",
        }).then(invoke => invoke.result),
        password: std.base64encode({
            input: "password",
        }).then(invoke => invoke.result),
    },
});
const example = exampleEnvironment.name.apply(name => gcp.composer.getUserWorkloadsSecretOutput({
    environment: name,
    name: googleComposerUserWorkloadsSecret.example.name,
}));
export const debug = example;
Copy
import pulumi
import pulumi_gcp as gcp
import pulumi_std as std

example_environment = gcp.composer.Environment("example",
    name="example-environment",
    config={
        "software_config": {
            "image_version": "composer-3-airflow-2",
        },
    })
example_user_workloads_secret = gcp.composer.UserWorkloadsSecret("example",
    environment=example_environment.name,
    name="example-secret",
    data={
        "username": std.base64encode(input="username").result,
        "password": std.base64encode(input="password").result,
    })
example = example_environment.name.apply(lambda name: gcp.composer.get_user_workloads_secret_output(environment=name,
    name=google_composer_user_workloads_secret["example"]["name"]))
pulumi.export("debug", example)
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/composer"
	"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 {
		exampleEnvironment, err := composer.NewEnvironment(ctx, "example", &composer.EnvironmentArgs{
			Name: pulumi.String("example-environment"),
			Config: &composer.EnvironmentConfigArgs{
				SoftwareConfig: &composer.EnvironmentConfigSoftwareConfigArgs{
					ImageVersion: pulumi.String("composer-3-airflow-2"),
				},
			},
		})
		if err != nil {
			return err
		}
		invokeBase64encode, err := std.Base64encode(ctx, &std.Base64encodeArgs{
			Input: "username",
		}, nil)
		if err != nil {
			return err
		}
		invokeBase64encode1, err := std.Base64encode(ctx, &std.Base64encodeArgs{
			Input: "password",
		}, nil)
		if err != nil {
			return err
		}
		_, err = composer.NewUserWorkloadsSecret(ctx, "example", &composer.UserWorkloadsSecretArgs{
			Environment: exampleEnvironment.Name,
			Name:        pulumi.String("example-secret"),
			Data: pulumi.StringMap{
				"username": pulumi.String(invokeBase64encode.Result),
				"password": pulumi.String(invokeBase64encode1.Result),
			},
		})
		if err != nil {
			return err
		}
		example := exampleEnvironment.Name.ApplyT(func(name string) (composer.GetUserWorkloadsSecretResult, error) {
			return composer.GetUserWorkloadsSecretResult(interface{}(composer.LookupUserWorkloadsSecretOutput(ctx, composer.GetUserWorkloadsSecretOutputArgs{
				Environment: name,
				Name:        googleComposerUserWorkloadsSecret.Example.Name,
			}, nil))), nil
		}).(composer.GetUserWorkloadsSecretResultOutput)
		ctx.Export("debug", example)
		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 exampleEnvironment = new Gcp.Composer.Environment("example", new()
    {
        Name = "example-environment",
        Config = new Gcp.Composer.Inputs.EnvironmentConfigArgs
        {
            SoftwareConfig = new Gcp.Composer.Inputs.EnvironmentConfigSoftwareConfigArgs
            {
                ImageVersion = "composer-3-airflow-2",
            },
        },
    });

    var exampleUserWorkloadsSecret = new Gcp.Composer.UserWorkloadsSecret("example", new()
    {
        Environment = exampleEnvironment.Name,
        Name = "example-secret",
        Data = 
        {
            { "username", Std.Base64encode.Invoke(new()
            {
                Input = "username",
            }).Apply(invoke => invoke.Result) },
            { "password", Std.Base64encode.Invoke(new()
            {
                Input = "password",
            }).Apply(invoke => invoke.Result) },
        },
    });

    var example = Gcp.Composer.GetUserWorkloadsSecret.Invoke(new()
    {
        Environment = exampleEnvironment.Name,
        Name = googleComposerUserWorkloadsSecret.Example.Name,
    });

    return new Dictionary<string, object?>
    {
        ["debug"] = example,
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.composer.Environment;
import com.pulumi.gcp.composer.EnvironmentArgs;
import com.pulumi.gcp.composer.inputs.EnvironmentConfigArgs;
import com.pulumi.gcp.composer.inputs.EnvironmentConfigSoftwareConfigArgs;
import com.pulumi.gcp.composer.UserWorkloadsSecret;
import com.pulumi.gcp.composer.UserWorkloadsSecretArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.Base64encodeArgs;
import com.pulumi.gcp.composer.ComposerFunctions;
import com.pulumi.gcp.composer.inputs.GetUserWorkloadsSecretArgs;
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 exampleEnvironment = new Environment("exampleEnvironment", EnvironmentArgs.builder()
            .name("example-environment")
            .config(EnvironmentConfigArgs.builder()
                .softwareConfig(EnvironmentConfigSoftwareConfigArgs.builder()
                    .imageVersion("composer-3-airflow-2")
                    .build())
                .build())
            .build());

        var exampleUserWorkloadsSecret = new UserWorkloadsSecret("exampleUserWorkloadsSecret", UserWorkloadsSecretArgs.builder()
            .environment(exampleEnvironment.name())
            .name("example-secret")
            .data(Map.ofEntries(
                Map.entry("username", StdFunctions.base64encode(Base64encodeArgs.builder()
                    .input("username")
                    .build()).result()),
                Map.entry("password", StdFunctions.base64encode(Base64encodeArgs.builder()
                    .input("password")
                    .build()).result())
            ))
            .build());

        final var example = exampleEnvironment.name().applyValue(_name -> ComposerFunctions.getUserWorkloadsSecret(GetUserWorkloadsSecretArgs.builder()
            .environment(_name)
            .name(googleComposerUserWorkloadsSecret.example().name())
            .build()));

        ctx.export("debug", example);
    }
}
Copy
resources:
  exampleEnvironment:
    type: gcp:composer:Environment
    name: example
    properties:
      name: example-environment
      config:
        softwareConfig:
          imageVersion: composer-3-airflow-2
  exampleUserWorkloadsSecret:
    type: gcp:composer:UserWorkloadsSecret
    name: example
    properties:
      environment: ${exampleEnvironment.name}
      name: example-secret
      data:
        username:
          fn::invoke:
            function: std:base64encode
            arguments:
              input: username
            return: result
        password:
          fn::invoke:
            function: std:base64encode
            arguments:
              input: password
            return: result
variables:
  example:
    fn::invoke:
      function: gcp:composer:getUserWorkloadsSecret
      arguments:
        environment: ${exampleEnvironment.name}
        name: ${googleComposerUserWorkloadsSecret.example.name}
outputs:
  debug: ${example}
Copy

Using getUserWorkloadsSecret

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getUserWorkloadsSecret(args: GetUserWorkloadsSecretArgs, opts?: InvokeOptions): Promise<GetUserWorkloadsSecretResult>
function getUserWorkloadsSecretOutput(args: GetUserWorkloadsSecretOutputArgs, opts?: InvokeOptions): Output<GetUserWorkloadsSecretResult>
Copy
def get_user_workloads_secret(environment: Optional[str] = None,
                              name: Optional[str] = None,
                              project: Optional[str] = None,
                              region: Optional[str] = None,
                              opts: Optional[InvokeOptions] = None) -> GetUserWorkloadsSecretResult
def get_user_workloads_secret_output(environment: Optional[pulumi.Input[str]] = None,
                              name: Optional[pulumi.Input[str]] = None,
                              project: Optional[pulumi.Input[str]] = None,
                              region: Optional[pulumi.Input[str]] = None,
                              opts: Optional[InvokeOptions] = None) -> Output[GetUserWorkloadsSecretResult]
Copy
func LookupUserWorkloadsSecret(ctx *Context, args *LookupUserWorkloadsSecretArgs, opts ...InvokeOption) (*LookupUserWorkloadsSecretResult, error)
func LookupUserWorkloadsSecretOutput(ctx *Context, args *LookupUserWorkloadsSecretOutputArgs, opts ...InvokeOption) LookupUserWorkloadsSecretResultOutput
Copy

> Note: This function is named LookupUserWorkloadsSecret in the Go SDK.

public static class GetUserWorkloadsSecret 
{
    public static Task<GetUserWorkloadsSecretResult> InvokeAsync(GetUserWorkloadsSecretArgs args, InvokeOptions? opts = null)
    public static Output<GetUserWorkloadsSecretResult> Invoke(GetUserWorkloadsSecretInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetUserWorkloadsSecretResult> getUserWorkloadsSecret(GetUserWorkloadsSecretArgs args, InvokeOptions options)
public static Output<GetUserWorkloadsSecretResult> getUserWorkloadsSecret(GetUserWorkloadsSecretArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: gcp:composer/getUserWorkloadsSecret:getUserWorkloadsSecret
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Environment This property is required. string
Environment where the Secret is stored.
Name This property is required. string
Name of the Secret.
Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Region string
The location or Compute Engine region of the environment.
Environment This property is required. string
Environment where the Secret is stored.
Name This property is required. string
Name of the Secret.
Project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Region string
The location or Compute Engine region of the environment.
environment This property is required. String
Environment where the Secret is stored.
name This property is required. String
Name of the Secret.
project String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
region String
The location or Compute Engine region of the environment.
environment This property is required. string
Environment where the Secret is stored.
name This property is required. string
Name of the Secret.
project string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
region string
The location or Compute Engine region of the environment.
environment This property is required. str
Environment where the Secret is stored.
name This property is required. str
Name of the Secret.
project str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
region str
The location or Compute Engine region of the environment.
environment This property is required. String
Environment where the Secret is stored.
name This property is required. String
Name of the Secret.
project String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
region String
The location or Compute Engine region of the environment.

getUserWorkloadsSecret Result

The following output properties are available:

Data Dictionary<string, string>
Environment string
Id string
The provider-assigned unique ID for this managed resource.
Name string
Project string
Region string
Data map[string]string
Environment string
Id string
The provider-assigned unique ID for this managed resource.
Name string
Project string
Region string
data Map<String,String>
environment String
id String
The provider-assigned unique ID for this managed resource.
name String
project String
region String
data {[key: string]: string}
environment string
id string
The provider-assigned unique ID for this managed resource.
name string
project string
region string
data Mapping[str, str]
environment str
id str
The provider-assigned unique ID for this managed resource.
name str
project str
region str
data Map<String>
environment String
id String
The provider-assigned unique ID for this managed resource.
name String
project String
region String

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.
Google Cloud v8.35.0 published on Wednesday, Jun 18, 2025 by Pulumi