/
ingress.go
507 lines (451 loc) · 19.3 KB
/
ingress.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
// 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 sae
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a Serverless App Engine (SAE) Ingress resource.
//
// For information about Serverless App Engine (SAE) Ingress and how to use it, see [What is Ingress](https://www.alibabacloud.com/help/en/sae/latest/createingress).
//
// > **NOTE:** Available since v1.137.0.
//
// ## Example Usage
//
// # Basic Usage
//
// ```go
// package main
//
// import (
//
// "fmt"
//
// "github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
// "github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
// "github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/sae"
// "github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/slb"
// "github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
// "github.com/pulumi/pulumi-random/sdk/v4/go/random"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// cfg := config.New(ctx, "")
// name := "tf-example"
// if param := cfg.Get("name"); param != "" {
// name = param
// }
// _default, err := alicloud.GetRegions(ctx, &alicloud.GetRegionsArgs{
// Current: pulumi.BoolRef(true),
// }, nil)
// if err != nil {
// return err
// }
// defaultInteger, err := random.NewInteger(ctx, "default", &random.IntegerArgs{
// Max: 99999,
// Min: 10000,
// })
// if err != nil {
// return err
// }
// defaultGetZones, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
// AvailableResourceCreation: pulumi.StringRef("VSwitch"),
// }, nil)
// if err != nil {
// return err
// }
// defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
// VpcName: pulumi.String(name),
// CidrBlock: pulumi.String("10.4.0.0/16"),
// })
// if err != nil {
// return err
// }
// defaultSwitch, err := vpc.NewSwitch(ctx, "default", &vpc.SwitchArgs{
// VswitchName: pulumi.String(name),
// CidrBlock: pulumi.String("10.4.0.0/24"),
// VpcId: defaultNetwork.ID(),
// ZoneId: pulumi.String(defaultGetZones.Zones[0].Id),
// })
// if err != nil {
// return err
// }
// defaultSecurityGroup, err := ecs.NewSecurityGroup(ctx, "default", &ecs.SecurityGroupArgs{
// VpcId: defaultNetwork.ID(),
// })
// if err != nil {
// return err
// }
// defaultNamespace, err := sae.NewNamespace(ctx, "default", &sae.NamespaceArgs{
// NamespaceId: pulumi.String(fmt.Sprintf("%v:example%v", _default.Regions[0].Id, defaultInteger.Result)),
// NamespaceName: pulumi.String(name),
// NamespaceDescription: pulumi.String(name),
// EnableMicroRegistration: pulumi.Bool(false),
// })
// if err != nil {
// return err
// }
// defaultApplication, err := sae.NewApplication(ctx, "default", &sae.ApplicationArgs{
// AppDescription: pulumi.String(name),
// AppName: pulumi.String(fmt.Sprintf("%v-%v", name, defaultInteger.Result)),
// NamespaceId: defaultNamespace.ID(),
// ImageUrl: pulumi.String(fmt.Sprintf("registry-vpc.%v.aliyuncs.com/sae-demo-image/consumer:1.0", _default.Regions[0].Id)),
// PackageType: pulumi.String("Image"),
// SecurityGroupId: defaultSecurityGroup.ID(),
// VpcId: defaultNetwork.ID(),
// VswitchId: defaultSwitch.ID(),
// Timezone: pulumi.String("Asia/Beijing"),
// Replicas: pulumi.Int(5),
// Cpu: pulumi.Int(500),
// Memory: pulumi.Int(2048),
// })
// if err != nil {
// return err
// }
// defaultApplicationLoadBalancer, err := slb.NewApplicationLoadBalancer(ctx, "default", &slb.ApplicationLoadBalancerArgs{
// LoadBalancerName: pulumi.String(name),
// VswitchId: defaultSwitch.ID(),
// LoadBalancerSpec: pulumi.String("slb.s2.small"),
// AddressType: pulumi.String("intranet"),
// })
// if err != nil {
// return err
// }
// _, err = sae.NewIngress(ctx, "default", &sae.IngressArgs{
// SlbId: defaultApplicationLoadBalancer.ID(),
// NamespaceId: defaultNamespace.ID(),
// ListenerPort: pulumi.Int(80),
// Rules: sae.IngressRuleArray{
// &sae.IngressRuleArgs{
// AppId: defaultApplication.ID(),
// ContainerPort: pulumi.Int(443),
// Domain: pulumi.String("www.alicloud.com"),
// AppName: defaultApplication.AppName,
// Path: pulumi.String("/"),
// },
// },
// DefaultRule: &sae.IngressDefaultRuleArgs{
// AppId: defaultApplication.ID(),
// ContainerPort: pulumi.Int(443),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Serverless App Engine (SAE) Ingress can be imported using the id, e.g.
//
// ```sh
// $ pulumi import alicloud:sae/ingress:Ingress example <id>
// ```
type Ingress struct {
pulumi.CustomResourceState
// The certificate ID of the HTTPS listener. The `certId` takes effect only when `loadBalanceType` is set to `clb`.
CertId pulumi.StringPtrOutput `pulumi:"certId"`
// The certificate IDs of the HTTPS listener, and multiple certificate IDs are separated by commas. The `certIds` takes effect only when `loadBalanceType` is set to `alb`.
CertIds pulumi.StringPtrOutput `pulumi:"certIds"`
// Default Rule. See `defaultRule` below.
DefaultRule IngressDefaultRulePtrOutput `pulumi:"defaultRule"`
// Description.
Description pulumi.StringPtrOutput `pulumi:"description"`
// SLB listening port.
ListenerPort pulumi.IntOutput `pulumi:"listenerPort"`
// The protocol that is used to forward requests. Default value: `HTTP`. Valid values: `HTTP`, `HTTPS`.
ListenerProtocol pulumi.StringOutput `pulumi:"listenerProtocol"`
// The type of the SLB instance. Default value: `clb`. Valid values: `clb`, `alb`.
LoadBalanceType pulumi.StringOutput `pulumi:"loadBalanceType"`
// The ID of Namespace. It can contain 2 to 32 lowercase characters.The value is in format `{RegionId}:{namespace}`.
NamespaceId pulumi.StringOutput `pulumi:"namespaceId"`
// Forwarding rules. Forward traffic to the specified application according to the domain name and path. See `rules` below.
Rules IngressRuleArrayOutput `pulumi:"rules"`
// SLB ID.
SlbId pulumi.StringOutput `pulumi:"slbId"`
}
// NewIngress registers a new resource with the given unique name, arguments, and options.
func NewIngress(ctx *pulumi.Context,
name string, args *IngressArgs, opts ...pulumi.ResourceOption) (*Ingress, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.ListenerPort == nil {
return nil, errors.New("invalid value for required argument 'ListenerPort'")
}
if args.NamespaceId == nil {
return nil, errors.New("invalid value for required argument 'NamespaceId'")
}
if args.Rules == nil {
return nil, errors.New("invalid value for required argument 'Rules'")
}
if args.SlbId == nil {
return nil, errors.New("invalid value for required argument 'SlbId'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource Ingress
err := ctx.RegisterResource("alicloud:sae/ingress:Ingress", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetIngress gets an existing Ingress 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 GetIngress(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *IngressState, opts ...pulumi.ResourceOption) (*Ingress, error) {
var resource Ingress
err := ctx.ReadResource("alicloud:sae/ingress:Ingress", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Ingress resources.
type ingressState struct {
// The certificate ID of the HTTPS listener. The `certId` takes effect only when `loadBalanceType` is set to `clb`.
CertId *string `pulumi:"certId"`
// The certificate IDs of the HTTPS listener, and multiple certificate IDs are separated by commas. The `certIds` takes effect only when `loadBalanceType` is set to `alb`.
CertIds *string `pulumi:"certIds"`
// Default Rule. See `defaultRule` below.
DefaultRule *IngressDefaultRule `pulumi:"defaultRule"`
// Description.
Description *string `pulumi:"description"`
// SLB listening port.
ListenerPort *int `pulumi:"listenerPort"`
// The protocol that is used to forward requests. Default value: `HTTP`. Valid values: `HTTP`, `HTTPS`.
ListenerProtocol *string `pulumi:"listenerProtocol"`
// The type of the SLB instance. Default value: `clb`. Valid values: `clb`, `alb`.
LoadBalanceType *string `pulumi:"loadBalanceType"`
// The ID of Namespace. It can contain 2 to 32 lowercase characters.The value is in format `{RegionId}:{namespace}`.
NamespaceId *string `pulumi:"namespaceId"`
// Forwarding rules. Forward traffic to the specified application according to the domain name and path. See `rules` below.
Rules []IngressRule `pulumi:"rules"`
// SLB ID.
SlbId *string `pulumi:"slbId"`
}
type IngressState struct {
// The certificate ID of the HTTPS listener. The `certId` takes effect only when `loadBalanceType` is set to `clb`.
CertId pulumi.StringPtrInput
// The certificate IDs of the HTTPS listener, and multiple certificate IDs are separated by commas. The `certIds` takes effect only when `loadBalanceType` is set to `alb`.
CertIds pulumi.StringPtrInput
// Default Rule. See `defaultRule` below.
DefaultRule IngressDefaultRulePtrInput
// Description.
Description pulumi.StringPtrInput
// SLB listening port.
ListenerPort pulumi.IntPtrInput
// The protocol that is used to forward requests. Default value: `HTTP`. Valid values: `HTTP`, `HTTPS`.
ListenerProtocol pulumi.StringPtrInput
// The type of the SLB instance. Default value: `clb`. Valid values: `clb`, `alb`.
LoadBalanceType pulumi.StringPtrInput
// The ID of Namespace. It can contain 2 to 32 lowercase characters.The value is in format `{RegionId}:{namespace}`.
NamespaceId pulumi.StringPtrInput
// Forwarding rules. Forward traffic to the specified application according to the domain name and path. See `rules` below.
Rules IngressRuleArrayInput
// SLB ID.
SlbId pulumi.StringPtrInput
}
func (IngressState) ElementType() reflect.Type {
return reflect.TypeOf((*ingressState)(nil)).Elem()
}
type ingressArgs struct {
// The certificate ID of the HTTPS listener. The `certId` takes effect only when `loadBalanceType` is set to `clb`.
CertId *string `pulumi:"certId"`
// The certificate IDs of the HTTPS listener, and multiple certificate IDs are separated by commas. The `certIds` takes effect only when `loadBalanceType` is set to `alb`.
CertIds *string `pulumi:"certIds"`
// Default Rule. See `defaultRule` below.
DefaultRule *IngressDefaultRule `pulumi:"defaultRule"`
// Description.
Description *string `pulumi:"description"`
// SLB listening port.
ListenerPort int `pulumi:"listenerPort"`
// The protocol that is used to forward requests. Default value: `HTTP`. Valid values: `HTTP`, `HTTPS`.
ListenerProtocol *string `pulumi:"listenerProtocol"`
// The type of the SLB instance. Default value: `clb`. Valid values: `clb`, `alb`.
LoadBalanceType *string `pulumi:"loadBalanceType"`
// The ID of Namespace. It can contain 2 to 32 lowercase characters.The value is in format `{RegionId}:{namespace}`.
NamespaceId string `pulumi:"namespaceId"`
// Forwarding rules. Forward traffic to the specified application according to the domain name and path. See `rules` below.
Rules []IngressRule `pulumi:"rules"`
// SLB ID.
SlbId string `pulumi:"slbId"`
}
// The set of arguments for constructing a Ingress resource.
type IngressArgs struct {
// The certificate ID of the HTTPS listener. The `certId` takes effect only when `loadBalanceType` is set to `clb`.
CertId pulumi.StringPtrInput
// The certificate IDs of the HTTPS listener, and multiple certificate IDs are separated by commas. The `certIds` takes effect only when `loadBalanceType` is set to `alb`.
CertIds pulumi.StringPtrInput
// Default Rule. See `defaultRule` below.
DefaultRule IngressDefaultRulePtrInput
// Description.
Description pulumi.StringPtrInput
// SLB listening port.
ListenerPort pulumi.IntInput
// The protocol that is used to forward requests. Default value: `HTTP`. Valid values: `HTTP`, `HTTPS`.
ListenerProtocol pulumi.StringPtrInput
// The type of the SLB instance. Default value: `clb`. Valid values: `clb`, `alb`.
LoadBalanceType pulumi.StringPtrInput
// The ID of Namespace. It can contain 2 to 32 lowercase characters.The value is in format `{RegionId}:{namespace}`.
NamespaceId pulumi.StringInput
// Forwarding rules. Forward traffic to the specified application according to the domain name and path. See `rules` below.
Rules IngressRuleArrayInput
// SLB ID.
SlbId pulumi.StringInput
}
func (IngressArgs) ElementType() reflect.Type {
return reflect.TypeOf((*ingressArgs)(nil)).Elem()
}
type IngressInput interface {
pulumi.Input
ToIngressOutput() IngressOutput
ToIngressOutputWithContext(ctx context.Context) IngressOutput
}
func (*Ingress) ElementType() reflect.Type {
return reflect.TypeOf((**Ingress)(nil)).Elem()
}
func (i *Ingress) ToIngressOutput() IngressOutput {
return i.ToIngressOutputWithContext(context.Background())
}
func (i *Ingress) ToIngressOutputWithContext(ctx context.Context) IngressOutput {
return pulumi.ToOutputWithContext(ctx, i).(IngressOutput)
}
// IngressArrayInput is an input type that accepts IngressArray and IngressArrayOutput values.
// You can construct a concrete instance of `IngressArrayInput` via:
//
// IngressArray{ IngressArgs{...} }
type IngressArrayInput interface {
pulumi.Input
ToIngressArrayOutput() IngressArrayOutput
ToIngressArrayOutputWithContext(context.Context) IngressArrayOutput
}
type IngressArray []IngressInput
func (IngressArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Ingress)(nil)).Elem()
}
func (i IngressArray) ToIngressArrayOutput() IngressArrayOutput {
return i.ToIngressArrayOutputWithContext(context.Background())
}
func (i IngressArray) ToIngressArrayOutputWithContext(ctx context.Context) IngressArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(IngressArrayOutput)
}
// IngressMapInput is an input type that accepts IngressMap and IngressMapOutput values.
// You can construct a concrete instance of `IngressMapInput` via:
//
// IngressMap{ "key": IngressArgs{...} }
type IngressMapInput interface {
pulumi.Input
ToIngressMapOutput() IngressMapOutput
ToIngressMapOutputWithContext(context.Context) IngressMapOutput
}
type IngressMap map[string]IngressInput
func (IngressMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Ingress)(nil)).Elem()
}
func (i IngressMap) ToIngressMapOutput() IngressMapOutput {
return i.ToIngressMapOutputWithContext(context.Background())
}
func (i IngressMap) ToIngressMapOutputWithContext(ctx context.Context) IngressMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(IngressMapOutput)
}
type IngressOutput struct{ *pulumi.OutputState }
func (IngressOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Ingress)(nil)).Elem()
}
func (o IngressOutput) ToIngressOutput() IngressOutput {
return o
}
func (o IngressOutput) ToIngressOutputWithContext(ctx context.Context) IngressOutput {
return o
}
// The certificate ID of the HTTPS listener. The `certId` takes effect only when `loadBalanceType` is set to `clb`.
func (o IngressOutput) CertId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Ingress) pulumi.StringPtrOutput { return v.CertId }).(pulumi.StringPtrOutput)
}
// The certificate IDs of the HTTPS listener, and multiple certificate IDs are separated by commas. The `certIds` takes effect only when `loadBalanceType` is set to `alb`.
func (o IngressOutput) CertIds() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Ingress) pulumi.StringPtrOutput { return v.CertIds }).(pulumi.StringPtrOutput)
}
// Default Rule. See `defaultRule` below.
func (o IngressOutput) DefaultRule() IngressDefaultRulePtrOutput {
return o.ApplyT(func(v *Ingress) IngressDefaultRulePtrOutput { return v.DefaultRule }).(IngressDefaultRulePtrOutput)
}
// Description.
func (o IngressOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Ingress) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
// SLB listening port.
func (o IngressOutput) ListenerPort() pulumi.IntOutput {
return o.ApplyT(func(v *Ingress) pulumi.IntOutput { return v.ListenerPort }).(pulumi.IntOutput)
}
// The protocol that is used to forward requests. Default value: `HTTP`. Valid values: `HTTP`, `HTTPS`.
func (o IngressOutput) ListenerProtocol() pulumi.StringOutput {
return o.ApplyT(func(v *Ingress) pulumi.StringOutput { return v.ListenerProtocol }).(pulumi.StringOutput)
}
// The type of the SLB instance. Default value: `clb`. Valid values: `clb`, `alb`.
func (o IngressOutput) LoadBalanceType() pulumi.StringOutput {
return o.ApplyT(func(v *Ingress) pulumi.StringOutput { return v.LoadBalanceType }).(pulumi.StringOutput)
}
// The ID of Namespace. It can contain 2 to 32 lowercase characters.The value is in format `{RegionId}:{namespace}`.
func (o IngressOutput) NamespaceId() pulumi.StringOutput {
return o.ApplyT(func(v *Ingress) pulumi.StringOutput { return v.NamespaceId }).(pulumi.StringOutput)
}
// Forwarding rules. Forward traffic to the specified application according to the domain name and path. See `rules` below.
func (o IngressOutput) Rules() IngressRuleArrayOutput {
return o.ApplyT(func(v *Ingress) IngressRuleArrayOutput { return v.Rules }).(IngressRuleArrayOutput)
}
// SLB ID.
func (o IngressOutput) SlbId() pulumi.StringOutput {
return o.ApplyT(func(v *Ingress) pulumi.StringOutput { return v.SlbId }).(pulumi.StringOutput)
}
type IngressArrayOutput struct{ *pulumi.OutputState }
func (IngressArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Ingress)(nil)).Elem()
}
func (o IngressArrayOutput) ToIngressArrayOutput() IngressArrayOutput {
return o
}
func (o IngressArrayOutput) ToIngressArrayOutputWithContext(ctx context.Context) IngressArrayOutput {
return o
}
func (o IngressArrayOutput) Index(i pulumi.IntInput) IngressOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Ingress {
return vs[0].([]*Ingress)[vs[1].(int)]
}).(IngressOutput)
}
type IngressMapOutput struct{ *pulumi.OutputState }
func (IngressMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Ingress)(nil)).Elem()
}
func (o IngressMapOutput) ToIngressMapOutput() IngressMapOutput {
return o
}
func (o IngressMapOutput) ToIngressMapOutputWithContext(ctx context.Context) IngressMapOutput {
return o
}
func (o IngressMapOutput) MapIndex(k pulumi.StringInput) IngressOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Ingress {
return vs[0].(map[string]*Ingress)[vs[1].(string)]
}).(IngressOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*IngressInput)(nil)).Elem(), &Ingress{})
pulumi.RegisterInputType(reflect.TypeOf((*IngressArrayInput)(nil)).Elem(), IngressArray{})
pulumi.RegisterInputType(reflect.TypeOf((*IngressMapInput)(nil)).Elem(), IngressMap{})
pulumi.RegisterOutputType(IngressOutput{})
pulumi.RegisterOutputType(IngressArrayOutput{})
pulumi.RegisterOutputType(IngressMapOutput{})
}