1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. kms
  5. getPlaintext
Alibaba Cloud v3.51.0 published on Saturday, Mar 23, 2024 by Pulumi

alicloud.kms.getPlaintext

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.51.0 published on Saturday, Mar 23, 2024 by Pulumi

    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",
    });
    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")
    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
    		}
    		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",
        });
    
        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());
    
            var encrypted = new Ciphertext("encrypted", CiphertextArgs.builder()        
                .keyId(key.id())
                .plaintext("example")
                .build());
    
            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:
      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:

    CiphertextBlob string
    The ciphertext to be decrypted.
    EncryptionContext 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.
    CiphertextBlob string
    The ciphertext to be decrypted.
    EncryptionContext 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.
    ciphertextBlob String
    The ciphertext to be decrypted.
    encryptionContext 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.
    ciphertextBlob string
    The ciphertext to be decrypted.
    encryptionContext {[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.
    ciphertextBlob String
    The ciphertext to be decrypted.
    encryptionContext 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:

    CiphertextBlob string
    Id string
    The provider-assigned unique ID for this managed resource.
    KeyId string
    The globally unique ID of the CMK. It is the ID of the CMK used to decrypt ciphertext.
    Plaintext string
    The decrypted plaintext.
    EncryptionContext Dictionary<string, string>
    CiphertextBlob string
    Id string
    The provider-assigned unique ID for this managed resource.
    KeyId string
    The globally unique ID of the CMK. It is the ID of the CMK used to decrypt ciphertext.
    Plaintext string
    The decrypted plaintext.
    EncryptionContext map[string]string
    ciphertextBlob String
    id String
    The provider-assigned unique ID for this managed resource.
    keyId String
    The globally unique ID of the CMK. It is the ID of the CMK used to decrypt ciphertext.
    plaintext String
    The decrypted plaintext.
    encryptionContext Map<String,String>
    ciphertextBlob string
    id string
    The provider-assigned unique ID for this managed resource.
    keyId string
    The globally unique ID of the CMK. It is the ID of the CMK used to decrypt ciphertext.
    plaintext string
    The decrypted plaintext.
    encryptionContext {[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]
    ciphertextBlob String
    id String
    The provider-assigned unique ID for this managed resource.
    keyId String
    The globally unique ID of the CMK. It is the ID of the CMK used to decrypt ciphertext.
    plaintext String
    The decrypted plaintext.
    encryptionContext 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.
    alicloud logo
    Alibaba Cloud v3.51.0 published on Saturday, Mar 23, 2024 by Pulumi