1. Registry
  2. Packages
  3. Bitwarden Provider
  4. API Docs
  5. getSecret
Viewing docs for bitwarden 0.22.0
published on Sunday, Oct 25, 2026 by maxlaverse
bitwarden
Viewing docs for bitwarden 0.22.0
published on Sunday, Oct 25, 2026 by maxlaverse

    Use this data source to get information on an existing Secrets Manager secret. The secret value and note are stored in pulumi preview and state. To read a secret without persisting it, use the bitwarden.Secret ephemeral resource.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as bitwarden from "@pulumi/bitwarden";
    import * as kubernetes from "@pulumi/kubernetes";
    
    // Values from this data source are stored in Terraform state. Use
    // ephemeral.bitwarden_secret when the secret should not be persisted.
    const example = bitwarden.getSecret({
        id: "37a66d6a-96c1-4f04-9a3c-b1fc0135669e",
    });
    const vpnCredentials = new kubernetes.index.Secret("vpn_credentials", {
        metadata: [{
            name: "vpn-key",
        }],
        data: {
            PASSWORD: example.value,
        },
    });
    
    import pulumi
    import pulumi_bitwarden as bitwarden
    import pulumi_kubernetes as kubernetes
    
    # Values from this data source are stored in Terraform state. Use
    # ephemeral.bitwarden_secret when the secret should not be persisted.
    example = bitwarden.get_secret(id="37a66d6a-96c1-4f04-9a3c-b1fc0135669e")
    vpn_credentials = kubernetes.index.Secret("vpn_credentials",
        metadata=[{
            name: vpn-key,
        }],
        data={
            PASSWORD: example.value,
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-kubernetes/sdk/go/kubernetes"
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/bitwarden/bitwarden"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// Values from this data source are stored in Terraform state. Use
    		// ephemeral.bitwarden_secret when the secret should not be persisted.
    		example, err := bitwarden.LookupSecret(ctx, &bitwarden.LookupSecretArgs{
    			Id: pulumi.StringRef("37a66d6a-96c1-4f04-9a3c-b1fc0135669e"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = kubernetes.NewSecret(ctx, "vpn_credentials", &kubernetes.SecretArgs{
    			Metadata: []map[string]interface{}{
    				map[string]interface{}{
    					"name": "vpn-key",
    				},
    			},
    			Data: map[string]interface{}{
    				"PASSWORD": example.Value,
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Bitwarden = Pulumi.Bitwarden;
    using Kubernetes = Pulumi.Kubernetes;
    
    return await Deployment.RunAsync(() => 
    {
        // Values from this data source are stored in Terraform state. Use
        // ephemeral.bitwarden_secret when the secret should not be persisted.
        var example = Bitwarden.GetSecret.Invoke(new()
        {
            Id = "37a66d6a-96c1-4f04-9a3c-b1fc0135669e",
        });
    
        var vpnCredentials = new Kubernetes.Index.Secret("vpn_credentials", new()
        {
            Metadata = new[]
            {
                
                {
                    { "name", "vpn-key" },
                },
            },
            Data = 
            {
                { "PASSWORD", example.Apply(getSecretResult => getSecretResult.Value) },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.bitwarden.BitwardenFunctions;
    import com.pulumi.bitwarden.inputs.GetSecretArgs;
    import com.pulumi.kubernetes.Secret;
    import com.pulumi.kubernetes.SecretArgs;
    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) {
            // Values from this data source are stored in Terraform state. Use
            // ephemeral.bitwarden_secret when the secret should not be persisted.
            final var example = BitwardenFunctions.getSecret(GetSecretArgs.builder()
                .id("37a66d6a-96c1-4f04-9a3c-b1fc0135669e")
                .build());
    
            var vpnCredentials = new Secret("vpnCredentials", SecretArgs.builder()
                .metadata(List.of(Map.of("name", "vpn-key")))
                .data(Map.of("PASSWORD", example.value()))
                .build());
    
        }
    }
    
    resources:
      vpnCredentials:
        type: kubernetes:Secret
        name: vpn_credentials
        properties:
          metadata:
            - name: vpn-key
          data:
            PASSWORD: ${example.value}
    variables:
      # Values from this data source are stored in Terraform state. Use
      # ephemeral.bitwarden_secret when the secret should not be persisted.
      example:
        fn::invoke:
          function: bitwarden:getSecret
          arguments:
            id: 37a66d6a-96c1-4f04-9a3c-b1fc0135669e
    
    Example coming soon!
    

    Using getSecret

    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 getSecret(args: GetSecretArgs, opts?: InvokeOptions): Promise<GetSecretResult>
    function getSecretOutput(args: GetSecretOutputArgs, opts?: InvokeOutputOptions): Output<GetSecretResult>
    def get_secret(id: Optional[str] = None,
                   key: Optional[str] = None,
                   organization_id: Optional[str] = None,
                   opts: Optional[InvokeOptions] = None) -> GetSecretResult
    def get_secret_output(id: pulumi.Input[Optional[str]] = None,
                   key: pulumi.Input[Optional[str]] = None,
                   organization_id: pulumi.Input[Optional[str]] = None,
                   opts: Optional[InvokeOutputOptions] = None) -> Output[GetSecretResult]
    func LookupSecret(ctx *Context, args *LookupSecretArgs, opts ...InvokeOption) (*LookupSecretResult, error)
    func LookupSecretOutput(ctx *Context, args *LookupSecretOutputArgs, opts ...InvokeOption) LookupSecretResultOutput

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

    public static class GetSecret 
    {
        public static Task<GetSecretResult> InvokeAsync(GetSecretArgs args, InvokeOptions? opts = null)
        public static Output<GetSecretResult> Invoke(GetSecretInvokeArgs args, InvokeOptions? opts = null)
        public static Output<GetSecretResult> Invoke(GetSecretInvokeArgs args, InvokeOutputOptions opts)
    }
    public static CompletableFuture<GetSecretResult> getSecret(GetSecretArgs args, InvokeOptions options)
    public static Output<GetSecretResult> getSecret(GetSecretArgs args, InvokeOptions options)
    public static Output<GetSecretResult> getSecret(GetSecretArgs args, InvokeOutputOptions options)
    
    fn::invoke:
      function: bitwarden:index/getSecret:getSecret
      arguments:
        # arguments dictionary
    data "bitwarden_get_secret" "name" {
        # arguments
    }

    The following arguments are supported:

    Id string
    Identifier of the secret. Specify exactly one of id or key.
    Key string
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    OrganizationId string
    Identifier of the organization.
    Id string
    Identifier of the secret. Specify exactly one of id or key.
    Key string
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    OrganizationId string
    Identifier of the organization.
    id string
    Identifier of the secret. Specify exactly one of id or key.
    key string
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    organization_id string
    Identifier of the organization.
    id String
    Identifier of the secret. Specify exactly one of id or key.
    key String
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    organizationId String
    Identifier of the organization.
    id string
    Identifier of the secret. Specify exactly one of id or key.
    key string
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    organizationId string
    Identifier of the organization.
    id str
    Identifier of the secret. Specify exactly one of id or key.
    key str
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    organization_id str
    Identifier of the organization.
    id String
    Identifier of the secret. Specify exactly one of id or key.
    key String
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    organizationId String
    Identifier of the organization.

    getSecret Result

    The following output properties are available:

    Id string
    Identifier of the secret. Specify exactly one of id or key.
    Key string
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    Note string
    Note.
    OrganizationId string
    Identifier of the organization.
    ProjectId string
    Identifier of the project.
    Value string
    Value.
    Id string
    Identifier of the secret. Specify exactly one of id or key.
    Key string
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    Note string
    Note.
    OrganizationId string
    Identifier of the organization.
    ProjectId string
    Identifier of the project.
    Value string
    Value.
    id string
    Identifier of the secret. Specify exactly one of id or key.
    key string
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    note string
    Note.
    organization_id string
    Identifier of the organization.
    project_id string
    Identifier of the project.
    value string
    Value.
    id String
    Identifier of the secret. Specify exactly one of id or key.
    key String
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    note String
    Note.
    organizationId String
    Identifier of the organization.
    projectId String
    Identifier of the project.
    value String
    Value.
    id string
    Identifier of the secret. Specify exactly one of id or key.
    key string
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    note string
    Note.
    organizationId string
    Identifier of the organization.
    projectId string
    Identifier of the project.
    value string
    Value.
    id str
    Identifier of the secret. Specify exactly one of id or key.
    key str
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    note str
    Note.
    organization_id str
    Identifier of the organization.
    project_id str
    Identifier of the project.
    value str
    Value.
    id String
    Identifier of the secret. Specify exactly one of id or key.
    key String
    Name of the secret. Must uniquely match a secret accessible to the access token. Specify exactly one of id or key.
    note String
    Note.
    organizationId String
    Identifier of the organization.
    projectId String
    Identifier of the project.
    value String
    Value.

    Package Details

    Repository
    bitwarden maxlaverse/terraform-provider-bitwarden
    License
    Notes
    This Pulumi package is based on the bitwarden Terraform Provider.
    bitwarden
    Viewing docs for bitwarden 0.22.0
    published on Sunday, Oct 25, 2026 by maxlaverse

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial