/
tlsPlatformCertificate.go
397 lines (351 loc) · 16.1 KB
/
tlsPlatformCertificate.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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
// 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 fastly
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Uploads a TLS certificate to the Fastly Platform TLS service.
//
// > Each TLS certificate **must** have its corresponding private key uploaded _prior_ to uploading the certificate.
//
// ## Example Usage
//
// Basic usage with self-signed CA:
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-fastly/sdk/v4/go/fastly"
// "github.com/pulumi/pulumi-tls/sdk/v4/go/tls"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// caKey, err := tls.NewPrivateKey(ctx, "caKey", &tls.PrivateKeyArgs{
// Algorithm: pulumi.String("RSA"),
// })
// if err != nil {
// return err
// }
// keyPrivateKey, err := tls.NewPrivateKey(ctx, "keyPrivateKey", &tls.PrivateKeyArgs{
// Algorithm: pulumi.String("RSA"),
// })
// if err != nil {
// return err
// }
// ca, err := tls.NewSelfSignedCert(ctx, "ca", &tls.SelfSignedCertArgs{
// KeyAlgorithm: caKey.Algorithm,
// PrivateKeyPem: caKey.PrivateKeyPem,
// Subjects: SelfSignedCertSubjectArray{
// &SelfSignedCertSubjectArgs{
// CommonName: pulumi.String("Example CA"),
// },
// },
// IsCaCertificate: pulumi.Bool(true),
// ValidityPeriodHours: pulumi.Int(360),
// AllowedUses: pulumi.StringArray{
// pulumi.String("cert_signing"),
// pulumi.String("server_auth"),
// },
// })
// if err != nil {
// return err
// }
// example, err := tls.NewCertRequest(ctx, "example", &tls.CertRequestArgs{
// KeyAlgorithm: keyPrivateKey.Algorithm,
// PrivateKeyPem: keyPrivateKey.PrivateKeyPem,
// Subjects: CertRequestSubjectArray{
// &CertRequestSubjectArgs{
// CommonName: pulumi.String("example.com"),
// },
// },
// DnsNames: pulumi.StringArray{
// pulumi.String("example.com"),
// pulumi.String("www.example.com"),
// },
// })
// if err != nil {
// return err
// }
// certLocallySignedCert, err := tls.NewLocallySignedCert(ctx, "certLocallySignedCert", &tls.LocallySignedCertArgs{
// CertRequestPem: example.CertRequestPem,
// CaKeyAlgorithm: caKey.Algorithm,
// CaPrivateKeyPem: caKey.PrivateKeyPem,
// CaCertPem: ca.CertPem,
// ValidityPeriodHours: pulumi.Int(360),
// AllowedUses: pulumi.StringArray{
// pulumi.String("cert_signing"),
// pulumi.String("server_auth"),
// },
// })
// if err != nil {
// return err
// }
// config, err := fastly.GetTlsConfiguration(ctx, &GetTlsConfigurationArgs{
// TlsService: pulumi.StringRef("PLATFORM"),
// }, nil)
// if err != nil {
// return err
// }
// keyTlsPrivateKey, err := fastly.NewTlsPrivateKey(ctx, "keyTlsPrivateKey", &fastly.TlsPrivateKeyArgs{
// KeyPem: keyPrivateKey.PrivateKeyPem,
// })
// if err != nil {
// return err
// }
// _, err = fastly.NewTlsPlatformCertificate(ctx, "certTlsPlatformCertificate", &fastly.TlsPlatformCertificateArgs{
// CertificateBody: certLocallySignedCert.CertPem,
// IntermediatesBlob: ca.CertPem,
// ConfigurationId: pulumi.String(config.Id),
// AllowUntrustedRoot: pulumi.Bool(true),
// }, pulumi.DependsOn([]pulumi.Resource{
// keyTlsPrivateKey,
// }))
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// A certificate can be imported using its Fastly certificate ID, e.g.
//
// ```sh
// $ pulumi import fastly:index/tlsPlatformCertificate:TlsPlatformCertificate demo xxxxxxxxxxx
// ```
type TlsPlatformCertificate struct {
pulumi.CustomResourceState
// Disable checking whether the root of the certificate chain is trusted. Useful for development purposes to allow use of self-signed CAs. Defaults to false. Write-only on create.
AllowUntrustedRoot pulumi.BoolPtrOutput `pulumi:"allowUntrustedRoot"`
// PEM-formatted certificate.
CertificateBody pulumi.StringOutput `pulumi:"certificateBody"`
// ID of TLS configuration to be used to terminate TLS traffic.
ConfigurationId pulumi.StringOutput `pulumi:"configurationId"`
// Timestamp (GMT) when the certificate was created.
CreatedAt pulumi.StringOutput `pulumi:"createdAt"`
// All the domains (including wildcard domains) that are listed in any certificate's Subject Alternative Names (SAN) list.
Domains pulumi.StringArrayOutput `pulumi:"domains"`
// PEM-formatted certificate chain from the `certificateBody` to its root.
IntermediatesBlob pulumi.StringOutput `pulumi:"intermediatesBlob"`
// Timestamp (GMT) when the certificate will expire.
NotAfter pulumi.StringOutput `pulumi:"notAfter"`
// Timestamp (GMT) when the certificate will become valid.
NotBefore pulumi.StringOutput `pulumi:"notBefore"`
// A recommendation from Fastly indicating the key associated with this certificate is in need of rotation.
Replace pulumi.BoolOutput `pulumi:"replace"`
// Timestamp (GMT) when the certificate was last updated.
UpdatedAt pulumi.StringOutput `pulumi:"updatedAt"`
}
// NewTlsPlatformCertificate registers a new resource with the given unique name, arguments, and options.
func NewTlsPlatformCertificate(ctx *pulumi.Context,
name string, args *TlsPlatformCertificateArgs, opts ...pulumi.ResourceOption) (*TlsPlatformCertificate, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.CertificateBody == nil {
return nil, errors.New("invalid value for required argument 'CertificateBody'")
}
if args.ConfigurationId == nil {
return nil, errors.New("invalid value for required argument 'ConfigurationId'")
}
if args.IntermediatesBlob == nil {
return nil, errors.New("invalid value for required argument 'IntermediatesBlob'")
}
var resource TlsPlatformCertificate
err := ctx.RegisterResource("fastly:index/tlsPlatformCertificate:TlsPlatformCertificate", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetTlsPlatformCertificate gets an existing TlsPlatformCertificate 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 GetTlsPlatformCertificate(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *TlsPlatformCertificateState, opts ...pulumi.ResourceOption) (*TlsPlatformCertificate, error) {
var resource TlsPlatformCertificate
err := ctx.ReadResource("fastly:index/tlsPlatformCertificate:TlsPlatformCertificate", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering TlsPlatformCertificate resources.
type tlsPlatformCertificateState struct {
// Disable checking whether the root of the certificate chain is trusted. Useful for development purposes to allow use of self-signed CAs. Defaults to false. Write-only on create.
AllowUntrustedRoot *bool `pulumi:"allowUntrustedRoot"`
// PEM-formatted certificate.
CertificateBody *string `pulumi:"certificateBody"`
// ID of TLS configuration to be used to terminate TLS traffic.
ConfigurationId *string `pulumi:"configurationId"`
// Timestamp (GMT) when the certificate was created.
CreatedAt *string `pulumi:"createdAt"`
// All the domains (including wildcard domains) that are listed in any certificate's Subject Alternative Names (SAN) list.
Domains []string `pulumi:"domains"`
// PEM-formatted certificate chain from the `certificateBody` to its root.
IntermediatesBlob *string `pulumi:"intermediatesBlob"`
// Timestamp (GMT) when the certificate will expire.
NotAfter *string `pulumi:"notAfter"`
// Timestamp (GMT) when the certificate will become valid.
NotBefore *string `pulumi:"notBefore"`
// A recommendation from Fastly indicating the key associated with this certificate is in need of rotation.
Replace *bool `pulumi:"replace"`
// Timestamp (GMT) when the certificate was last updated.
UpdatedAt *string `pulumi:"updatedAt"`
}
type TlsPlatformCertificateState struct {
// Disable checking whether the root of the certificate chain is trusted. Useful for development purposes to allow use of self-signed CAs. Defaults to false. Write-only on create.
AllowUntrustedRoot pulumi.BoolPtrInput
// PEM-formatted certificate.
CertificateBody pulumi.StringPtrInput
// ID of TLS configuration to be used to terminate TLS traffic.
ConfigurationId pulumi.StringPtrInput
// Timestamp (GMT) when the certificate was created.
CreatedAt pulumi.StringPtrInput
// All the domains (including wildcard domains) that are listed in any certificate's Subject Alternative Names (SAN) list.
Domains pulumi.StringArrayInput
// PEM-formatted certificate chain from the `certificateBody` to its root.
IntermediatesBlob pulumi.StringPtrInput
// Timestamp (GMT) when the certificate will expire.
NotAfter pulumi.StringPtrInput
// Timestamp (GMT) when the certificate will become valid.
NotBefore pulumi.StringPtrInput
// A recommendation from Fastly indicating the key associated with this certificate is in need of rotation.
Replace pulumi.BoolPtrInput
// Timestamp (GMT) when the certificate was last updated.
UpdatedAt pulumi.StringPtrInput
}
func (TlsPlatformCertificateState) ElementType() reflect.Type {
return reflect.TypeOf((*tlsPlatformCertificateState)(nil)).Elem()
}
type tlsPlatformCertificateArgs struct {
// Disable checking whether the root of the certificate chain is trusted. Useful for development purposes to allow use of self-signed CAs. Defaults to false. Write-only on create.
AllowUntrustedRoot *bool `pulumi:"allowUntrustedRoot"`
// PEM-formatted certificate.
CertificateBody string `pulumi:"certificateBody"`
// ID of TLS configuration to be used to terminate TLS traffic.
ConfigurationId string `pulumi:"configurationId"`
// PEM-formatted certificate chain from the `certificateBody` to its root.
IntermediatesBlob string `pulumi:"intermediatesBlob"`
}
// The set of arguments for constructing a TlsPlatformCertificate resource.
type TlsPlatformCertificateArgs struct {
// Disable checking whether the root of the certificate chain is trusted. Useful for development purposes to allow use of self-signed CAs. Defaults to false. Write-only on create.
AllowUntrustedRoot pulumi.BoolPtrInput
// PEM-formatted certificate.
CertificateBody pulumi.StringInput
// ID of TLS configuration to be used to terminate TLS traffic.
ConfigurationId pulumi.StringInput
// PEM-formatted certificate chain from the `certificateBody` to its root.
IntermediatesBlob pulumi.StringInput
}
func (TlsPlatformCertificateArgs) ElementType() reflect.Type {
return reflect.TypeOf((*tlsPlatformCertificateArgs)(nil)).Elem()
}
type TlsPlatformCertificateInput interface {
pulumi.Input
ToTlsPlatformCertificateOutput() TlsPlatformCertificateOutput
ToTlsPlatformCertificateOutputWithContext(ctx context.Context) TlsPlatformCertificateOutput
}
func (*TlsPlatformCertificate) ElementType() reflect.Type {
return reflect.TypeOf((**TlsPlatformCertificate)(nil)).Elem()
}
func (i *TlsPlatformCertificate) ToTlsPlatformCertificateOutput() TlsPlatformCertificateOutput {
return i.ToTlsPlatformCertificateOutputWithContext(context.Background())
}
func (i *TlsPlatformCertificate) ToTlsPlatformCertificateOutputWithContext(ctx context.Context) TlsPlatformCertificateOutput {
return pulumi.ToOutputWithContext(ctx, i).(TlsPlatformCertificateOutput)
}
// TlsPlatformCertificateArrayInput is an input type that accepts TlsPlatformCertificateArray and TlsPlatformCertificateArrayOutput values.
// You can construct a concrete instance of `TlsPlatformCertificateArrayInput` via:
//
// TlsPlatformCertificateArray{ TlsPlatformCertificateArgs{...} }
type TlsPlatformCertificateArrayInput interface {
pulumi.Input
ToTlsPlatformCertificateArrayOutput() TlsPlatformCertificateArrayOutput
ToTlsPlatformCertificateArrayOutputWithContext(context.Context) TlsPlatformCertificateArrayOutput
}
type TlsPlatformCertificateArray []TlsPlatformCertificateInput
func (TlsPlatformCertificateArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*TlsPlatformCertificate)(nil)).Elem()
}
func (i TlsPlatformCertificateArray) ToTlsPlatformCertificateArrayOutput() TlsPlatformCertificateArrayOutput {
return i.ToTlsPlatformCertificateArrayOutputWithContext(context.Background())
}
func (i TlsPlatformCertificateArray) ToTlsPlatformCertificateArrayOutputWithContext(ctx context.Context) TlsPlatformCertificateArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(TlsPlatformCertificateArrayOutput)
}
// TlsPlatformCertificateMapInput is an input type that accepts TlsPlatformCertificateMap and TlsPlatformCertificateMapOutput values.
// You can construct a concrete instance of `TlsPlatformCertificateMapInput` via:
//
// TlsPlatformCertificateMap{ "key": TlsPlatformCertificateArgs{...} }
type TlsPlatformCertificateMapInput interface {
pulumi.Input
ToTlsPlatformCertificateMapOutput() TlsPlatformCertificateMapOutput
ToTlsPlatformCertificateMapOutputWithContext(context.Context) TlsPlatformCertificateMapOutput
}
type TlsPlatformCertificateMap map[string]TlsPlatformCertificateInput
func (TlsPlatformCertificateMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*TlsPlatformCertificate)(nil)).Elem()
}
func (i TlsPlatformCertificateMap) ToTlsPlatformCertificateMapOutput() TlsPlatformCertificateMapOutput {
return i.ToTlsPlatformCertificateMapOutputWithContext(context.Background())
}
func (i TlsPlatformCertificateMap) ToTlsPlatformCertificateMapOutputWithContext(ctx context.Context) TlsPlatformCertificateMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(TlsPlatformCertificateMapOutput)
}
type TlsPlatformCertificateOutput struct{ *pulumi.OutputState }
func (TlsPlatformCertificateOutput) ElementType() reflect.Type {
return reflect.TypeOf((**TlsPlatformCertificate)(nil)).Elem()
}
func (o TlsPlatformCertificateOutput) ToTlsPlatformCertificateOutput() TlsPlatformCertificateOutput {
return o
}
func (o TlsPlatformCertificateOutput) ToTlsPlatformCertificateOutputWithContext(ctx context.Context) TlsPlatformCertificateOutput {
return o
}
type TlsPlatformCertificateArrayOutput struct{ *pulumi.OutputState }
func (TlsPlatformCertificateArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*TlsPlatformCertificate)(nil)).Elem()
}
func (o TlsPlatformCertificateArrayOutput) ToTlsPlatformCertificateArrayOutput() TlsPlatformCertificateArrayOutput {
return o
}
func (o TlsPlatformCertificateArrayOutput) ToTlsPlatformCertificateArrayOutputWithContext(ctx context.Context) TlsPlatformCertificateArrayOutput {
return o
}
func (o TlsPlatformCertificateArrayOutput) Index(i pulumi.IntInput) TlsPlatformCertificateOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *TlsPlatformCertificate {
return vs[0].([]*TlsPlatformCertificate)[vs[1].(int)]
}).(TlsPlatformCertificateOutput)
}
type TlsPlatformCertificateMapOutput struct{ *pulumi.OutputState }
func (TlsPlatformCertificateMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*TlsPlatformCertificate)(nil)).Elem()
}
func (o TlsPlatformCertificateMapOutput) ToTlsPlatformCertificateMapOutput() TlsPlatformCertificateMapOutput {
return o
}
func (o TlsPlatformCertificateMapOutput) ToTlsPlatformCertificateMapOutputWithContext(ctx context.Context) TlsPlatformCertificateMapOutput {
return o
}
func (o TlsPlatformCertificateMapOutput) MapIndex(k pulumi.StringInput) TlsPlatformCertificateOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *TlsPlatformCertificate {
return vs[0].(map[string]*TlsPlatformCertificate)[vs[1].(string)]
}).(TlsPlatformCertificateOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*TlsPlatformCertificateInput)(nil)).Elem(), &TlsPlatformCertificate{})
pulumi.RegisterInputType(reflect.TypeOf((*TlsPlatformCertificateArrayInput)(nil)).Elem(), TlsPlatformCertificateArray{})
pulumi.RegisterInputType(reflect.TypeOf((*TlsPlatformCertificateMapInput)(nil)).Elem(), TlsPlatformCertificateMap{})
pulumi.RegisterOutputType(TlsPlatformCertificateOutput{})
pulumi.RegisterOutputType(TlsPlatformCertificateArrayOutput{})
pulumi.RegisterOutputType(TlsPlatformCertificateMapOutput{})
}