generated from pulumi/pulumi-tf-provider-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serviceAccount.go
388 lines (332 loc) · 14.7 KB
/
serviceAccount.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
// 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 prefect
import (
"context"
"reflect"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/ru5j4r0/pulumi-prefect/sdk/go/prefect/internal"
)
// The resource `serviceAccount` represents a Prefect Cloud Service Account. A Service Account allows you to create an API Key that is not associated with a user account.
//
// Service Accounts are used to configure API access for workers or programs. Use this resource to provision and rotate Keys as well as assign Account and Workspace Access through Roles.
//
// API Keys for `serviceAccount` resources can be rotated by modifying the `apiKeyExpiration` attribute.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/pulumiverse/pulumi-time/sdk/go/time"
// "github.com/ru5j4r0/pulumi-prefect/sdk/go/prefect"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// // NON-EXPIRING API KEY
// _, err := prefect.NewServiceAccount(ctx, "exampleServiceAccount", nil)
// if err != nil {
// return err
// }
// ninetyDays, err := time.NewRotating(ctx, "ninetyDays", &time.RotatingArgs{
// RotationDays: pulumi.Int(90),
// })
// if err != nil {
// return err
// }
// // Pass the time_rotating resource to the `api_key_expiration` attribute
// // in order to automate the rotation of the Service Account key
// _, err = prefect.NewServiceAccount(ctx, "exampleIndex/serviceAccountServiceAccount", &prefect.ServiceAccountArgs{
// ApiKeyExpiration: ninetyDays.RotationRfc3339,
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Prefect Service Accounts can be imported via name in the form `name/my-bot-name`
//
// ```sh
// $ pulumi import prefect:index/serviceAccount:ServiceAccount example name/my-bot-name
// ```
//
// # Prefect Service Accounts can also be imported via UUID
//
// ```sh
// $ pulumi import prefect:index/serviceAccount:ServiceAccount example 00000000-0000-0000-0000-000000000000
// ```
type ServiceAccount struct {
pulumi.CustomResourceState
// Account ID (UUID), defaults to the account set in the provider
AccountId pulumi.StringOutput `pulumi:"accountId"`
// Account Role name of the service account
AccountRoleName pulumi.StringOutput `pulumi:"accountRoleName"`
// API Key associated with the service account
ApiKey pulumi.StringOutput `pulumi:"apiKey"`
// Timestamp of the API Key creation (RFC3339)
ApiKeyCreated pulumi.StringOutput `pulumi:"apiKeyCreated"`
// Timestamp of the API Key expiration (RFC3339). If left as null, the API Key will not expire. Modify this attribute to force a key rotation.
ApiKeyExpiration pulumi.StringPtrOutput `pulumi:"apiKeyExpiration"`
// API Key ID associated with the service account
ApiKeyId pulumi.StringOutput `pulumi:"apiKeyId"`
// API Key Name associated with the service account
ApiKeyName pulumi.StringOutput `pulumi:"apiKeyName"`
// Timestamp of when the resource was created (RFC3339)
Created pulumi.StringOutput `pulumi:"created"`
// Name of the service account
Name pulumi.StringOutput `pulumi:"name"`
// Timestamp of when the resource was updated (RFC3339)
Updated pulumi.StringOutput `pulumi:"updated"`
}
// NewServiceAccount registers a new resource with the given unique name, arguments, and options.
func NewServiceAccount(ctx *pulumi.Context,
name string, args *ServiceAccountArgs, opts ...pulumi.ResourceOption) (*ServiceAccount, error) {
if args == nil {
args = &ServiceAccountArgs{}
}
secrets := pulumi.AdditionalSecretOutputs([]string{
"apiKey",
})
opts = append(opts, secrets)
opts = internal.PkgResourceDefaultOpts(opts)
var resource ServiceAccount
err := ctx.RegisterResource("prefect:index/serviceAccount:ServiceAccount", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetServiceAccount gets an existing ServiceAccount 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 GetServiceAccount(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ServiceAccountState, opts ...pulumi.ResourceOption) (*ServiceAccount, error) {
var resource ServiceAccount
err := ctx.ReadResource("prefect:index/serviceAccount:ServiceAccount", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ServiceAccount resources.
type serviceAccountState struct {
// Account ID (UUID), defaults to the account set in the provider
AccountId *string `pulumi:"accountId"`
// Account Role name of the service account
AccountRoleName *string `pulumi:"accountRoleName"`
// API Key associated with the service account
ApiKey *string `pulumi:"apiKey"`
// Timestamp of the API Key creation (RFC3339)
ApiKeyCreated *string `pulumi:"apiKeyCreated"`
// Timestamp of the API Key expiration (RFC3339). If left as null, the API Key will not expire. Modify this attribute to force a key rotation.
ApiKeyExpiration *string `pulumi:"apiKeyExpiration"`
// API Key ID associated with the service account
ApiKeyId *string `pulumi:"apiKeyId"`
// API Key Name associated with the service account
ApiKeyName *string `pulumi:"apiKeyName"`
// Timestamp of when the resource was created (RFC3339)
Created *string `pulumi:"created"`
// Name of the service account
Name *string `pulumi:"name"`
// Timestamp of when the resource was updated (RFC3339)
Updated *string `pulumi:"updated"`
}
type ServiceAccountState struct {
// Account ID (UUID), defaults to the account set in the provider
AccountId pulumi.StringPtrInput
// Account Role name of the service account
AccountRoleName pulumi.StringPtrInput
// API Key associated with the service account
ApiKey pulumi.StringPtrInput
// Timestamp of the API Key creation (RFC3339)
ApiKeyCreated pulumi.StringPtrInput
// Timestamp of the API Key expiration (RFC3339). If left as null, the API Key will not expire. Modify this attribute to force a key rotation.
ApiKeyExpiration pulumi.StringPtrInput
// API Key ID associated with the service account
ApiKeyId pulumi.StringPtrInput
// API Key Name associated with the service account
ApiKeyName pulumi.StringPtrInput
// Timestamp of when the resource was created (RFC3339)
Created pulumi.StringPtrInput
// Name of the service account
Name pulumi.StringPtrInput
// Timestamp of when the resource was updated (RFC3339)
Updated pulumi.StringPtrInput
}
func (ServiceAccountState) ElementType() reflect.Type {
return reflect.TypeOf((*serviceAccountState)(nil)).Elem()
}
type serviceAccountArgs struct {
// Account ID (UUID), defaults to the account set in the provider
AccountId *string `pulumi:"accountId"`
// Account Role name of the service account
AccountRoleName *string `pulumi:"accountRoleName"`
// Timestamp of the API Key expiration (RFC3339). If left as null, the API Key will not expire. Modify this attribute to force a key rotation.
ApiKeyExpiration *string `pulumi:"apiKeyExpiration"`
// Name of the service account
Name *string `pulumi:"name"`
}
// The set of arguments for constructing a ServiceAccount resource.
type ServiceAccountArgs struct {
// Account ID (UUID), defaults to the account set in the provider
AccountId pulumi.StringPtrInput
// Account Role name of the service account
AccountRoleName pulumi.StringPtrInput
// Timestamp of the API Key expiration (RFC3339). If left as null, the API Key will not expire. Modify this attribute to force a key rotation.
ApiKeyExpiration pulumi.StringPtrInput
// Name of the service account
Name pulumi.StringPtrInput
}
func (ServiceAccountArgs) ElementType() reflect.Type {
return reflect.TypeOf((*serviceAccountArgs)(nil)).Elem()
}
type ServiceAccountInput interface {
pulumi.Input
ToServiceAccountOutput() ServiceAccountOutput
ToServiceAccountOutputWithContext(ctx context.Context) ServiceAccountOutput
}
func (*ServiceAccount) ElementType() reflect.Type {
return reflect.TypeOf((**ServiceAccount)(nil)).Elem()
}
func (i *ServiceAccount) ToServiceAccountOutput() ServiceAccountOutput {
return i.ToServiceAccountOutputWithContext(context.Background())
}
func (i *ServiceAccount) ToServiceAccountOutputWithContext(ctx context.Context) ServiceAccountOutput {
return pulumi.ToOutputWithContext(ctx, i).(ServiceAccountOutput)
}
// ServiceAccountArrayInput is an input type that accepts ServiceAccountArray and ServiceAccountArrayOutput values.
// You can construct a concrete instance of `ServiceAccountArrayInput` via:
//
// ServiceAccountArray{ ServiceAccountArgs{...} }
type ServiceAccountArrayInput interface {
pulumi.Input
ToServiceAccountArrayOutput() ServiceAccountArrayOutput
ToServiceAccountArrayOutputWithContext(context.Context) ServiceAccountArrayOutput
}
type ServiceAccountArray []ServiceAccountInput
func (ServiceAccountArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ServiceAccount)(nil)).Elem()
}
func (i ServiceAccountArray) ToServiceAccountArrayOutput() ServiceAccountArrayOutput {
return i.ToServiceAccountArrayOutputWithContext(context.Background())
}
func (i ServiceAccountArray) ToServiceAccountArrayOutputWithContext(ctx context.Context) ServiceAccountArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ServiceAccountArrayOutput)
}
// ServiceAccountMapInput is an input type that accepts ServiceAccountMap and ServiceAccountMapOutput values.
// You can construct a concrete instance of `ServiceAccountMapInput` via:
//
// ServiceAccountMap{ "key": ServiceAccountArgs{...} }
type ServiceAccountMapInput interface {
pulumi.Input
ToServiceAccountMapOutput() ServiceAccountMapOutput
ToServiceAccountMapOutputWithContext(context.Context) ServiceAccountMapOutput
}
type ServiceAccountMap map[string]ServiceAccountInput
func (ServiceAccountMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ServiceAccount)(nil)).Elem()
}
func (i ServiceAccountMap) ToServiceAccountMapOutput() ServiceAccountMapOutput {
return i.ToServiceAccountMapOutputWithContext(context.Background())
}
func (i ServiceAccountMap) ToServiceAccountMapOutputWithContext(ctx context.Context) ServiceAccountMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ServiceAccountMapOutput)
}
type ServiceAccountOutput struct{ *pulumi.OutputState }
func (ServiceAccountOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ServiceAccount)(nil)).Elem()
}
func (o ServiceAccountOutput) ToServiceAccountOutput() ServiceAccountOutput {
return o
}
func (o ServiceAccountOutput) ToServiceAccountOutputWithContext(ctx context.Context) ServiceAccountOutput {
return o
}
// Account ID (UUID), defaults to the account set in the provider
func (o ServiceAccountOutput) AccountId() pulumi.StringOutput {
return o.ApplyT(func(v *ServiceAccount) pulumi.StringOutput { return v.AccountId }).(pulumi.StringOutput)
}
// Account Role name of the service account
func (o ServiceAccountOutput) AccountRoleName() pulumi.StringOutput {
return o.ApplyT(func(v *ServiceAccount) pulumi.StringOutput { return v.AccountRoleName }).(pulumi.StringOutput)
}
// API Key associated with the service account
func (o ServiceAccountOutput) ApiKey() pulumi.StringOutput {
return o.ApplyT(func(v *ServiceAccount) pulumi.StringOutput { return v.ApiKey }).(pulumi.StringOutput)
}
// Timestamp of the API Key creation (RFC3339)
func (o ServiceAccountOutput) ApiKeyCreated() pulumi.StringOutput {
return o.ApplyT(func(v *ServiceAccount) pulumi.StringOutput { return v.ApiKeyCreated }).(pulumi.StringOutput)
}
// Timestamp of the API Key expiration (RFC3339). If left as null, the API Key will not expire. Modify this attribute to force a key rotation.
func (o ServiceAccountOutput) ApiKeyExpiration() pulumi.StringPtrOutput {
return o.ApplyT(func(v *ServiceAccount) pulumi.StringPtrOutput { return v.ApiKeyExpiration }).(pulumi.StringPtrOutput)
}
// API Key ID associated with the service account
func (o ServiceAccountOutput) ApiKeyId() pulumi.StringOutput {
return o.ApplyT(func(v *ServiceAccount) pulumi.StringOutput { return v.ApiKeyId }).(pulumi.StringOutput)
}
// API Key Name associated with the service account
func (o ServiceAccountOutput) ApiKeyName() pulumi.StringOutput {
return o.ApplyT(func(v *ServiceAccount) pulumi.StringOutput { return v.ApiKeyName }).(pulumi.StringOutput)
}
// Timestamp of when the resource was created (RFC3339)
func (o ServiceAccountOutput) Created() pulumi.StringOutput {
return o.ApplyT(func(v *ServiceAccount) pulumi.StringOutput { return v.Created }).(pulumi.StringOutput)
}
// Name of the service account
func (o ServiceAccountOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *ServiceAccount) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Timestamp of when the resource was updated (RFC3339)
func (o ServiceAccountOutput) Updated() pulumi.StringOutput {
return o.ApplyT(func(v *ServiceAccount) pulumi.StringOutput { return v.Updated }).(pulumi.StringOutput)
}
type ServiceAccountArrayOutput struct{ *pulumi.OutputState }
func (ServiceAccountArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*ServiceAccount)(nil)).Elem()
}
func (o ServiceAccountArrayOutput) ToServiceAccountArrayOutput() ServiceAccountArrayOutput {
return o
}
func (o ServiceAccountArrayOutput) ToServiceAccountArrayOutputWithContext(ctx context.Context) ServiceAccountArrayOutput {
return o
}
func (o ServiceAccountArrayOutput) Index(i pulumi.IntInput) ServiceAccountOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ServiceAccount {
return vs[0].([]*ServiceAccount)[vs[1].(int)]
}).(ServiceAccountOutput)
}
type ServiceAccountMapOutput struct{ *pulumi.OutputState }
func (ServiceAccountMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*ServiceAccount)(nil)).Elem()
}
func (o ServiceAccountMapOutput) ToServiceAccountMapOutput() ServiceAccountMapOutput {
return o
}
func (o ServiceAccountMapOutput) ToServiceAccountMapOutputWithContext(ctx context.Context) ServiceAccountMapOutput {
return o
}
func (o ServiceAccountMapOutput) MapIndex(k pulumi.StringInput) ServiceAccountOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ServiceAccount {
return vs[0].(map[string]*ServiceAccount)[vs[1].(string)]
}).(ServiceAccountOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*ServiceAccountInput)(nil)).Elem(), &ServiceAccount{})
pulumi.RegisterInputType(reflect.TypeOf((*ServiceAccountArrayInput)(nil)).Elem(), ServiceAccountArray{})
pulumi.RegisterInputType(reflect.TypeOf((*ServiceAccountMapInput)(nil)).Elem(), ServiceAccountMap{})
pulumi.RegisterOutputType(ServiceAccountOutput{})
pulumi.RegisterOutputType(ServiceAccountArrayOutput{})
pulumi.RegisterOutputType(ServiceAccountMapOutput{})
}