/
ciphertext.go
303 lines (253 loc) · 10.9 KB
/
ciphertext.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
// 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"
"errors"
"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"),
// Status: pulumi.String("Enabled"),
// PendingWindowInDays: pulumi.Int(7),
// })
// if err != nil {
// return err
// }
// _, err = kms.NewCiphertext(ctx, "encrypted", &kms.CiphertextArgs{
// KeyId: key.ID(),
// Plaintext: pulumi.String("example"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
type Ciphertext struct {
pulumi.CustomResourceState
// The ciphertext of the data key encrypted with the primary CMK version.
CiphertextBlob pulumi.StringOutput `pulumi:"ciphertextBlob"`
// The Encryption context. If you specify this parameter here, 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.StringMapOutput `pulumi:"encryptionContext"`
// The globally unique ID of the CMK.
KeyId pulumi.StringOutput `pulumi:"keyId"`
// The plaintext to be encrypted which must be encoded in Base64.
Plaintext pulumi.StringOutput `pulumi:"plaintext"`
}
// NewCiphertext registers a new resource with the given unique name, arguments, and options.
func NewCiphertext(ctx *pulumi.Context,
name string, args *CiphertextArgs, opts ...pulumi.ResourceOption) (*Ciphertext, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.KeyId == nil {
return nil, errors.New("invalid value for required argument 'KeyId'")
}
if args.Plaintext == nil {
return nil, errors.New("invalid value for required argument 'Plaintext'")
}
if args.Plaintext != nil {
args.Plaintext = pulumi.ToSecret(args.Plaintext).(pulumi.StringInput)
}
secrets := pulumi.AdditionalSecretOutputs([]string{
"plaintext",
})
opts = append(opts, secrets)
opts = internal.PkgResourceDefaultOpts(opts)
var resource Ciphertext
err := ctx.RegisterResource("alicloud:kms/ciphertext:Ciphertext", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetCiphertext gets an existing Ciphertext resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetCiphertext(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *CiphertextState, opts ...pulumi.ResourceOption) (*Ciphertext, error) {
var resource Ciphertext
err := ctx.ReadResource("alicloud:kms/ciphertext:Ciphertext", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Ciphertext resources.
type ciphertextState struct {
// The ciphertext of the data key encrypted with the primary CMK version.
CiphertextBlob *string `pulumi:"ciphertextBlob"`
// The Encryption context. If you specify this parameter here, 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"`
// The globally unique ID of the CMK.
KeyId *string `pulumi:"keyId"`
// The plaintext to be encrypted which must be encoded in Base64.
Plaintext *string `pulumi:"plaintext"`
}
type CiphertextState struct {
// The ciphertext of the data key encrypted with the primary CMK version.
CiphertextBlob pulumi.StringPtrInput
// The Encryption context. If you specify this parameter here, 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
// The globally unique ID of the CMK.
KeyId pulumi.StringPtrInput
// The plaintext to be encrypted which must be encoded in Base64.
Plaintext pulumi.StringPtrInput
}
func (CiphertextState) ElementType() reflect.Type {
return reflect.TypeOf((*ciphertextState)(nil)).Elem()
}
type ciphertextArgs struct {
// The Encryption context. If you specify this parameter here, 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"`
// The globally unique ID of the CMK.
KeyId string `pulumi:"keyId"`
// The plaintext to be encrypted which must be encoded in Base64.
Plaintext string `pulumi:"plaintext"`
}
// The set of arguments for constructing a Ciphertext resource.
type CiphertextArgs struct {
// The Encryption context. If you specify this parameter here, 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
// The globally unique ID of the CMK.
KeyId pulumi.StringInput
// The plaintext to be encrypted which must be encoded in Base64.
Plaintext pulumi.StringInput
}
func (CiphertextArgs) ElementType() reflect.Type {
return reflect.TypeOf((*ciphertextArgs)(nil)).Elem()
}
type CiphertextInput interface {
pulumi.Input
ToCiphertextOutput() CiphertextOutput
ToCiphertextOutputWithContext(ctx context.Context) CiphertextOutput
}
func (*Ciphertext) ElementType() reflect.Type {
return reflect.TypeOf((**Ciphertext)(nil)).Elem()
}
func (i *Ciphertext) ToCiphertextOutput() CiphertextOutput {
return i.ToCiphertextOutputWithContext(context.Background())
}
func (i *Ciphertext) ToCiphertextOutputWithContext(ctx context.Context) CiphertextOutput {
return pulumi.ToOutputWithContext(ctx, i).(CiphertextOutput)
}
// CiphertextArrayInput is an input type that accepts CiphertextArray and CiphertextArrayOutput values.
// You can construct a concrete instance of `CiphertextArrayInput` via:
//
// CiphertextArray{ CiphertextArgs{...} }
type CiphertextArrayInput interface {
pulumi.Input
ToCiphertextArrayOutput() CiphertextArrayOutput
ToCiphertextArrayOutputWithContext(context.Context) CiphertextArrayOutput
}
type CiphertextArray []CiphertextInput
func (CiphertextArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Ciphertext)(nil)).Elem()
}
func (i CiphertextArray) ToCiphertextArrayOutput() CiphertextArrayOutput {
return i.ToCiphertextArrayOutputWithContext(context.Background())
}
func (i CiphertextArray) ToCiphertextArrayOutputWithContext(ctx context.Context) CiphertextArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(CiphertextArrayOutput)
}
// CiphertextMapInput is an input type that accepts CiphertextMap and CiphertextMapOutput values.
// You can construct a concrete instance of `CiphertextMapInput` via:
//
// CiphertextMap{ "key": CiphertextArgs{...} }
type CiphertextMapInput interface {
pulumi.Input
ToCiphertextMapOutput() CiphertextMapOutput
ToCiphertextMapOutputWithContext(context.Context) CiphertextMapOutput
}
type CiphertextMap map[string]CiphertextInput
func (CiphertextMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Ciphertext)(nil)).Elem()
}
func (i CiphertextMap) ToCiphertextMapOutput() CiphertextMapOutput {
return i.ToCiphertextMapOutputWithContext(context.Background())
}
func (i CiphertextMap) ToCiphertextMapOutputWithContext(ctx context.Context) CiphertextMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(CiphertextMapOutput)
}
type CiphertextOutput struct{ *pulumi.OutputState }
func (CiphertextOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Ciphertext)(nil)).Elem()
}
func (o CiphertextOutput) ToCiphertextOutput() CiphertextOutput {
return o
}
func (o CiphertextOutput) ToCiphertextOutputWithContext(ctx context.Context) CiphertextOutput {
return o
}
// The ciphertext of the data key encrypted with the primary CMK version.
func (o CiphertextOutput) CiphertextBlob() pulumi.StringOutput {
return o.ApplyT(func(v *Ciphertext) pulumi.StringOutput { return v.CiphertextBlob }).(pulumi.StringOutput)
}
// The Encryption context. If you specify this parameter here, 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).
func (o CiphertextOutput) EncryptionContext() pulumi.StringMapOutput {
return o.ApplyT(func(v *Ciphertext) pulumi.StringMapOutput { return v.EncryptionContext }).(pulumi.StringMapOutput)
}
// The globally unique ID of the CMK.
func (o CiphertextOutput) KeyId() pulumi.StringOutput {
return o.ApplyT(func(v *Ciphertext) pulumi.StringOutput { return v.KeyId }).(pulumi.StringOutput)
}
// The plaintext to be encrypted which must be encoded in Base64.
func (o CiphertextOutput) Plaintext() pulumi.StringOutput {
return o.ApplyT(func(v *Ciphertext) pulumi.StringOutput { return v.Plaintext }).(pulumi.StringOutput)
}
type CiphertextArrayOutput struct{ *pulumi.OutputState }
func (CiphertextArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Ciphertext)(nil)).Elem()
}
func (o CiphertextArrayOutput) ToCiphertextArrayOutput() CiphertextArrayOutput {
return o
}
func (o CiphertextArrayOutput) ToCiphertextArrayOutputWithContext(ctx context.Context) CiphertextArrayOutput {
return o
}
func (o CiphertextArrayOutput) Index(i pulumi.IntInput) CiphertextOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Ciphertext {
return vs[0].([]*Ciphertext)[vs[1].(int)]
}).(CiphertextOutput)
}
type CiphertextMapOutput struct{ *pulumi.OutputState }
func (CiphertextMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Ciphertext)(nil)).Elem()
}
func (o CiphertextMapOutput) ToCiphertextMapOutput() CiphertextMapOutput {
return o
}
func (o CiphertextMapOutput) ToCiphertextMapOutputWithContext(ctx context.Context) CiphertextMapOutput {
return o
}
func (o CiphertextMapOutput) MapIndex(k pulumi.StringInput) CiphertextOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Ciphertext {
return vs[0].(map[string]*Ciphertext)[vs[1].(string)]
}).(CiphertextOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*CiphertextInput)(nil)).Elem(), &Ciphertext{})
pulumi.RegisterInputType(reflect.TypeOf((*CiphertextArrayInput)(nil)).Elem(), CiphertextArray{})
pulumi.RegisterInputType(reflect.TypeOf((*CiphertextMapInput)(nil)).Elem(), CiphertextMap{})
pulumi.RegisterOutputType(CiphertextOutput{})
pulumi.RegisterOutputType(CiphertextArrayOutput{})
pulumi.RegisterOutputType(CiphertextMapOutput{})
}