AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.10.0 published on Monday, Jul 11, 2022 by Pulumi

getSecretVersion

Retrieve information about a Secrets Manager secret version, including its secret value. To retrieve secret metadata, see the aws.secretsmanager.Secret data source.

Example Usage

Retrieve Current Secret Version

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var secret_version = Output.Create(Aws.SecretsManager.GetSecretVersion.InvokeAsync(new Aws.SecretsManager.GetSecretVersionArgs
        {
            SecretId = data.Aws_secretsmanager_secret.Example.Id,
        }));
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/secretsmanager"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := secretsmanager.LookupSecretVersion(ctx, &secretsmanager.LookupSecretVersionArgs{
			SecretId: data.Aws_secretsmanager_secret.Example.Id,
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var secret-version = Output.of(SecretsmanagerFunctions.getSecretVersion(GetSecretVersionArgs.builder()
            .secretId(data.aws_secretsmanager_secret().example().id())
            .build()));

    }
}
import pulumi
import pulumi_aws as aws

secret_version = aws.secretsmanager.get_secret_version(secret_id=data["aws_secretsmanager_secret"]["example"]["id"])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const secret-version = aws.secretsmanager.getSecretVersion({
    secretId: data.aws_secretsmanager_secret.example.id,
});
variables:
  secret-version:
    Fn::Invoke:
      Function: aws:secretsmanager:getSecretVersion
      Arguments:
        secretId: ${data.aws_secretsmanager_secret.example.id}

Retrieve Specific Secret Version

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var by_version_stage = Output.Create(Aws.SecretsManager.GetSecretVersion.InvokeAsync(new Aws.SecretsManager.GetSecretVersionArgs
        {
            SecretId = data.Aws_secretsmanager_secret.Example.Id,
            VersionStage = "example",
        }));
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/secretsmanager"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := secretsmanager.LookupSecretVersion(ctx, &secretsmanager.LookupSecretVersionArgs{
			SecretId:     data.Aws_secretsmanager_secret.Example.Id,
			VersionStage: pulumi.StringRef("example"),
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var by-version-stage = Output.of(SecretsmanagerFunctions.getSecretVersion(GetSecretVersionArgs.builder()
            .secretId(data.aws_secretsmanager_secret().example().id())
            .versionStage("example")
            .build()));

    }
}
import pulumi
import pulumi_aws as aws

by_version_stage = aws.secretsmanager.get_secret_version(secret_id=data["aws_secretsmanager_secret"]["example"]["id"],
    version_stage="example")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const by-version-stage = aws.secretsmanager.getSecretVersion({
    secretId: data.aws_secretsmanager_secret.example.id,
    versionStage: "example",
});
variables:
  by-version-stage:
    Fn::Invoke:
      Function: aws:secretsmanager:getSecretVersion
      Arguments:
        secretId: ${data.aws_secretsmanager_secret.example.id}
        versionStage: example

Using getSecretVersion

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 getSecretVersion(args: GetSecretVersionArgs, opts?: InvokeOptions): Promise<GetSecretVersionResult>
function getSecretVersionOutput(args: GetSecretVersionOutputArgs, opts?: InvokeOptions): Output<GetSecretVersionResult>
def get_secret_version(secret_id: Optional[str] = None,
                       version_id: Optional[str] = None,
                       version_stage: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetSecretVersionResult
def get_secret_version_output(secret_id: Optional[pulumi.Input[str]] = None,
                       version_id: Optional[pulumi.Input[str]] = None,
                       version_stage: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetSecretVersionResult]
func LookupSecretVersion(ctx *Context, args *LookupSecretVersionArgs, opts ...InvokeOption) (*LookupSecretVersionResult, error)
func LookupSecretVersionOutput(ctx *Context, args *LookupSecretVersionOutputArgs, opts ...InvokeOption) LookupSecretVersionResultOutput

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

public static class GetSecretVersion 
{
    public static Task<GetSecretVersionResult> InvokeAsync(GetSecretVersionArgs args, InvokeOptions? opts = null)
    public static Output<GetSecretVersionResult> Invoke(GetSecretVersionInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetSecretVersionResult> getSecretVersion(GetSecretVersionArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: aws:secretsmanager/getSecretVersion:getSecretVersion
  Arguments:
    # Arguments dictionary

The following arguments are supported:

SecretId string

Specifies the secret containing the version that you want to retrieve. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.

VersionId string

Specifies the unique identifier of the version of the secret that you want to retrieve. Overrides version_stage.

VersionStage string

Specifies the secret version that you want to retrieve by the staging label attached to the version. Defaults to AWSCURRENT.

SecretId string

Specifies the secret containing the version that you want to retrieve. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.

VersionId string

Specifies the unique identifier of the version of the secret that you want to retrieve. Overrides version_stage.

VersionStage string

Specifies the secret version that you want to retrieve by the staging label attached to the version. Defaults to AWSCURRENT.

secretId String

Specifies the secret containing the version that you want to retrieve. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.

versionId String

Specifies the unique identifier of the version of the secret that you want to retrieve. Overrides version_stage.

versionStage String

Specifies the secret version that you want to retrieve by the staging label attached to the version. Defaults to AWSCURRENT.

secretId string

Specifies the secret containing the version that you want to retrieve. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.

versionId string

Specifies the unique identifier of the version of the secret that you want to retrieve. Overrides version_stage.

versionStage string

Specifies the secret version that you want to retrieve by the staging label attached to the version. Defaults to AWSCURRENT.

secret_id str

Specifies the secret containing the version that you want to retrieve. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.

version_id str

Specifies the unique identifier of the version of the secret that you want to retrieve. Overrides version_stage.

version_stage str

Specifies the secret version that you want to retrieve by the staging label attached to the version. Defaults to AWSCURRENT.

secretId String

Specifies the secret containing the version that you want to retrieve. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.

versionId String

Specifies the unique identifier of the version of the secret that you want to retrieve. Overrides version_stage.

versionStage String

Specifies the secret version that you want to retrieve by the staging label attached to the version. Defaults to AWSCURRENT.

getSecretVersion Result

The following output properties are available:

Arn string

The ARN of the secret.

Id string

The provider-assigned unique ID for this managed resource.

SecretBinary string

The decrypted part of the protected secret information that was originally provided as a binary.

SecretId string
SecretString string

The decrypted part of the protected secret information that was originally provided as a string.

VersionId string

The unique identifier of this version of the secret.

VersionStages List<string>
VersionStage string
Arn string

The ARN of the secret.

Id string

The provider-assigned unique ID for this managed resource.

SecretBinary string

The decrypted part of the protected secret information that was originally provided as a binary.

SecretId string
SecretString string

The decrypted part of the protected secret information that was originally provided as a string.

VersionId string

The unique identifier of this version of the secret.

VersionStages []string
VersionStage string
arn String

The ARN of the secret.

id String

The provider-assigned unique ID for this managed resource.

secretBinary String

The decrypted part of the protected secret information that was originally provided as a binary.

secretId String
secretString String

The decrypted part of the protected secret information that was originally provided as a string.

versionId String

The unique identifier of this version of the secret.

versionStages List<String>
versionStage String
arn string

The ARN of the secret.

id string

The provider-assigned unique ID for this managed resource.

secretBinary string

The decrypted part of the protected secret information that was originally provided as a binary.

secretId string
secretString string

The decrypted part of the protected secret information that was originally provided as a string.

versionId string

The unique identifier of this version of the secret.

versionStages string[]
versionStage string
arn str

The ARN of the secret.

id str

The provider-assigned unique ID for this managed resource.

secret_binary str

The decrypted part of the protected secret information that was originally provided as a binary.

secret_id str
secret_string str

The decrypted part of the protected secret information that was originally provided as a string.

version_id str

The unique identifier of this version of the secret.

version_stages Sequence[str]
version_stage str
arn String

The ARN of the secret.

id String

The provider-assigned unique ID for this managed resource.

secretBinary String

The decrypted part of the protected secret information that was originally provided as a binary.

secretId String
secretString String

The decrypted part of the protected secret information that was originally provided as a string.

versionId String

The unique identifier of this version of the secret.

versionStages List<String>
versionStage String

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.