/
applicationCertificate.go
441 lines (381 loc) · 21.6 KB
/
applicationCertificate.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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package azuread
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Manages a certificate associated with an Application within Azure Active Directory. These are also referred to as client certificates during authentication.
//
// > **NOTE:** If you're authenticating using a Service Principal then it must have permissions to both `Read and write all applications` and `Sign in and read user profile` within the `Windows Azure Active Directory` API.
//
// ## Example Usage
// ### Using a certificate from Azure Key Vault
//
// ```go
// package main
//
// import (
// "fmt"
//
// "github.com/pulumi/pulumi-azure/sdk/v4/go/azure/keyvault"
// "github.com/pulumi/pulumi-azuread/sdk/v4/go/azuread"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleApplication, err := azuread.NewApplication(ctx, "exampleApplication", nil)
// if err != nil {
// return err
// }
// exampleCertificate, err := keyvault.NewCertificate(ctx, "exampleCertificate", &keyvault.CertificateArgs{
// KeyVaultId: pulumi.Any(azurerm_key_vault.Example.Id),
// CertificatePolicy: &keyvault.CertificateCertificatePolicyArgs{
// IssuerParameters: &keyvault.CertificateCertificatePolicyIssuerParametersArgs{
// Name: pulumi.String("Self"),
// },
// KeyProperties: &keyvault.CertificateCertificatePolicyKeyPropertiesArgs{
// Exportable: pulumi.Bool(true),
// KeySize: pulumi.Int(2048),
// KeyType: pulumi.String("RSA"),
// ReuseKey: pulumi.Bool(true),
// },
// LifetimeActions: keyvault.CertificateCertificatePolicyLifetimeActionArray{
// &keyvault.CertificateCertificatePolicyLifetimeActionArgs{
// Action: &keyvault.CertificateCertificatePolicyLifetimeActionActionArgs{
// ActionType: pulumi.String("AutoRenew"),
// },
// Trigger: &keyvault.CertificateCertificatePolicyLifetimeActionTriggerArgs{
// DaysBeforeExpiry: pulumi.Int(30),
// },
// },
// },
// SecretProperties: &keyvault.CertificateCertificatePolicySecretPropertiesArgs{
// ContentType: pulumi.String("application/x-pkcs12"),
// },
// X509CertificateProperties: &keyvault.CertificateCertificatePolicyX509CertificatePropertiesArgs{
// ExtendedKeyUsages: pulumi.StringArray{
// pulumi.String("1.3.6.1.5.5.7.3.2"),
// },
// KeyUsages: pulumi.StringArray{
// pulumi.String("dataEncipherment"),
// pulumi.String("digitalSignature"),
// pulumi.String("keyCertSign"),
// pulumi.String("keyEncipherment"),
// },
// SubjectAlternativeNames: &keyvault.CertificateCertificatePolicyX509CertificatePropertiesSubjectAlternativeNamesArgs{
// DnsNames: pulumi.StringArray{
// pulumi.String("internal.contoso.com"),
// pulumi.String("domain.hello.world"),
// },
// },
// Subject: exampleApplication.Name.ApplyT(func(name string) (string, error) {
// return fmt.Sprintf("%v%v", "CN=", name), nil
// }).(pulumi.StringOutput),
// ValidityInMonths: pulumi.Int(12),
// },
// },
// })
// if err != nil {
// return err
// }
// _, err = azuread.NewApplicationCertificate(ctx, "exampleApplicationCertificate", &azuread.ApplicationCertificateArgs{
// ApplicationObjectId: exampleApplication.ID(),
// Type: pulumi.String("AsymmetricX509Cert"),
// Encoding: pulumi.String("hex"),
// Value: exampleCertificate.CertificateData,
// EndDate: exampleCertificate.CertificateAttributes.ApplyT(func(certificateAttributes []keyvault.CertificateCertificateAttribute) (string, error) {
// return certificateAttributes[0].Expires, nil
// }).(pulumi.StringOutput),
// StartDate: exampleCertificate.CertificateAttributes.ApplyT(func(certificateAttributes []keyvault.CertificateCertificateAttribute) (string, error) {
// return certificateAttributes[0].NotBefore, nil
// }).(pulumi.StringOutput),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Certificates can be imported using the `object id` of an Application and the `key id` of the certificate, e.g.
//
// ```sh
// $ pulumi import azuread:index/applicationCertificate:ApplicationCertificate test 00000000-0000-0000-0000-000000000000/certificate/11111111-1111-1111-1111-111111111111
// ```
type ApplicationCertificate struct {
pulumi.CustomResourceState
// The Object ID of the Application for which this Certificate should be created. Changing this field forces a new resource to be created.
ApplicationObjectId pulumi.StringOutput `pulumi:"applicationObjectId"`
// Specifies the encoding used for the supplied certificate data. Must be one of `pem`, `base64` or `hex`. Defaults to `pem`.
Encoding pulumi.StringPtrOutput `pulumi:"encoding"`
// The End Date which the Certificate is valid until, formatted as a RFC3339 date string (e.g. `2018-01-01T01:02:03Z`). Changing this field forces a new resource to be created.
EndDate pulumi.StringOutput `pulumi:"endDate"`
// A relative duration for which the Certificate is valid until, for example `240h` (10 days) or `2400h30m`. Changing this field forces a new resource to be created.
EndDateRelative pulumi.StringPtrOutput `pulumi:"endDateRelative"`
// A GUID used to uniquely identify this Certificate. If not specified a GUID will be created. Changing this field forces a new resource to be created.
KeyId pulumi.StringOutput `pulumi:"keyId"`
// The Start Date which the Certificate is valid from, formatted as a RFC3339 date string (e.g. `2018-01-01T01:02:03Z`). If this isn't specified, the current date is used. Changing this field forces a new resource to be created.
StartDate pulumi.StringOutput `pulumi:"startDate"`
// The type of key/certificate. Must be one of `AsymmetricX509Cert` or `Symmetric`. Changing this fields forces a new resource to be created.
Type pulumi.StringPtrOutput `pulumi:"type"`
// The certificate data, which can be PEM encoded, base64 encoded DER or hexadecimal encoded DER. See also the `encoding` argument.
Value pulumi.StringOutput `pulumi:"value"`
}
// NewApplicationCertificate registers a new resource with the given unique name, arguments, and options.
func NewApplicationCertificate(ctx *pulumi.Context,
name string, args *ApplicationCertificateArgs, opts ...pulumi.ResourceOption) (*ApplicationCertificate, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.ApplicationObjectId == nil {
return nil, errors.New("invalid value for required argument 'ApplicationObjectId'")
}
if args.Value == nil {
return nil, errors.New("invalid value for required argument 'Value'")
}
var resource ApplicationCertificate
err := ctx.RegisterResource("azuread:index/applicationCertificate:ApplicationCertificate", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetApplicationCertificate gets an existing ApplicationCertificate 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 GetApplicationCertificate(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ApplicationCertificateState, opts ...pulumi.ResourceOption) (*ApplicationCertificate, error) {
var resource ApplicationCertificate
err := ctx.ReadResource("azuread:index/applicationCertificate:ApplicationCertificate", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ApplicationCertificate resources.
type applicationCertificateState struct {
// The Object ID of the Application for which this Certificate should be created. Changing this field forces a new resource to be created.
ApplicationObjectId *string `pulumi:"applicationObjectId"`
// Specifies the encoding used for the supplied certificate data. Must be one of `pem`, `base64` or `hex`. Defaults to `pem`.
Encoding *string `pulumi:"encoding"`
// The End Date which the Certificate is valid until, formatted as a RFC3339 date string (e.g. `2018-01-01T01:02:03Z`). Changing this field forces a new resource to be created.
EndDate *string `pulumi:"endDate"`
// A relative duration for which the Certificate is valid until, for example `240h` (10 days) or `2400h30m`. Changing this field forces a new resource to be created.
EndDateRelative *string `pulumi:"endDateRelative"`
// A GUID used to uniquely identify this Certificate. If not specified a GUID will be created. Changing this field forces a new resource to be created.
KeyId *string `pulumi:"keyId"`
// The Start Date which the Certificate is valid from, formatted as a RFC3339 date string (e.g. `2018-01-01T01:02:03Z`). If this isn't specified, the current date is used. Changing this field forces a new resource to be created.
StartDate *string `pulumi:"startDate"`
// The type of key/certificate. Must be one of `AsymmetricX509Cert` or `Symmetric`. Changing this fields forces a new resource to be created.
Type *string `pulumi:"type"`
// The certificate data, which can be PEM encoded, base64 encoded DER or hexadecimal encoded DER. See also the `encoding` argument.
Value *string `pulumi:"value"`
}
type ApplicationCertificateState struct {
// The Object ID of the Application for which this Certificate should be created. Changing this field forces a new resource to be created.
ApplicationObjectId pulumi.StringPtrInput
// Specifies the encoding used for the supplied certificate data. Must be one of `pem`, `base64` or `hex`. Defaults to `pem`.
Encoding pulumi.StringPtrInput
// The End Date which the Certificate is valid until, formatted as a RFC3339 date string (e.g. `2018-01-01T01:02:03Z`). Changing this field forces a new resource to be created.
EndDate pulumi.StringPtrInput
// A relative duration for which the Certificate is valid until, for example `240h` (10 days) or `2400h30m`. Changing this field forces a new resource to be created.
EndDateRelative pulumi.StringPtrInput
// A GUID used to uniquely identify this Certificate. If not specified a GUID will be created. Changing this field forces a new resource to be created.
KeyId pulumi.StringPtrInput
// The Start Date which the Certificate is valid from, formatted as a RFC3339 date string (e.g. `2018-01-01T01:02:03Z`). If this isn't specified, the current date is used. Changing this field forces a new resource to be created.
StartDate pulumi.StringPtrInput
// The type of key/certificate. Must be one of `AsymmetricX509Cert` or `Symmetric`. Changing this fields forces a new resource to be created.
Type pulumi.StringPtrInput
// The certificate data, which can be PEM encoded, base64 encoded DER or hexadecimal encoded DER. See also the `encoding` argument.
Value pulumi.StringPtrInput
}
func (ApplicationCertificateState) ElementType() reflect.Type {
return reflect.TypeOf((*applicationCertificateState)(nil)).Elem()
}
type applicationCertificateArgs struct {
// The Object ID of the Application for which this Certificate should be created. Changing this field forces a new resource to be created.
ApplicationObjectId string `pulumi:"applicationObjectId"`
// Specifies the encoding used for the supplied certificate data. Must be one of `pem`, `base64` or `hex`. Defaults to `pem`.
Encoding *string `pulumi:"encoding"`
// The End Date which the Certificate is valid until, formatted as a RFC3339 date string (e.g. `2018-01-01T01:02:03Z`). Changing this field forces a new resource to be created.
EndDate *string `pulumi:"endDate"`
// A relative duration for which the Certificate is valid until, for example `240h` (10 days) or `2400h30m`. Changing this field forces a new resource to be created.
EndDateRelative *string `pulumi:"endDateRelative"`
// A GUID used to uniquely identify this Certificate. If not specified a GUID will be created. Changing this field forces a new resource to be created.
KeyId *string `pulumi:"keyId"`
// The Start Date which the Certificate is valid from, formatted as a RFC3339 date string (e.g. `2018-01-01T01:02:03Z`). If this isn't specified, the current date is used. Changing this field forces a new resource to be created.
StartDate *string `pulumi:"startDate"`
// The type of key/certificate. Must be one of `AsymmetricX509Cert` or `Symmetric`. Changing this fields forces a new resource to be created.
Type *string `pulumi:"type"`
// The certificate data, which can be PEM encoded, base64 encoded DER or hexadecimal encoded DER. See also the `encoding` argument.
Value string `pulumi:"value"`
}
// The set of arguments for constructing a ApplicationCertificate resource.
type ApplicationCertificateArgs struct {
// The Object ID of the Application for which this Certificate should be created. Changing this field forces a new resource to be created.
ApplicationObjectId pulumi.StringInput
// Specifies the encoding used for the supplied certificate data. Must be one of `pem`, `base64` or `hex`. Defaults to `pem`.
Encoding pulumi.StringPtrInput
// The End Date which the Certificate is valid until, formatted as a RFC3339 date string (e.g. `2018-01-01T01:02:03Z`). Changing this field forces a new resource to be created.
EndDate pulumi.StringPtrInput
// A relative duration for which the Certificate is valid until, for example `240h` (10 days) or `2400h30m`. Changing this field forces a new resource to be created.
EndDateRelative pulumi.StringPtrInput
// A GUID used to uniquely identify this Certificate. If not specified a GUID will be created. Changing this field forces a new resource to be created.
KeyId pulumi.StringPtrInput
// The Start Date which the Certificate is valid from, formatted as a RFC3339 date string (e.g. `2018-01-01T01:02:03Z`). If this isn't specified, the current date is used. Changing this field forces a new resource to be created.
StartDate pulumi.StringPtrInput
// The type of key/certificate. Must be one of `AsymmetricX509Cert` or `Symmetric`. Changing this fields forces a new resource to be created.
Type pulumi.StringPtrInput
// The certificate data, which can be PEM encoded, base64 encoded DER or hexadecimal encoded DER. See also the `encoding` argument.
Value pulumi.StringInput
}
func (ApplicationCertificateArgs) ElementType() reflect.Type {
return reflect.TypeOf((*applicationCertificateArgs)(nil)).Elem()
}
type ApplicationCertificateInput interface {
pulumi.Input
ToApplicationCertificateOutput() ApplicationCertificateOutput
ToApplicationCertificateOutputWithContext(ctx context.Context) ApplicationCertificateOutput
}
func (*ApplicationCertificate) ElementType() reflect.Type {
return reflect.TypeOf((*ApplicationCertificate)(nil))
}
func (i *ApplicationCertificate) ToApplicationCertificateOutput() ApplicationCertificateOutput {
return i.ToApplicationCertificateOutputWithContext(context.Background())
}
func (i *ApplicationCertificate) ToApplicationCertificateOutputWithContext(ctx context.Context) ApplicationCertificateOutput {
return pulumi.ToOutputWithContext(ctx, i).(ApplicationCertificateOutput)
}
func (i *ApplicationCertificate) ToApplicationCertificatePtrOutput() ApplicationCertificatePtrOutput {
return i.ToApplicationCertificatePtrOutputWithContext(context.Background())
}
func (i *ApplicationCertificate) ToApplicationCertificatePtrOutputWithContext(ctx context.Context) ApplicationCertificatePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ApplicationCertificatePtrOutput)
}
type ApplicationCertificatePtrInput interface {
pulumi.Input
ToApplicationCertificatePtrOutput() ApplicationCertificatePtrOutput
ToApplicationCertificatePtrOutputWithContext(ctx context.Context) ApplicationCertificatePtrOutput
}
type applicationCertificatePtrType ApplicationCertificateArgs
func (*applicationCertificatePtrType) ElementType() reflect.Type {
return reflect.TypeOf((**ApplicationCertificate)(nil))
}
func (i *applicationCertificatePtrType) ToApplicationCertificatePtrOutput() ApplicationCertificatePtrOutput {
return i.ToApplicationCertificatePtrOutputWithContext(context.Background())
}
func (i *applicationCertificatePtrType) ToApplicationCertificatePtrOutputWithContext(ctx context.Context) ApplicationCertificatePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ApplicationCertificatePtrOutput)
}
// ApplicationCertificateArrayInput is an input type that accepts ApplicationCertificateArray and ApplicationCertificateArrayOutput values.
// You can construct a concrete instance of `ApplicationCertificateArrayInput` via:
//
// ApplicationCertificateArray{ ApplicationCertificateArgs{...} }
type ApplicationCertificateArrayInput interface {
pulumi.Input
ToApplicationCertificateArrayOutput() ApplicationCertificateArrayOutput
ToApplicationCertificateArrayOutputWithContext(context.Context) ApplicationCertificateArrayOutput
}
type ApplicationCertificateArray []ApplicationCertificateInput
func (ApplicationCertificateArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*ApplicationCertificate)(nil))
}
func (i ApplicationCertificateArray) ToApplicationCertificateArrayOutput() ApplicationCertificateArrayOutput {
return i.ToApplicationCertificateArrayOutputWithContext(context.Background())
}
func (i ApplicationCertificateArray) ToApplicationCertificateArrayOutputWithContext(ctx context.Context) ApplicationCertificateArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ApplicationCertificateArrayOutput)
}
// ApplicationCertificateMapInput is an input type that accepts ApplicationCertificateMap and ApplicationCertificateMapOutput values.
// You can construct a concrete instance of `ApplicationCertificateMapInput` via:
//
// ApplicationCertificateMap{ "key": ApplicationCertificateArgs{...} }
type ApplicationCertificateMapInput interface {
pulumi.Input
ToApplicationCertificateMapOutput() ApplicationCertificateMapOutput
ToApplicationCertificateMapOutputWithContext(context.Context) ApplicationCertificateMapOutput
}
type ApplicationCertificateMap map[string]ApplicationCertificateInput
func (ApplicationCertificateMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*ApplicationCertificate)(nil))
}
func (i ApplicationCertificateMap) ToApplicationCertificateMapOutput() ApplicationCertificateMapOutput {
return i.ToApplicationCertificateMapOutputWithContext(context.Background())
}
func (i ApplicationCertificateMap) ToApplicationCertificateMapOutputWithContext(ctx context.Context) ApplicationCertificateMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ApplicationCertificateMapOutput)
}
type ApplicationCertificateOutput struct {
*pulumi.OutputState
}
func (ApplicationCertificateOutput) ElementType() reflect.Type {
return reflect.TypeOf((*ApplicationCertificate)(nil))
}
func (o ApplicationCertificateOutput) ToApplicationCertificateOutput() ApplicationCertificateOutput {
return o
}
func (o ApplicationCertificateOutput) ToApplicationCertificateOutputWithContext(ctx context.Context) ApplicationCertificateOutput {
return o
}
func (o ApplicationCertificateOutput) ToApplicationCertificatePtrOutput() ApplicationCertificatePtrOutput {
return o.ToApplicationCertificatePtrOutputWithContext(context.Background())
}
func (o ApplicationCertificateOutput) ToApplicationCertificatePtrOutputWithContext(ctx context.Context) ApplicationCertificatePtrOutput {
return o.ApplyT(func(v ApplicationCertificate) *ApplicationCertificate {
return &v
}).(ApplicationCertificatePtrOutput)
}
type ApplicationCertificatePtrOutput struct {
*pulumi.OutputState
}
func (ApplicationCertificatePtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ApplicationCertificate)(nil))
}
func (o ApplicationCertificatePtrOutput) ToApplicationCertificatePtrOutput() ApplicationCertificatePtrOutput {
return o
}
func (o ApplicationCertificatePtrOutput) ToApplicationCertificatePtrOutputWithContext(ctx context.Context) ApplicationCertificatePtrOutput {
return o
}
type ApplicationCertificateArrayOutput struct{ *pulumi.OutputState }
func (ApplicationCertificateArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]ApplicationCertificate)(nil))
}
func (o ApplicationCertificateArrayOutput) ToApplicationCertificateArrayOutput() ApplicationCertificateArrayOutput {
return o
}
func (o ApplicationCertificateArrayOutput) ToApplicationCertificateArrayOutputWithContext(ctx context.Context) ApplicationCertificateArrayOutput {
return o
}
func (o ApplicationCertificateArrayOutput) Index(i pulumi.IntInput) ApplicationCertificateOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) ApplicationCertificate {
return vs[0].([]ApplicationCertificate)[vs[1].(int)]
}).(ApplicationCertificateOutput)
}
type ApplicationCertificateMapOutput struct{ *pulumi.OutputState }
func (ApplicationCertificateMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]ApplicationCertificate)(nil))
}
func (o ApplicationCertificateMapOutput) ToApplicationCertificateMapOutput() ApplicationCertificateMapOutput {
return o
}
func (o ApplicationCertificateMapOutput) ToApplicationCertificateMapOutputWithContext(ctx context.Context) ApplicationCertificateMapOutput {
return o
}
func (o ApplicationCertificateMapOutput) MapIndex(k pulumi.StringInput) ApplicationCertificateOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) ApplicationCertificate {
return vs[0].(map[string]ApplicationCertificate)[vs[1].(string)]
}).(ApplicationCertificateOutput)
}
func init() {
pulumi.RegisterOutputType(ApplicationCertificateOutput{})
pulumi.RegisterOutputType(ApplicationCertificatePtrOutput{})
pulumi.RegisterOutputType(ApplicationCertificateArrayOutput{})
pulumi.RegisterOutputType(ApplicationCertificateMapOutput{})
}