/
gcpServiceAccount.go
368 lines (312 loc) · 13.5 KB
/
gcpServiceAccount.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
// 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 spacelift
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumix"
"github.com/spacelift-io/pulumi-spacelift/sdk/v2/go/spacelift/internal"
)
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "fmt"
//
// "github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/organizations"
// "github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/projects"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/spacelift-io/pulumi-spacelift/sdk/v2/go/spacelift"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := spacelift.NewStack(ctx, "k8s-coreStack", &spacelift.StackArgs{
// Branch: pulumi.String("master"),
// Repository: pulumi.String("core-infra"),
// })
// if err != nil {
// return err
// }
// _, err = spacelift.NewGcpServiceAccount(ctx, "k8s-coreGcpServiceAccount", &spacelift.GcpServiceAccountArgs{
// StackId: k8s_coreStack.ID(),
// TokenScopes: pulumi.StringArray{
// pulumi.String("https://www.googleapis.com/auth/compute"),
// pulumi.String("https://www.googleapis.com/auth/cloud-platform"),
// pulumi.String("https://www.googleapis.com/auth/devstorage.full_control"),
// },
// })
// if err != nil {
// return err
// }
// _, err = organizations.NewProject(ctx, "k8s-coreProject", &organizations.ProjectArgs{
// ProjectId: pulumi.String("unicorn-k8s-core"),
// OrgId: pulumi.Any(_var.Gcp_organization_id),
// })
// if err != nil {
// return err
// }
// _, err = projects.NewIAMMember(ctx, "k8s-coreIAMMember", &projects.IAMMemberArgs{
// Project: k8s_coreProject.ID(),
// Role: pulumi.String("roles/owner"),
// Member: k8s_coreGcpServiceAccount.ServiceAccountEmail.ApplyT(func(serviceAccountEmail string) (string, error) {
// return fmt.Sprintf("serviceAccount:%v", serviceAccountEmail), nil
// }).(pulumi.StringOutput),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// ```sh
//
// $ pulumi import spacelift:index/gcpServiceAccount:GcpServiceAccount k8s-core stack/$STACK_ID
//
// ```
//
// ```sh
//
// $ pulumi import spacelift:index/gcpServiceAccount:GcpServiceAccount k8s-core module/$MODULE_ID
//
// ```
type GcpServiceAccount struct {
pulumi.CustomResourceState
// ID of the module which uses GCP service account credentials
ModuleId pulumi.StringPtrOutput `pulumi:"moduleId"`
// Email address of the GCP service account dedicated for this stack
ServiceAccountEmail pulumi.StringOutput `pulumi:"serviceAccountEmail"`
// ID of the stack which uses GCP service account credentials
StackId pulumi.StringPtrOutput `pulumi:"stackId"`
// List of scopes that will be requested when generating temporary GCP service account credentials
TokenScopes pulumi.StringArrayOutput `pulumi:"tokenScopes"`
}
// NewGcpServiceAccount registers a new resource with the given unique name, arguments, and options.
func NewGcpServiceAccount(ctx *pulumi.Context,
name string, args *GcpServiceAccountArgs, opts ...pulumi.ResourceOption) (*GcpServiceAccount, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.TokenScopes == nil {
return nil, errors.New("invalid value for required argument 'TokenScopes'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource GcpServiceAccount
err := ctx.RegisterResource("spacelift:index/gcpServiceAccount:GcpServiceAccount", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetGcpServiceAccount gets an existing GcpServiceAccount 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 GetGcpServiceAccount(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *GcpServiceAccountState, opts ...pulumi.ResourceOption) (*GcpServiceAccount, error) {
var resource GcpServiceAccount
err := ctx.ReadResource("spacelift:index/gcpServiceAccount:GcpServiceAccount", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering GcpServiceAccount resources.
type gcpServiceAccountState struct {
// ID of the module which uses GCP service account credentials
ModuleId *string `pulumi:"moduleId"`
// Email address of the GCP service account dedicated for this stack
ServiceAccountEmail *string `pulumi:"serviceAccountEmail"`
// ID of the stack which uses GCP service account credentials
StackId *string `pulumi:"stackId"`
// List of scopes that will be requested when generating temporary GCP service account credentials
TokenScopes []string `pulumi:"tokenScopes"`
}
type GcpServiceAccountState struct {
// ID of the module which uses GCP service account credentials
ModuleId pulumi.StringPtrInput
// Email address of the GCP service account dedicated for this stack
ServiceAccountEmail pulumi.StringPtrInput
// ID of the stack which uses GCP service account credentials
StackId pulumi.StringPtrInput
// List of scopes that will be requested when generating temporary GCP service account credentials
TokenScopes pulumi.StringArrayInput
}
func (GcpServiceAccountState) ElementType() reflect.Type {
return reflect.TypeOf((*gcpServiceAccountState)(nil)).Elem()
}
type gcpServiceAccountArgs struct {
// ID of the module which uses GCP service account credentials
ModuleId *string `pulumi:"moduleId"`
// ID of the stack which uses GCP service account credentials
StackId *string `pulumi:"stackId"`
// List of scopes that will be requested when generating temporary GCP service account credentials
TokenScopes []string `pulumi:"tokenScopes"`
}
// The set of arguments for constructing a GcpServiceAccount resource.
type GcpServiceAccountArgs struct {
// ID of the module which uses GCP service account credentials
ModuleId pulumi.StringPtrInput
// ID of the stack which uses GCP service account credentials
StackId pulumi.StringPtrInput
// List of scopes that will be requested when generating temporary GCP service account credentials
TokenScopes pulumi.StringArrayInput
}
func (GcpServiceAccountArgs) ElementType() reflect.Type {
return reflect.TypeOf((*gcpServiceAccountArgs)(nil)).Elem()
}
type GcpServiceAccountInput interface {
pulumi.Input
ToGcpServiceAccountOutput() GcpServiceAccountOutput
ToGcpServiceAccountOutputWithContext(ctx context.Context) GcpServiceAccountOutput
}
func (*GcpServiceAccount) ElementType() reflect.Type {
return reflect.TypeOf((**GcpServiceAccount)(nil)).Elem()
}
func (i *GcpServiceAccount) ToGcpServiceAccountOutput() GcpServiceAccountOutput {
return i.ToGcpServiceAccountOutputWithContext(context.Background())
}
func (i *GcpServiceAccount) ToGcpServiceAccountOutputWithContext(ctx context.Context) GcpServiceAccountOutput {
return pulumi.ToOutputWithContext(ctx, i).(GcpServiceAccountOutput)
}
func (i *GcpServiceAccount) ToOutput(ctx context.Context) pulumix.Output[*GcpServiceAccount] {
return pulumix.Output[*GcpServiceAccount]{
OutputState: i.ToGcpServiceAccountOutputWithContext(ctx).OutputState,
}
}
// GcpServiceAccountArrayInput is an input type that accepts GcpServiceAccountArray and GcpServiceAccountArrayOutput values.
// You can construct a concrete instance of `GcpServiceAccountArrayInput` via:
//
// GcpServiceAccountArray{ GcpServiceAccountArgs{...} }
type GcpServiceAccountArrayInput interface {
pulumi.Input
ToGcpServiceAccountArrayOutput() GcpServiceAccountArrayOutput
ToGcpServiceAccountArrayOutputWithContext(context.Context) GcpServiceAccountArrayOutput
}
type GcpServiceAccountArray []GcpServiceAccountInput
func (GcpServiceAccountArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*GcpServiceAccount)(nil)).Elem()
}
func (i GcpServiceAccountArray) ToGcpServiceAccountArrayOutput() GcpServiceAccountArrayOutput {
return i.ToGcpServiceAccountArrayOutputWithContext(context.Background())
}
func (i GcpServiceAccountArray) ToGcpServiceAccountArrayOutputWithContext(ctx context.Context) GcpServiceAccountArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(GcpServiceAccountArrayOutput)
}
func (i GcpServiceAccountArray) ToOutput(ctx context.Context) pulumix.Output[[]*GcpServiceAccount] {
return pulumix.Output[[]*GcpServiceAccount]{
OutputState: i.ToGcpServiceAccountArrayOutputWithContext(ctx).OutputState,
}
}
// GcpServiceAccountMapInput is an input type that accepts GcpServiceAccountMap and GcpServiceAccountMapOutput values.
// You can construct a concrete instance of `GcpServiceAccountMapInput` via:
//
// GcpServiceAccountMap{ "key": GcpServiceAccountArgs{...} }
type GcpServiceAccountMapInput interface {
pulumi.Input
ToGcpServiceAccountMapOutput() GcpServiceAccountMapOutput
ToGcpServiceAccountMapOutputWithContext(context.Context) GcpServiceAccountMapOutput
}
type GcpServiceAccountMap map[string]GcpServiceAccountInput
func (GcpServiceAccountMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*GcpServiceAccount)(nil)).Elem()
}
func (i GcpServiceAccountMap) ToGcpServiceAccountMapOutput() GcpServiceAccountMapOutput {
return i.ToGcpServiceAccountMapOutputWithContext(context.Background())
}
func (i GcpServiceAccountMap) ToGcpServiceAccountMapOutputWithContext(ctx context.Context) GcpServiceAccountMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(GcpServiceAccountMapOutput)
}
func (i GcpServiceAccountMap) ToOutput(ctx context.Context) pulumix.Output[map[string]*GcpServiceAccount] {
return pulumix.Output[map[string]*GcpServiceAccount]{
OutputState: i.ToGcpServiceAccountMapOutputWithContext(ctx).OutputState,
}
}
type GcpServiceAccountOutput struct{ *pulumi.OutputState }
func (GcpServiceAccountOutput) ElementType() reflect.Type {
return reflect.TypeOf((**GcpServiceAccount)(nil)).Elem()
}
func (o GcpServiceAccountOutput) ToGcpServiceAccountOutput() GcpServiceAccountOutput {
return o
}
func (o GcpServiceAccountOutput) ToGcpServiceAccountOutputWithContext(ctx context.Context) GcpServiceAccountOutput {
return o
}
func (o GcpServiceAccountOutput) ToOutput(ctx context.Context) pulumix.Output[*GcpServiceAccount] {
return pulumix.Output[*GcpServiceAccount]{
OutputState: o.OutputState,
}
}
// ID of the module which uses GCP service account credentials
func (o GcpServiceAccountOutput) ModuleId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *GcpServiceAccount) pulumi.StringPtrOutput { return v.ModuleId }).(pulumi.StringPtrOutput)
}
// Email address of the GCP service account dedicated for this stack
func (o GcpServiceAccountOutput) ServiceAccountEmail() pulumi.StringOutput {
return o.ApplyT(func(v *GcpServiceAccount) pulumi.StringOutput { return v.ServiceAccountEmail }).(pulumi.StringOutput)
}
// ID of the stack which uses GCP service account credentials
func (o GcpServiceAccountOutput) StackId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *GcpServiceAccount) pulumi.StringPtrOutput { return v.StackId }).(pulumi.StringPtrOutput)
}
// List of scopes that will be requested when generating temporary GCP service account credentials
func (o GcpServiceAccountOutput) TokenScopes() pulumi.StringArrayOutput {
return o.ApplyT(func(v *GcpServiceAccount) pulumi.StringArrayOutput { return v.TokenScopes }).(pulumi.StringArrayOutput)
}
type GcpServiceAccountArrayOutput struct{ *pulumi.OutputState }
func (GcpServiceAccountArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*GcpServiceAccount)(nil)).Elem()
}
func (o GcpServiceAccountArrayOutput) ToGcpServiceAccountArrayOutput() GcpServiceAccountArrayOutput {
return o
}
func (o GcpServiceAccountArrayOutput) ToGcpServiceAccountArrayOutputWithContext(ctx context.Context) GcpServiceAccountArrayOutput {
return o
}
func (o GcpServiceAccountArrayOutput) ToOutput(ctx context.Context) pulumix.Output[[]*GcpServiceAccount] {
return pulumix.Output[[]*GcpServiceAccount]{
OutputState: o.OutputState,
}
}
func (o GcpServiceAccountArrayOutput) Index(i pulumi.IntInput) GcpServiceAccountOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *GcpServiceAccount {
return vs[0].([]*GcpServiceAccount)[vs[1].(int)]
}).(GcpServiceAccountOutput)
}
type GcpServiceAccountMapOutput struct{ *pulumi.OutputState }
func (GcpServiceAccountMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*GcpServiceAccount)(nil)).Elem()
}
func (o GcpServiceAccountMapOutput) ToGcpServiceAccountMapOutput() GcpServiceAccountMapOutput {
return o
}
func (o GcpServiceAccountMapOutput) ToGcpServiceAccountMapOutputWithContext(ctx context.Context) GcpServiceAccountMapOutput {
return o
}
func (o GcpServiceAccountMapOutput) ToOutput(ctx context.Context) pulumix.Output[map[string]*GcpServiceAccount] {
return pulumix.Output[map[string]*GcpServiceAccount]{
OutputState: o.OutputState,
}
}
func (o GcpServiceAccountMapOutput) MapIndex(k pulumi.StringInput) GcpServiceAccountOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *GcpServiceAccount {
return vs[0].(map[string]*GcpServiceAccount)[vs[1].(string)]
}).(GcpServiceAccountOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*GcpServiceAccountInput)(nil)).Elem(), &GcpServiceAccount{})
pulumi.RegisterInputType(reflect.TypeOf((*GcpServiceAccountArrayInput)(nil)).Elem(), GcpServiceAccountArray{})
pulumi.RegisterInputType(reflect.TypeOf((*GcpServiceAccountMapInput)(nil)).Elem(), GcpServiceAccountMap{})
pulumi.RegisterOutputType(GcpServiceAccountOutput{})
pulumi.RegisterOutputType(GcpServiceAccountArrayOutput{})
pulumi.RegisterOutputType(GcpServiceAccountMapOutput{})
}