github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/kms/getCipherText.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package kms
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    11  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    12  )
    13  
    14  // The KMS ciphertext data source allows you to encrypt plaintext into ciphertext
    15  // by using an AWS KMS customer master key. The value returned by this data source
    16  // changes every apply. For a stable ciphertext value, see the `kms.Ciphertext`
    17  // resource.
    18  //
    19  // ## Example Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/kms"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			oauthConfig, err := kms.NewKey(ctx, "oauth_config", &kms.KeyArgs{
    35  //				Description: pulumi.String("oauth config"),
    36  //				IsEnabled:   pulumi.Bool(true),
    37  //			})
    38  //			if err != nil {
    39  //				return err
    40  //			}
    41  //			_ = kms.GetCipherTextOutput(ctx, kms.GetCipherTextOutputArgs{
    42  //				KeyId:     oauthConfig.KeyId,
    43  //				Plaintext: pulumi.String("{\n  \"client_id\": \"e587dbae22222f55da22\",\n  \"client_secret\": \"8289575d00000ace55e1815ec13673955721b8a5\"\n}\n"),
    44  //			}, nil)
    45  //			return nil
    46  //		})
    47  //	}
    48  //
    49  // ```
    50  // <!--End PulumiCodeChooser -->
    51  func GetCipherText(ctx *pulumi.Context, args *GetCipherTextArgs, opts ...pulumi.InvokeOption) (*GetCipherTextResult, error) {
    52  	opts = internal.PkgInvokeDefaultOpts(opts)
    53  	var rv GetCipherTextResult
    54  	err := ctx.Invoke("aws:kms/getCipherText:getCipherText", args, &rv, opts...)
    55  	if err != nil {
    56  		return nil, err
    57  	}
    58  	return &rv, nil
    59  }
    60  
    61  // A collection of arguments for invoking getCipherText.
    62  type GetCipherTextArgs struct {
    63  	// An optional mapping that makes up the encryption context.
    64  	Context map[string]string `pulumi:"context"`
    65  	// Globally unique key ID for the customer master key.
    66  	KeyId string `pulumi:"keyId"`
    67  	// Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
    68  	Plaintext string `pulumi:"plaintext"`
    69  }
    70  
    71  // A collection of values returned by getCipherText.
    72  type GetCipherTextResult struct {
    73  	// Base64 encoded ciphertext
    74  	CiphertextBlob string            `pulumi:"ciphertextBlob"`
    75  	Context        map[string]string `pulumi:"context"`
    76  	// The provider-assigned unique ID for this managed resource.
    77  	Id        string `pulumi:"id"`
    78  	KeyId     string `pulumi:"keyId"`
    79  	Plaintext string `pulumi:"plaintext"`
    80  }
    81  
    82  func GetCipherTextOutput(ctx *pulumi.Context, args GetCipherTextOutputArgs, opts ...pulumi.InvokeOption) GetCipherTextResultOutput {
    83  	return pulumi.ToOutputWithContext(context.Background(), args).
    84  		ApplyT(func(v interface{}) (GetCipherTextResult, error) {
    85  			args := v.(GetCipherTextArgs)
    86  			r, err := GetCipherText(ctx, &args, opts...)
    87  			var s GetCipherTextResult
    88  			if r != nil {
    89  				s = *r
    90  			}
    91  			return s, err
    92  		}).(GetCipherTextResultOutput)
    93  }
    94  
    95  // A collection of arguments for invoking getCipherText.
    96  type GetCipherTextOutputArgs struct {
    97  	// An optional mapping that makes up the encryption context.
    98  	Context pulumi.StringMapInput `pulumi:"context"`
    99  	// Globally unique key ID for the customer master key.
   100  	KeyId pulumi.StringInput `pulumi:"keyId"`
   101  	// Data to be encrypted. Note that this may show up in logs, and it will be stored in the state file.
   102  	Plaintext pulumi.StringInput `pulumi:"plaintext"`
   103  }
   104  
   105  func (GetCipherTextOutputArgs) ElementType() reflect.Type {
   106  	return reflect.TypeOf((*GetCipherTextArgs)(nil)).Elem()
   107  }
   108  
   109  // A collection of values returned by getCipherText.
   110  type GetCipherTextResultOutput struct{ *pulumi.OutputState }
   111  
   112  func (GetCipherTextResultOutput) ElementType() reflect.Type {
   113  	return reflect.TypeOf((*GetCipherTextResult)(nil)).Elem()
   114  }
   115  
   116  func (o GetCipherTextResultOutput) ToGetCipherTextResultOutput() GetCipherTextResultOutput {
   117  	return o
   118  }
   119  
   120  func (o GetCipherTextResultOutput) ToGetCipherTextResultOutputWithContext(ctx context.Context) GetCipherTextResultOutput {
   121  	return o
   122  }
   123  
   124  // Base64 encoded ciphertext
   125  func (o GetCipherTextResultOutput) CiphertextBlob() pulumi.StringOutput {
   126  	return o.ApplyT(func(v GetCipherTextResult) string { return v.CiphertextBlob }).(pulumi.StringOutput)
   127  }
   128  
   129  func (o GetCipherTextResultOutput) Context() pulumi.StringMapOutput {
   130  	return o.ApplyT(func(v GetCipherTextResult) map[string]string { return v.Context }).(pulumi.StringMapOutput)
   131  }
   132  
   133  // The provider-assigned unique ID for this managed resource.
   134  func (o GetCipherTextResultOutput) Id() pulumi.StringOutput {
   135  	return o.ApplyT(func(v GetCipherTextResult) string { return v.Id }).(pulumi.StringOutput)
   136  }
   137  
   138  func (o GetCipherTextResultOutput) KeyId() pulumi.StringOutput {
   139  	return o.ApplyT(func(v GetCipherTextResult) string { return v.KeyId }).(pulumi.StringOutput)
   140  }
   141  
   142  func (o GetCipherTextResultOutput) Plaintext() pulumi.StringOutput {
   143  	return o.ApplyT(func(v GetCipherTextResult) string { return v.Plaintext }).(pulumi.StringOutput)
   144  }
   145  
   146  func init() {
   147  	pulumi.RegisterOutputType(GetCipherTextResultOutput{})
   148  }