Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi
alicloud.kms.getPlaintext
Explore with Pulumi AI
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)
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
})
}
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 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(getPlaintextResult -> getPlaintextResult).applyValue(plaintext -> plaintext.applyValue(getPlaintextResult -> getPlaintextResult.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}
Using getPlaintext
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 getPlaintext(args: GetPlaintextArgs, opts?: InvokeOptions): Promise<GetPlaintextResult>
function getPlaintextOutput(args: GetPlaintextOutputArgs, opts?: InvokeOptions): Output<GetPlaintextResult>
def get_plaintext(ciphertext_blob: Optional[str] = None,
encryption_context: Optional[Mapping[str, str]] = None,
opts: Optional[InvokeOptions] = None) -> GetPlaintextResult
def get_plaintext_output(ciphertext_blob: Optional[pulumi.Input[str]] = None,
encryption_context: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetPlaintextResult]
func GetPlaintext(ctx *Context, args *GetPlaintextArgs, opts ...InvokeOption) (*GetPlaintextResult, error)
func GetPlaintextOutput(ctx *Context, args *GetPlaintextOutputArgs, opts ...InvokeOption) GetPlaintextResultOutput
> Note: This function is named GetPlaintext
in the Go SDK.
public static class GetPlaintext
{
public static Task<GetPlaintextResult> InvokeAsync(GetPlaintextArgs args, InvokeOptions? opts = null)
public static Output<GetPlaintextResult> Invoke(GetPlaintextInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetPlaintextResult> getPlaintext(GetPlaintextArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: alicloud:kms/getPlaintext:getPlaintext
arguments:
# arguments dictionary
The following arguments are supported:
- Ciphertext
Blob string - The ciphertext to be decrypted.
- Encryption
Context Dictionary<string, string> - (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.
- Ciphertext
Blob string - The ciphertext to be decrypted.
- Encryption
Context map[string]string - (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.
- ciphertext
Blob String - The ciphertext to be decrypted.
- encryption
Context Map<String,String> - (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.
- ciphertext
Blob string - The ciphertext to be decrypted.
- encryption
Context {[key: string]: string} - (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.
- ciphertext_
blob str - The ciphertext to be decrypted.
- encryption_
context Mapping[str, str] - (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.
- ciphertext
Blob String - The ciphertext to be decrypted.
- encryption
Context Map<String> - (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.
getPlaintext Result
The following output properties are available:
- Ciphertext
Blob string - Id string
- The provider-assigned unique ID for this managed resource.
- Key
Id string - The globally unique ID of the CMK. It is the ID of the CMK used to decrypt ciphertext.
- Plaintext string
- The decrypted plaintext.
- Encryption
Context Dictionary<string, string>
- Ciphertext
Blob string - Id string
- The provider-assigned unique ID for this managed resource.
- Key
Id string - The globally unique ID of the CMK. It is the ID of the CMK used to decrypt ciphertext.
- Plaintext string
- The decrypted plaintext.
- Encryption
Context map[string]string
- ciphertext
Blob String - id String
- The provider-assigned unique ID for this managed resource.
- key
Id String - The globally unique ID of the CMK. It is the ID of the CMK used to decrypt ciphertext.
- plaintext String
- The decrypted plaintext.
- encryption
Context Map<String,String>
- ciphertext
Blob string - id string
- The provider-assigned unique ID for this managed resource.
- key
Id string - The globally unique ID of the CMK. It is the ID of the CMK used to decrypt ciphertext.
- plaintext string
- The decrypted plaintext.
- encryption
Context {[key: string]: string}
- ciphertext_
blob str - id str
- The provider-assigned unique ID for this managed resource.
- key_
id str - The globally unique ID of the CMK. It is the ID of the CMK used to decrypt ciphertext.
- plaintext str
- The decrypted plaintext.
- encryption_
context Mapping[str, str]
- ciphertext
Blob String - id String
- The provider-assigned unique ID for this managed resource.
- key
Id String - The globally unique ID of the CMK. It is the ID of the CMK used to decrypt ciphertext.
- plaintext String
- The decrypted plaintext.
- encryption
Context Map<String>
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.