/
tlsCertificate.go
343 lines (297 loc) · 13.2 KB
/
tlsCertificate.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
// 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 custom TLS certificate to Fastly to be used to terminate TLS traffic.
//
// > Each TLS certificate **must** have its corresponding private key uploaded _prior_ to uploading the certificate.
//
// ## Example Usage
//
// Basic usage:
//
// ```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 {
// keyPrivateKey, err := tls.NewPrivateKey(ctx, "keyPrivateKey", &tls.PrivateKeyArgs{
// Algorithm: pulumi.String("RSA"),
// })
// if err != nil {
// return err
// }
// cert, err := tls.NewSelfSignedCert(ctx, "cert", &tls.SelfSignedCertArgs{
// KeyAlgorithm: keyPrivateKey.Algorithm,
// PrivateKeyPem: keyPrivateKey.PrivateKeyPem,
// Subjects: SelfSignedCertSubjectArray{
// &SelfSignedCertSubjectArgs{
// CommonName: pulumi.String("example.com"),
// },
// },
// IsCaCertificate: pulumi.Bool(true),
// ValidityPeriodHours: pulumi.Int(360),
// AllowedUses: pulumi.StringArray{
// pulumi.String("cert_signing"),
// pulumi.String("server_auth"),
// },
// DnsNames: pulumi.StringArray{
// pulumi.String("example.com"),
// },
// })
// if err != nil {
// return err
// }
// keyTlsPrivateKey, err := fastly.NewTlsPrivateKey(ctx, "keyTlsPrivateKey", &fastly.TlsPrivateKeyArgs{
// KeyPem: keyPrivateKey.PrivateKeyPem,
// })
// if err != nil {
// return err
// }
// _, err = fastly.NewTlsCertificate(ctx, "example", &fastly.TlsCertificateArgs{
// CertificateBody: cert.CertPem,
// }, pulumi.DependsOn([]pulumi.Resource{
// keyTlsPrivateKey,
// }))
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// > **Warning:** Updating the `TlsPrivateKey`/`TlsCertificate` resources should be done in multiple plan/apply steps to avoid potential downtime. The new certificate and associated private key must first be created so they exist alongside the currently active resources. Once the new resources have been created, then the `TlsActivation` can be updated to point to the new certificate. Finally, the original key/certificate resources can be deleted.
//
// ## Import
//
// A certificate can be imported using its Fastly certificate ID, e.g.
//
// ```sh
// $ pulumi import fastly:index/tlsCertificate:TlsCertificate demo xxxxxxxxxxx
// ```
type TlsCertificate struct {
pulumi.CustomResourceState
// PEM-formatted certificate, optionally including any intermediary certificates.
CertificateBody pulumi.StringOutput `pulumi:"certificateBody"`
// Timestamp (GMT) when the certificate was created.
CreatedAt pulumi.StringOutput `pulumi:"createdAt"`
// All the domains (including wildcard domains) that are listed in the certificate's Subject Alternative Names (SAN) list.
Domains pulumi.StringArrayOutput `pulumi:"domains"`
// The hostname for which a certificate was issued.
IssuedTo pulumi.StringOutput `pulumi:"issuedTo"`
// The certificate authority that issued the certificate.
Issuer pulumi.StringOutput `pulumi:"issuer"`
// Human-readable name used to identify the certificate. Defaults to the certificate's Common Name or first Subject Alternative Name entry.
Name pulumi.StringOutput `pulumi:"name"`
// A recommendation from Fastly indicating the key associated with this certificate is in need of rotation.
Replace pulumi.BoolOutput `pulumi:"replace"`
// A value assigned by the issuer that is unique to a certificate.
SerialNumber pulumi.StringOutput `pulumi:"serialNumber"`
// The algorithm used to sign the certificate.
SignatureAlgorithm pulumi.StringOutput `pulumi:"signatureAlgorithm"`
// Timestamp (GMT) when the certificate was last updated.
UpdatedAt pulumi.StringOutput `pulumi:"updatedAt"`
}
// NewTlsCertificate registers a new resource with the given unique name, arguments, and options.
func NewTlsCertificate(ctx *pulumi.Context,
name string, args *TlsCertificateArgs, opts ...pulumi.ResourceOption) (*TlsCertificate, 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'")
}
var resource TlsCertificate
err := ctx.RegisterResource("fastly:index/tlsCertificate:TlsCertificate", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetTlsCertificate gets an existing TlsCertificate 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 GetTlsCertificate(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *TlsCertificateState, opts ...pulumi.ResourceOption) (*TlsCertificate, error) {
var resource TlsCertificate
err := ctx.ReadResource("fastly:index/tlsCertificate:TlsCertificate", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering TlsCertificate resources.
type tlsCertificateState struct {
// PEM-formatted certificate, optionally including any intermediary certificates.
CertificateBody *string `pulumi:"certificateBody"`
// Timestamp (GMT) when the certificate was created.
CreatedAt *string `pulumi:"createdAt"`
// All the domains (including wildcard domains) that are listed in the certificate's Subject Alternative Names (SAN) list.
Domains []string `pulumi:"domains"`
// The hostname for which a certificate was issued.
IssuedTo *string `pulumi:"issuedTo"`
// The certificate authority that issued the certificate.
Issuer *string `pulumi:"issuer"`
// Human-readable name used to identify the certificate. Defaults to the certificate's Common Name or first Subject Alternative Name entry.
Name *string `pulumi:"name"`
// A recommendation from Fastly indicating the key associated with this certificate is in need of rotation.
Replace *bool `pulumi:"replace"`
// A value assigned by the issuer that is unique to a certificate.
SerialNumber *string `pulumi:"serialNumber"`
// The algorithm used to sign the certificate.
SignatureAlgorithm *string `pulumi:"signatureAlgorithm"`
// Timestamp (GMT) when the certificate was last updated.
UpdatedAt *string `pulumi:"updatedAt"`
}
type TlsCertificateState struct {
// PEM-formatted certificate, optionally including any intermediary certificates.
CertificateBody pulumi.StringPtrInput
// Timestamp (GMT) when the certificate was created.
CreatedAt pulumi.StringPtrInput
// All the domains (including wildcard domains) that are listed in the certificate's Subject Alternative Names (SAN) list.
Domains pulumi.StringArrayInput
// The hostname for which a certificate was issued.
IssuedTo pulumi.StringPtrInput
// The certificate authority that issued the certificate.
Issuer pulumi.StringPtrInput
// Human-readable name used to identify the certificate. Defaults to the certificate's Common Name or first Subject Alternative Name entry.
Name pulumi.StringPtrInput
// A recommendation from Fastly indicating the key associated with this certificate is in need of rotation.
Replace pulumi.BoolPtrInput
// A value assigned by the issuer that is unique to a certificate.
SerialNumber pulumi.StringPtrInput
// The algorithm used to sign the certificate.
SignatureAlgorithm pulumi.StringPtrInput
// Timestamp (GMT) when the certificate was last updated.
UpdatedAt pulumi.StringPtrInput
}
func (TlsCertificateState) ElementType() reflect.Type {
return reflect.TypeOf((*tlsCertificateState)(nil)).Elem()
}
type tlsCertificateArgs struct {
// PEM-formatted certificate, optionally including any intermediary certificates.
CertificateBody string `pulumi:"certificateBody"`
// Human-readable name used to identify the certificate. Defaults to the certificate's Common Name or first Subject Alternative Name entry.
Name *string `pulumi:"name"`
}
// The set of arguments for constructing a TlsCertificate resource.
type TlsCertificateArgs struct {
// PEM-formatted certificate, optionally including any intermediary certificates.
CertificateBody pulumi.StringInput
// Human-readable name used to identify the certificate. Defaults to the certificate's Common Name or first Subject Alternative Name entry.
Name pulumi.StringPtrInput
}
func (TlsCertificateArgs) ElementType() reflect.Type {
return reflect.TypeOf((*tlsCertificateArgs)(nil)).Elem()
}
type TlsCertificateInput interface {
pulumi.Input
ToTlsCertificateOutput() TlsCertificateOutput
ToTlsCertificateOutputWithContext(ctx context.Context) TlsCertificateOutput
}
func (*TlsCertificate) ElementType() reflect.Type {
return reflect.TypeOf((**TlsCertificate)(nil)).Elem()
}
func (i *TlsCertificate) ToTlsCertificateOutput() TlsCertificateOutput {
return i.ToTlsCertificateOutputWithContext(context.Background())
}
func (i *TlsCertificate) ToTlsCertificateOutputWithContext(ctx context.Context) TlsCertificateOutput {
return pulumi.ToOutputWithContext(ctx, i).(TlsCertificateOutput)
}
// TlsCertificateArrayInput is an input type that accepts TlsCertificateArray and TlsCertificateArrayOutput values.
// You can construct a concrete instance of `TlsCertificateArrayInput` via:
//
// TlsCertificateArray{ TlsCertificateArgs{...} }
type TlsCertificateArrayInput interface {
pulumi.Input
ToTlsCertificateArrayOutput() TlsCertificateArrayOutput
ToTlsCertificateArrayOutputWithContext(context.Context) TlsCertificateArrayOutput
}
type TlsCertificateArray []TlsCertificateInput
func (TlsCertificateArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*TlsCertificate)(nil)).Elem()
}
func (i TlsCertificateArray) ToTlsCertificateArrayOutput() TlsCertificateArrayOutput {
return i.ToTlsCertificateArrayOutputWithContext(context.Background())
}
func (i TlsCertificateArray) ToTlsCertificateArrayOutputWithContext(ctx context.Context) TlsCertificateArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(TlsCertificateArrayOutput)
}
// TlsCertificateMapInput is an input type that accepts TlsCertificateMap and TlsCertificateMapOutput values.
// You can construct a concrete instance of `TlsCertificateMapInput` via:
//
// TlsCertificateMap{ "key": TlsCertificateArgs{...} }
type TlsCertificateMapInput interface {
pulumi.Input
ToTlsCertificateMapOutput() TlsCertificateMapOutput
ToTlsCertificateMapOutputWithContext(context.Context) TlsCertificateMapOutput
}
type TlsCertificateMap map[string]TlsCertificateInput
func (TlsCertificateMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*TlsCertificate)(nil)).Elem()
}
func (i TlsCertificateMap) ToTlsCertificateMapOutput() TlsCertificateMapOutput {
return i.ToTlsCertificateMapOutputWithContext(context.Background())
}
func (i TlsCertificateMap) ToTlsCertificateMapOutputWithContext(ctx context.Context) TlsCertificateMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(TlsCertificateMapOutput)
}
type TlsCertificateOutput struct{ *pulumi.OutputState }
func (TlsCertificateOutput) ElementType() reflect.Type {
return reflect.TypeOf((**TlsCertificate)(nil)).Elem()
}
func (o TlsCertificateOutput) ToTlsCertificateOutput() TlsCertificateOutput {
return o
}
func (o TlsCertificateOutput) ToTlsCertificateOutputWithContext(ctx context.Context) TlsCertificateOutput {
return o
}
type TlsCertificateArrayOutput struct{ *pulumi.OutputState }
func (TlsCertificateArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*TlsCertificate)(nil)).Elem()
}
func (o TlsCertificateArrayOutput) ToTlsCertificateArrayOutput() TlsCertificateArrayOutput {
return o
}
func (o TlsCertificateArrayOutput) ToTlsCertificateArrayOutputWithContext(ctx context.Context) TlsCertificateArrayOutput {
return o
}
func (o TlsCertificateArrayOutput) Index(i pulumi.IntInput) TlsCertificateOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *TlsCertificate {
return vs[0].([]*TlsCertificate)[vs[1].(int)]
}).(TlsCertificateOutput)
}
type TlsCertificateMapOutput struct{ *pulumi.OutputState }
func (TlsCertificateMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*TlsCertificate)(nil)).Elem()
}
func (o TlsCertificateMapOutput) ToTlsCertificateMapOutput() TlsCertificateMapOutput {
return o
}
func (o TlsCertificateMapOutput) ToTlsCertificateMapOutputWithContext(ctx context.Context) TlsCertificateMapOutput {
return o
}
func (o TlsCertificateMapOutput) MapIndex(k pulumi.StringInput) TlsCertificateOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *TlsCertificate {
return vs[0].(map[string]*TlsCertificate)[vs[1].(string)]
}).(TlsCertificateOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*TlsCertificateInput)(nil)).Elem(), &TlsCertificate{})
pulumi.RegisterInputType(reflect.TypeOf((*TlsCertificateArrayInput)(nil)).Elem(), TlsCertificateArray{})
pulumi.RegisterInputType(reflect.TypeOf((*TlsCertificateMapInput)(nil)).Elem(), TlsCertificateMap{})
pulumi.RegisterOutputType(TlsCertificateOutput{})
pulumi.RegisterOutputType(TlsCertificateArrayOutput{})
pulumi.RegisterOutputType(TlsCertificateMapOutput{})
}