/
getPlaintext.go
150 lines (131 loc) · 5.31 KB
/
getPlaintext.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package kms
import (
"context"
"reflect"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// ## Example Usage
//
// ```go
// 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
// })
// }
//
// ```
func GetPlaintext(ctx *pulumi.Context, args *GetPlaintextArgs, opts ...pulumi.InvokeOption) (*GetPlaintextResult, error) {
opts = internal.PkgInvokeDefaultOpts(opts)
var rv GetPlaintextResult
err := ctx.Invoke("alicloud:kms/getPlaintext:getPlaintext", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getPlaintext.
type GetPlaintextArgs struct {
// The ciphertext to be decrypted.
CiphertextBlob string `pulumi:"ciphertextBlob"`
// (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](https://www.alibabacloud.com/help/doc-detail/42975.htm).
EncryptionContext map[string]string `pulumi:"encryptionContext"`
}
// A collection of values returned by getPlaintext.
type GetPlaintextResult struct {
CiphertextBlob string `pulumi:"ciphertextBlob"`
EncryptionContext map[string]string `pulumi:"encryptionContext"`
// The provider-assigned unique ID for this managed resource.
Id string `pulumi:"id"`
// The globally unique ID of the CMK. It is the ID of the CMK used to decrypt ciphertext.
KeyId string `pulumi:"keyId"`
// The decrypted plaintext.
Plaintext string `pulumi:"plaintext"`
}
func GetPlaintextOutput(ctx *pulumi.Context, args GetPlaintextOutputArgs, opts ...pulumi.InvokeOption) GetPlaintextResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (GetPlaintextResult, error) {
args := v.(GetPlaintextArgs)
r, err := GetPlaintext(ctx, &args, opts...)
var s GetPlaintextResult
if r != nil {
s = *r
}
return s, err
}).(GetPlaintextResultOutput)
}
// A collection of arguments for invoking getPlaintext.
type GetPlaintextOutputArgs struct {
// The ciphertext to be decrypted.
CiphertextBlob pulumi.StringInput `pulumi:"ciphertextBlob"`
// (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](https://www.alibabacloud.com/help/doc-detail/42975.htm).
EncryptionContext pulumi.StringMapInput `pulumi:"encryptionContext"`
}
func (GetPlaintextOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*GetPlaintextArgs)(nil)).Elem()
}
// A collection of values returned by getPlaintext.
type GetPlaintextResultOutput struct{ *pulumi.OutputState }
func (GetPlaintextResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*GetPlaintextResult)(nil)).Elem()
}
func (o GetPlaintextResultOutput) ToGetPlaintextResultOutput() GetPlaintextResultOutput {
return o
}
func (o GetPlaintextResultOutput) ToGetPlaintextResultOutputWithContext(ctx context.Context) GetPlaintextResultOutput {
return o
}
func (o GetPlaintextResultOutput) CiphertextBlob() pulumi.StringOutput {
return o.ApplyT(func(v GetPlaintextResult) string { return v.CiphertextBlob }).(pulumi.StringOutput)
}
func (o GetPlaintextResultOutput) EncryptionContext() pulumi.StringMapOutput {
return o.ApplyT(func(v GetPlaintextResult) map[string]string { return v.EncryptionContext }).(pulumi.StringMapOutput)
}
// The provider-assigned unique ID for this managed resource.
func (o GetPlaintextResultOutput) Id() pulumi.StringOutput {
return o.ApplyT(func(v GetPlaintextResult) string { return v.Id }).(pulumi.StringOutput)
}
// The globally unique ID of the CMK. It is the ID of the CMK used to decrypt ciphertext.
func (o GetPlaintextResultOutput) KeyId() pulumi.StringOutput {
return o.ApplyT(func(v GetPlaintextResult) string { return v.KeyId }).(pulumi.StringOutput)
}
// The decrypted plaintext.
func (o GetPlaintextResultOutput) Plaintext() pulumi.StringOutput {
return o.ApplyT(func(v GetPlaintextResult) string { return v.Plaintext }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterOutputType(GetPlaintextResultOutput{})
}