getPlaintext

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const key = new alicloud.kms.Key("key", {
description: "example key",
isEnabled: true,
});
// Encrypt plaintext 'example'
const encrypted = new alicloud.kms.Ciphertext("encrypted", {
keyId: key.id,
plaintext: "example",
});
// Decrypt encrypted ciphertext
const plaintext = alicloud.kms.getPlaintextOutput({
ciphertextBlob: encrypted.ciphertextBlob,
});
export const decrypted = plaintext.apply(plaintext => plaintext.plaintext);
import pulumi
import pulumi_alicloud as alicloud
key = alicloud.kms.Key("key",
description="example key",
is_enabled=True)
# Encrypt plaintext 'example'
encrypted = alicloud.kms.Ciphertext("encrypted",
key_id=key.id,
plaintext="example")
# Decrypt encrypted ciphertext
plaintext = alicloud.kms.get_plaintext_output(ciphertext_blob=encrypted.ciphertext_blob)
pulumi.export("decrypted", plaintext.plaintext)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var key = new AliCloud.Kms.Key("key", new()
{
Description = "example key",
IsEnabled = true,
});
// Encrypt plaintext 'example'
var encrypted = new AliCloud.Kms.Ciphertext("encrypted", new()
{
KeyId = key.Id,
Plaintext = "example",
});
// Decrypt encrypted ciphertext
var plaintext = AliCloud.Kms.GetPlaintext.Invoke(new()
{
CiphertextBlob = encrypted.CiphertextBlob,
});
return new Dictionary<string, object?>
{
["decrypted"] = plaintext.Apply(getPlaintextResult => getPlaintextResult.Plaintext),
};
});
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/kms"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
key, err := kms.NewKey(ctx, "key", &kms.KeyArgs{
Description: pulumi.String("example key"),
IsEnabled: pulumi.Bool(true),
})
if err != nil {
return err
}
// Encrypt plaintext 'example'
encrypted, err := kms.NewCiphertext(ctx, "encrypted", &kms.CiphertextArgs{
KeyId: key.ID(),
Plaintext: pulumi.String("example"),
})
if err != nil {
return err
}
// Decrypt encrypted ciphertext
plaintext := kms.GetPlaintextOutput(ctx, kms.GetPlaintextOutputArgs{
CiphertextBlob: encrypted.CiphertextBlob,
}, nil)
ctx.Export("decrypted", plaintext.ApplyT(func(plaintext kms.GetPlaintextResult) (*string, error) {
return &plaintext.Plaintext, nil
}).(pulumi.StringPtrOutput))
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.kms.Key;
import com.pulumi.alicloud.kms.KeyArgs;
import com.pulumi.alicloud.kms.Ciphertext;
import com.pulumi.alicloud.kms.CiphertextArgs;
import com.pulumi.alicloud.kms.KmsFunctions;
import com.pulumi.alicloud.kms.inputs.GetPlaintextArgs;
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 key = new Key("key", KeyArgs.builder()
.description("example key")
.isEnabled(true)
.build());
// Encrypt plaintext 'example'
var encrypted = new Ciphertext("encrypted", CiphertextArgs.builder()
.keyId(key.id())
.plaintext("example")
.build());
// Decrypt encrypted ciphertext
final var plaintext = KmsFunctions.getPlaintext(GetPlaintextArgs.builder()
.ciphertextBlob(encrypted.ciphertextBlob())
.build());
ctx.export("decrypted", plaintext.applyValue(_plaintext -> _plaintext.plaintext()));
}
}
resources:
key:
type: alicloud:kms:Key
properties:
description: example key
isEnabled: true
# Encrypt plaintext 'example'
encrypted:
type: alicloud:kms:Ciphertext
properties:
keyId: ${key.id}
plaintext: example
variables:
# Decrypt encrypted ciphertext
plaintext:
fn::invoke:
function: alicloud:kms:getPlaintext
arguments:
ciphertextBlob: ${encrypted.ciphertextBlob}
outputs:
# Output 'example' should match the plaintext encrypted in the beginning
decrypted: ${plaintext.plaintext}

Return

A collection of values returned by getPlaintext.

Parameters

argument

A collection of arguments for invoking getPlaintext.


suspend fun getPlaintext(ciphertextBlob: String, encryptionContext: Map<String, String>? = null): GetPlaintextResult

Return

A collection of values returned by getPlaintext.

Parameters

ciphertextBlob

The ciphertext to be decrypted.

encryptionContext

(Optional) The Encryption context. If you specify this parameter in the Encrypt or GenerateDataKey API operation, it is also required when you call the Decrypt API operation. For more information, see Encryption Context.

See also


Return

A collection of values returned by getPlaintext.

Parameters

argument

Builder for com.pulumi.alicloud.kms.kotlin.inputs.GetPlaintextPlainArgs.

See also