/
webApp.go
551 lines (492 loc) · 19.6 KB
/
webApp.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
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
// 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 firebase
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumix"
)
// A Google Cloud Firebase web application instance
//
// To get more information about WebApp, see:
//
// * [API documentation](https://firebase.google.com/docs/reference/firebase-management/rest/v1beta1/projects.webApps)
// * How-to Guides
// - [Official Documentation](https://firebase.google.com/)
//
// ## Example Usage
// ### Firebase Web App Basic
//
// ```go
// package main
//
// import (
//
// "encoding/json"
//
// "github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/firebase"
// "github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/organizations"
// "github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/storage"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// defaultProject, err := organizations.NewProject(ctx, "defaultProject", &organizations.ProjectArgs{
// ProjectId: pulumi.String("my-project"),
// OrgId: pulumi.String("123456789"),
// Labels: pulumi.StringMap{
// "firebase": pulumi.String("enabled"),
// },
// }, pulumi.Provider(google_beta))
// if err != nil {
// return err
// }
// _, err = firebase.NewProject(ctx, "defaultFirebase/projectProject", &firebase.ProjectArgs{
// Project: defaultProject.ProjectId,
// }, pulumi.Provider(google_beta))
// if err != nil {
// return err
// }
// basicWebApp, err := firebase.NewWebApp(ctx, "basicWebApp", &firebase.WebAppArgs{
// Project: defaultProject.ProjectId,
// DisplayName: pulumi.String("Display Name Basic"),
// DeletionPolicy: pulumi.String("DELETE"),
// }, pulumi.Provider(google_beta), pulumi.DependsOn([]pulumi.Resource{
// defaultFirebase / projectProject,
// }))
// if err != nil {
// return err
// }
// basicWebAppConfig := firebase.GetWebAppConfigOutput(ctx, firebase.GetWebAppConfigOutputArgs{
// WebAppId: basicWebApp.AppId,
// }, nil)
// defaultBucket, err := storage.NewBucket(ctx, "defaultBucket", &storage.BucketArgs{
// Location: pulumi.String("US"),
// }, pulumi.Provider(google_beta))
// if err != nil {
// return err
// }
// _, err = storage.NewBucketObject(ctx, "defaultBucketObject", &storage.BucketObjectArgs{
// Bucket: defaultBucket.Name,
// Content: pulumi.All(basicWebApp.AppId, basicWebAppConfig, basicWebAppConfig, "TODO: Lookup", "TODO: Lookup", "TODO: Lookup", "TODO: Lookup").ApplyT(func(_args []interface{}) (string, error) {
// appId := _args[0].(string)
// basicWebAppConfig := _args[1].(firebase.GetWebAppConfigResult)
// basicWebAppConfig1 := _args[2].(firebase.GetWebAppConfigResult)
// s := _args[3].(*string)
// s1 := _args[4].(*string)
// s2 := _args[5].(*string)
// s3 := _args[6].(*string)
// var _zero string
// tmpJSON0, err := json.Marshal(map[string]interface{}{
// "appId": appId,
// "apiKey": basicWebAppConfig.ApiKey,
// "authDomain": basicWebAppConfig1.AuthDomain,
// "databaseURL": s,
// "storageBucket": s1,
// "messagingSenderId": s2,
// "measurementId": s3,
// })
// if err != nil {
// return _zero, err
// }
// json0 := string(tmpJSON0)
// return json0, nil
// }).(pulumi.StringOutput),
// }, pulumi.Provider(google_beta))
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// ### Firebase Web App Custom Api Key
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/firebase"
// "github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/projects"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// web, err := projects.NewApiKey(ctx, "web", &projects.ApiKeyArgs{
// Project: pulumi.String("my-project-name"),
// DisplayName: pulumi.String("Display Name"),
// Restrictions: &projects.ApiKeyRestrictionsArgs{
// BrowserKeyRestrictions: &projects.ApiKeyRestrictionsBrowserKeyRestrictionsArgs{
// AllowedReferrers: pulumi.StringArray{
// pulumi.String("*"),
// },
// },
// },
// }, pulumi.Provider(google_beta))
// if err != nil {
// return err
// }
// _, err = firebase.NewWebApp(ctx, "default", &firebase.WebAppArgs{
// Project: pulumi.String("my-project-name"),
// DisplayName: pulumi.String("Display Name"),
// ApiKeyId: web.Uid,
// DeletionPolicy: pulumi.String("DELETE"),
// }, pulumi.Provider(google_beta))
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// # WebApp can be imported using any of these accepted formats
//
// ```sh
//
// $ pulumi import gcp:firebase/webApp:WebApp default {{project}} projects/{{project}}/webApps/{{app_id}}
//
// ```
//
// ```sh
//
// $ pulumi import gcp:firebase/webApp:WebApp default projects/{{project}}/webApps/{{app_id}}
//
// ```
//
// ```sh
//
// $ pulumi import gcp:firebase/webApp:WebApp default {{project}}/{{project}}/{{app_id}}
//
// ```
//
// ```sh
//
// $ pulumi import gcp:firebase/webApp:WebApp default webApps/{{app_id}}
//
// ```
//
// ```sh
//
// $ pulumi import gcp:firebase/webApp:WebApp default {{app_id}}
//
// ```
type WebApp struct {
pulumi.CustomResourceState
// The globally unique, Google-assigned identifier (UID) for the Firebase API key associated with the WebApp.
// If apiKeyId is not set during creation, then Firebase automatically associates an apiKeyId with the WebApp.
// This auto-associated key may be an existing valid key or, if no valid key exists, a new one will be provisioned.
ApiKeyId pulumi.StringOutput `pulumi:"apiKeyId"`
// The globally unique, Firebase-assigned identifier of the App.
// This identifier should be treated as an opaque token, as the data format is not specified.
AppId pulumi.StringOutput `pulumi:"appId"`
// The URLs where the `WebApp` is hosted.
AppUrls pulumi.StringArrayOutput `pulumi:"appUrls"`
// Set to 'ABANDON' to allow the WebApp to be untracked from terraform state rather than deleted upon 'terraform destroy'.
// This is useful becaue the WebApp may be serving traffic. Set to 'DELETE' to delete the WebApp. Default to 'ABANDON'
DeletionPolicy pulumi.StringPtrOutput `pulumi:"deletionPolicy"`
// The user-assigned display name of the App.
//
// ***
DisplayName pulumi.StringOutput `pulumi:"displayName"`
// The fully qualified resource name of the App, for example:
// projects/projectId/webApps/appId
Name pulumi.StringOutput `pulumi:"name"`
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project pulumi.StringOutput `pulumi:"project"`
}
// NewWebApp registers a new resource with the given unique name, arguments, and options.
func NewWebApp(ctx *pulumi.Context,
name string, args *WebAppArgs, opts ...pulumi.ResourceOption) (*WebApp, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.DisplayName == nil {
return nil, errors.New("invalid value for required argument 'DisplayName'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource WebApp
err := ctx.RegisterResource("gcp:firebase/webApp:WebApp", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetWebApp gets an existing WebApp 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 GetWebApp(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *WebAppState, opts ...pulumi.ResourceOption) (*WebApp, error) {
var resource WebApp
err := ctx.ReadResource("gcp:firebase/webApp:WebApp", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering WebApp resources.
type webAppState struct {
// The globally unique, Google-assigned identifier (UID) for the Firebase API key associated with the WebApp.
// If apiKeyId is not set during creation, then Firebase automatically associates an apiKeyId with the WebApp.
// This auto-associated key may be an existing valid key or, if no valid key exists, a new one will be provisioned.
ApiKeyId *string `pulumi:"apiKeyId"`
// The globally unique, Firebase-assigned identifier of the App.
// This identifier should be treated as an opaque token, as the data format is not specified.
AppId *string `pulumi:"appId"`
// The URLs where the `WebApp` is hosted.
AppUrls []string `pulumi:"appUrls"`
// Set to 'ABANDON' to allow the WebApp to be untracked from terraform state rather than deleted upon 'terraform destroy'.
// This is useful becaue the WebApp may be serving traffic. Set to 'DELETE' to delete the WebApp. Default to 'ABANDON'
DeletionPolicy *string `pulumi:"deletionPolicy"`
// The user-assigned display name of the App.
//
// ***
DisplayName *string `pulumi:"displayName"`
// The fully qualified resource name of the App, for example:
// projects/projectId/webApps/appId
Name *string `pulumi:"name"`
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project *string `pulumi:"project"`
}
type WebAppState struct {
// The globally unique, Google-assigned identifier (UID) for the Firebase API key associated with the WebApp.
// If apiKeyId is not set during creation, then Firebase automatically associates an apiKeyId with the WebApp.
// This auto-associated key may be an existing valid key or, if no valid key exists, a new one will be provisioned.
ApiKeyId pulumi.StringPtrInput
// The globally unique, Firebase-assigned identifier of the App.
// This identifier should be treated as an opaque token, as the data format is not specified.
AppId pulumi.StringPtrInput
// The URLs where the `WebApp` is hosted.
AppUrls pulumi.StringArrayInput
// Set to 'ABANDON' to allow the WebApp to be untracked from terraform state rather than deleted upon 'terraform destroy'.
// This is useful becaue the WebApp may be serving traffic. Set to 'DELETE' to delete the WebApp. Default to 'ABANDON'
DeletionPolicy pulumi.StringPtrInput
// The user-assigned display name of the App.
//
// ***
DisplayName pulumi.StringPtrInput
// The fully qualified resource name of the App, for example:
// projects/projectId/webApps/appId
Name pulumi.StringPtrInput
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project pulumi.StringPtrInput
}
func (WebAppState) ElementType() reflect.Type {
return reflect.TypeOf((*webAppState)(nil)).Elem()
}
type webAppArgs struct {
// The globally unique, Google-assigned identifier (UID) for the Firebase API key associated with the WebApp.
// If apiKeyId is not set during creation, then Firebase automatically associates an apiKeyId with the WebApp.
// This auto-associated key may be an existing valid key or, if no valid key exists, a new one will be provisioned.
ApiKeyId *string `pulumi:"apiKeyId"`
// Set to 'ABANDON' to allow the WebApp to be untracked from terraform state rather than deleted upon 'terraform destroy'.
// This is useful becaue the WebApp may be serving traffic. Set to 'DELETE' to delete the WebApp. Default to 'ABANDON'
DeletionPolicy *string `pulumi:"deletionPolicy"`
// The user-assigned display name of the App.
//
// ***
DisplayName string `pulumi:"displayName"`
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project *string `pulumi:"project"`
}
// The set of arguments for constructing a WebApp resource.
type WebAppArgs struct {
// The globally unique, Google-assigned identifier (UID) for the Firebase API key associated with the WebApp.
// If apiKeyId is not set during creation, then Firebase automatically associates an apiKeyId with the WebApp.
// This auto-associated key may be an existing valid key or, if no valid key exists, a new one will be provisioned.
ApiKeyId pulumi.StringPtrInput
// Set to 'ABANDON' to allow the WebApp to be untracked from terraform state rather than deleted upon 'terraform destroy'.
// This is useful becaue the WebApp may be serving traffic. Set to 'DELETE' to delete the WebApp. Default to 'ABANDON'
DeletionPolicy pulumi.StringPtrInput
// The user-assigned display name of the App.
//
// ***
DisplayName pulumi.StringInput
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
Project pulumi.StringPtrInput
}
func (WebAppArgs) ElementType() reflect.Type {
return reflect.TypeOf((*webAppArgs)(nil)).Elem()
}
type WebAppInput interface {
pulumi.Input
ToWebAppOutput() WebAppOutput
ToWebAppOutputWithContext(ctx context.Context) WebAppOutput
}
func (*WebApp) ElementType() reflect.Type {
return reflect.TypeOf((**WebApp)(nil)).Elem()
}
func (i *WebApp) ToWebAppOutput() WebAppOutput {
return i.ToWebAppOutputWithContext(context.Background())
}
func (i *WebApp) ToWebAppOutputWithContext(ctx context.Context) WebAppOutput {
return pulumi.ToOutputWithContext(ctx, i).(WebAppOutput)
}
func (i *WebApp) ToOutput(ctx context.Context) pulumix.Output[*WebApp] {
return pulumix.Output[*WebApp]{
OutputState: i.ToWebAppOutputWithContext(ctx).OutputState,
}
}
// WebAppArrayInput is an input type that accepts WebAppArray and WebAppArrayOutput values.
// You can construct a concrete instance of `WebAppArrayInput` via:
//
// WebAppArray{ WebAppArgs{...} }
type WebAppArrayInput interface {
pulumi.Input
ToWebAppArrayOutput() WebAppArrayOutput
ToWebAppArrayOutputWithContext(context.Context) WebAppArrayOutput
}
type WebAppArray []WebAppInput
func (WebAppArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*WebApp)(nil)).Elem()
}
func (i WebAppArray) ToWebAppArrayOutput() WebAppArrayOutput {
return i.ToWebAppArrayOutputWithContext(context.Background())
}
func (i WebAppArray) ToWebAppArrayOutputWithContext(ctx context.Context) WebAppArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(WebAppArrayOutput)
}
func (i WebAppArray) ToOutput(ctx context.Context) pulumix.Output[[]*WebApp] {
return pulumix.Output[[]*WebApp]{
OutputState: i.ToWebAppArrayOutputWithContext(ctx).OutputState,
}
}
// WebAppMapInput is an input type that accepts WebAppMap and WebAppMapOutput values.
// You can construct a concrete instance of `WebAppMapInput` via:
//
// WebAppMap{ "key": WebAppArgs{...} }
type WebAppMapInput interface {
pulumi.Input
ToWebAppMapOutput() WebAppMapOutput
ToWebAppMapOutputWithContext(context.Context) WebAppMapOutput
}
type WebAppMap map[string]WebAppInput
func (WebAppMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*WebApp)(nil)).Elem()
}
func (i WebAppMap) ToWebAppMapOutput() WebAppMapOutput {
return i.ToWebAppMapOutputWithContext(context.Background())
}
func (i WebAppMap) ToWebAppMapOutputWithContext(ctx context.Context) WebAppMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(WebAppMapOutput)
}
func (i WebAppMap) ToOutput(ctx context.Context) pulumix.Output[map[string]*WebApp] {
return pulumix.Output[map[string]*WebApp]{
OutputState: i.ToWebAppMapOutputWithContext(ctx).OutputState,
}
}
type WebAppOutput struct{ *pulumi.OutputState }
func (WebAppOutput) ElementType() reflect.Type {
return reflect.TypeOf((**WebApp)(nil)).Elem()
}
func (o WebAppOutput) ToWebAppOutput() WebAppOutput {
return o
}
func (o WebAppOutput) ToWebAppOutputWithContext(ctx context.Context) WebAppOutput {
return o
}
func (o WebAppOutput) ToOutput(ctx context.Context) pulumix.Output[*WebApp] {
return pulumix.Output[*WebApp]{
OutputState: o.OutputState,
}
}
// The globally unique, Google-assigned identifier (UID) for the Firebase API key associated with the WebApp.
// If apiKeyId is not set during creation, then Firebase automatically associates an apiKeyId with the WebApp.
// This auto-associated key may be an existing valid key or, if no valid key exists, a new one will be provisioned.
func (o WebAppOutput) ApiKeyId() pulumi.StringOutput {
return o.ApplyT(func(v *WebApp) pulumi.StringOutput { return v.ApiKeyId }).(pulumi.StringOutput)
}
// The globally unique, Firebase-assigned identifier of the App.
// This identifier should be treated as an opaque token, as the data format is not specified.
func (o WebAppOutput) AppId() pulumi.StringOutput {
return o.ApplyT(func(v *WebApp) pulumi.StringOutput { return v.AppId }).(pulumi.StringOutput)
}
// The URLs where the `WebApp` is hosted.
func (o WebAppOutput) AppUrls() pulumi.StringArrayOutput {
return o.ApplyT(func(v *WebApp) pulumi.StringArrayOutput { return v.AppUrls }).(pulumi.StringArrayOutput)
}
// Set to 'ABANDON' to allow the WebApp to be untracked from terraform state rather than deleted upon 'terraform destroy'.
// This is useful becaue the WebApp may be serving traffic. Set to 'DELETE' to delete the WebApp. Default to 'ABANDON'
func (o WebAppOutput) DeletionPolicy() pulumi.StringPtrOutput {
return o.ApplyT(func(v *WebApp) pulumi.StringPtrOutput { return v.DeletionPolicy }).(pulumi.StringPtrOutput)
}
// The user-assigned display name of the App.
//
// ***
func (o WebAppOutput) DisplayName() pulumi.StringOutput {
return o.ApplyT(func(v *WebApp) pulumi.StringOutput { return v.DisplayName }).(pulumi.StringOutput)
}
// The fully qualified resource name of the App, for example:
// projects/projectId/webApps/appId
func (o WebAppOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *WebApp) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// The ID of the project in which the resource belongs.
// If it is not provided, the provider project is used.
func (o WebAppOutput) Project() pulumi.StringOutput {
return o.ApplyT(func(v *WebApp) pulumi.StringOutput { return v.Project }).(pulumi.StringOutput)
}
type WebAppArrayOutput struct{ *pulumi.OutputState }
func (WebAppArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*WebApp)(nil)).Elem()
}
func (o WebAppArrayOutput) ToWebAppArrayOutput() WebAppArrayOutput {
return o
}
func (o WebAppArrayOutput) ToWebAppArrayOutputWithContext(ctx context.Context) WebAppArrayOutput {
return o
}
func (o WebAppArrayOutput) ToOutput(ctx context.Context) pulumix.Output[[]*WebApp] {
return pulumix.Output[[]*WebApp]{
OutputState: o.OutputState,
}
}
func (o WebAppArrayOutput) Index(i pulumi.IntInput) WebAppOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *WebApp {
return vs[0].([]*WebApp)[vs[1].(int)]
}).(WebAppOutput)
}
type WebAppMapOutput struct{ *pulumi.OutputState }
func (WebAppMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*WebApp)(nil)).Elem()
}
func (o WebAppMapOutput) ToWebAppMapOutput() WebAppMapOutput {
return o
}
func (o WebAppMapOutput) ToWebAppMapOutputWithContext(ctx context.Context) WebAppMapOutput {
return o
}
func (o WebAppMapOutput) ToOutput(ctx context.Context) pulumix.Output[map[string]*WebApp] {
return pulumix.Output[map[string]*WebApp]{
OutputState: o.OutputState,
}
}
func (o WebAppMapOutput) MapIndex(k pulumi.StringInput) WebAppOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *WebApp {
return vs[0].(map[string]*WebApp)[vs[1].(string)]
}).(WebAppOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*WebAppInput)(nil)).Elem(), &WebApp{})
pulumi.RegisterInputType(reflect.TypeOf((*WebAppArrayInput)(nil)).Elem(), WebAppArray{})
pulumi.RegisterInputType(reflect.TypeOf((*WebAppMapInput)(nil)).Elem(), WebAppMap{})
pulumi.RegisterOutputType(WebAppOutput{})
pulumi.RegisterOutputType(WebAppArrayOutput{})
pulumi.RegisterOutputType(WebAppMapOutput{})
}