/
autoscaler.go
243 lines (203 loc) · 16.2 KB
/
autoscaler.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
// Code generated by the Pulumi SDK Generator DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package alpha
import (
"context"
"reflect"
"github.com/pulumi/pulumi-google-native/sdk/go/google/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Creates an autoscaler in the specified project using the data included in the request.
type Autoscaler struct {
pulumi.CustomResourceState
// The configuration parameters for the autoscaling algorithm. You can define one or more signals for an autoscaler: cpuUtilization, customMetricUtilizations, and loadBalancingUtilization. If none of these are specified, the default will be to autoscale based on cpuUtilization to 0.6 or 60%.
AutoscalingPolicy AutoscalingPolicyResponseOutput `pulumi:"autoscalingPolicy"`
// Creation timestamp in RFC3339 text format.
CreationTimestamp pulumi.StringOutput `pulumi:"creationTimestamp"`
// An optional description of this resource. Provide this property when you create the resource.
Description pulumi.StringOutput `pulumi:"description"`
// Type of the resource. Always compute#autoscaler for autoscalers.
Kind pulumi.StringOutput `pulumi:"kind"`
// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
Name pulumi.StringOutput `pulumi:"name"`
Project pulumi.StringOutput `pulumi:"project"`
// Target recommended MIG size (number of instances) computed by autoscaler. Autoscaler calculates the recommended MIG size even when the autoscaling policy mode is different from ON. This field is empty when autoscaler is not connected to an existing managed instance group or autoscaler did not generate its prediction.
RecommendedSize pulumi.IntOutput `pulumi:"recommendedSize"`
// URL of the region where the instance group resides (for autoscalers living in regional scope).
Region pulumi.StringOutput `pulumi:"region"`
// An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
RequestId pulumi.StringPtrOutput `pulumi:"requestId"`
// Status information of existing scaling schedules.
ScalingScheduleStatus pulumi.StringMapOutput `pulumi:"scalingScheduleStatus"`
// Server-defined URL for the resource.
SelfLink pulumi.StringOutput `pulumi:"selfLink"`
// Server-defined URL for this resource with the resource id.
SelfLinkWithId pulumi.StringOutput `pulumi:"selfLinkWithId"`
// The status of the autoscaler configuration. Current set of possible values: - PENDING: Autoscaler backend hasn't read new/updated configuration. - DELETING: Configuration is being deleted. - ACTIVE: Configuration is acknowledged to be effective. Some warnings might be present in the statusDetails field. - ERROR: Configuration has errors. Actionable for users. Details are present in the statusDetails field. New values might be added in the future.
Status pulumi.StringOutput `pulumi:"status"`
// Human-readable details about the current state of the autoscaler. Read the documentation for Commonly returned status messages for examples of status messages you might encounter.
StatusDetails AutoscalerStatusDetailsResponseArrayOutput `pulumi:"statusDetails"`
// URL of the managed instance group that this autoscaler will scale. This field is required when creating an autoscaler.
Target pulumi.StringOutput `pulumi:"target"`
Zone pulumi.StringOutput `pulumi:"zone"`
}
// NewAutoscaler registers a new resource with the given unique name, arguments, and options.
func NewAutoscaler(ctx *pulumi.Context,
name string, args *AutoscalerArgs, opts ...pulumi.ResourceOption) (*Autoscaler, error) {
if args == nil {
args = &AutoscalerArgs{}
}
replaceOnChanges := pulumi.ReplaceOnChanges([]string{
"project",
"zone",
})
opts = append(opts, replaceOnChanges)
opts = internal.PkgResourceDefaultOpts(opts)
var resource Autoscaler
err := ctx.RegisterResource("google-native:compute/alpha:Autoscaler", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetAutoscaler gets an existing Autoscaler 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 GetAutoscaler(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *AutoscalerState, opts ...pulumi.ResourceOption) (*Autoscaler, error) {
var resource Autoscaler
err := ctx.ReadResource("google-native:compute/alpha:Autoscaler", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Autoscaler resources.
type autoscalerState struct {
}
type AutoscalerState struct {
}
func (AutoscalerState) ElementType() reflect.Type {
return reflect.TypeOf((*autoscalerState)(nil)).Elem()
}
type autoscalerArgs struct {
// The configuration parameters for the autoscaling algorithm. You can define one or more signals for an autoscaler: cpuUtilization, customMetricUtilizations, and loadBalancingUtilization. If none of these are specified, the default will be to autoscale based on cpuUtilization to 0.6 or 60%.
AutoscalingPolicy *AutoscalingPolicy `pulumi:"autoscalingPolicy"`
// An optional description of this resource. Provide this property when you create the resource.
Description *string `pulumi:"description"`
// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
Name *string `pulumi:"name"`
Project *string `pulumi:"project"`
// An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
RequestId *string `pulumi:"requestId"`
// URL of the managed instance group that this autoscaler will scale. This field is required when creating an autoscaler.
Target *string `pulumi:"target"`
Zone *string `pulumi:"zone"`
}
// The set of arguments for constructing a Autoscaler resource.
type AutoscalerArgs struct {
// The configuration parameters for the autoscaling algorithm. You can define one or more signals for an autoscaler: cpuUtilization, customMetricUtilizations, and loadBalancingUtilization. If none of these are specified, the default will be to autoscale based on cpuUtilization to 0.6 or 60%.
AutoscalingPolicy AutoscalingPolicyPtrInput
// An optional description of this resource. Provide this property when you create the resource.
Description pulumi.StringPtrInput
// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
Name pulumi.StringPtrInput
Project pulumi.StringPtrInput
// An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
RequestId pulumi.StringPtrInput
// URL of the managed instance group that this autoscaler will scale. This field is required when creating an autoscaler.
Target pulumi.StringPtrInput
Zone pulumi.StringPtrInput
}
func (AutoscalerArgs) ElementType() reflect.Type {
return reflect.TypeOf((*autoscalerArgs)(nil)).Elem()
}
type AutoscalerInput interface {
pulumi.Input
ToAutoscalerOutput() AutoscalerOutput
ToAutoscalerOutputWithContext(ctx context.Context) AutoscalerOutput
}
func (*Autoscaler) ElementType() reflect.Type {
return reflect.TypeOf((**Autoscaler)(nil)).Elem()
}
func (i *Autoscaler) ToAutoscalerOutput() AutoscalerOutput {
return i.ToAutoscalerOutputWithContext(context.Background())
}
func (i *Autoscaler) ToAutoscalerOutputWithContext(ctx context.Context) AutoscalerOutput {
return pulumi.ToOutputWithContext(ctx, i).(AutoscalerOutput)
}
type AutoscalerOutput struct{ *pulumi.OutputState }
func (AutoscalerOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Autoscaler)(nil)).Elem()
}
func (o AutoscalerOutput) ToAutoscalerOutput() AutoscalerOutput {
return o
}
func (o AutoscalerOutput) ToAutoscalerOutputWithContext(ctx context.Context) AutoscalerOutput {
return o
}
// The configuration parameters for the autoscaling algorithm. You can define one or more signals for an autoscaler: cpuUtilization, customMetricUtilizations, and loadBalancingUtilization. If none of these are specified, the default will be to autoscale based on cpuUtilization to 0.6 or 60%.
func (o AutoscalerOutput) AutoscalingPolicy() AutoscalingPolicyResponseOutput {
return o.ApplyT(func(v *Autoscaler) AutoscalingPolicyResponseOutput { return v.AutoscalingPolicy }).(AutoscalingPolicyResponseOutput)
}
// Creation timestamp in RFC3339 text format.
func (o AutoscalerOutput) CreationTimestamp() pulumi.StringOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.StringOutput { return v.CreationTimestamp }).(pulumi.StringOutput)
}
// An optional description of this resource. Provide this property when you create the resource.
func (o AutoscalerOutput) Description() pulumi.StringOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.StringOutput { return v.Description }).(pulumi.StringOutput)
}
// Type of the resource. Always compute#autoscaler for autoscalers.
func (o AutoscalerOutput) Kind() pulumi.StringOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.StringOutput { return v.Kind }).(pulumi.StringOutput)
}
// Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.
func (o AutoscalerOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
func (o AutoscalerOutput) Project() pulumi.StringOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.StringOutput { return v.Project }).(pulumi.StringOutput)
}
// Target recommended MIG size (number of instances) computed by autoscaler. Autoscaler calculates the recommended MIG size even when the autoscaling policy mode is different from ON. This field is empty when autoscaler is not connected to an existing managed instance group or autoscaler did not generate its prediction.
func (o AutoscalerOutput) RecommendedSize() pulumi.IntOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.IntOutput { return v.RecommendedSize }).(pulumi.IntOutput)
}
// URL of the region where the instance group resides (for autoscalers living in regional scope).
func (o AutoscalerOutput) Region() pulumi.StringOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.StringOutput { return v.Region }).(pulumi.StringOutput)
}
// An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
func (o AutoscalerOutput) RequestId() pulumi.StringPtrOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.StringPtrOutput { return v.RequestId }).(pulumi.StringPtrOutput)
}
// Status information of existing scaling schedules.
func (o AutoscalerOutput) ScalingScheduleStatus() pulumi.StringMapOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.StringMapOutput { return v.ScalingScheduleStatus }).(pulumi.StringMapOutput)
}
// Server-defined URL for the resource.
func (o AutoscalerOutput) SelfLink() pulumi.StringOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.StringOutput { return v.SelfLink }).(pulumi.StringOutput)
}
// Server-defined URL for this resource with the resource id.
func (o AutoscalerOutput) SelfLinkWithId() pulumi.StringOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.StringOutput { return v.SelfLinkWithId }).(pulumi.StringOutput)
}
// The status of the autoscaler configuration. Current set of possible values: - PENDING: Autoscaler backend hasn't read new/updated configuration. - DELETING: Configuration is being deleted. - ACTIVE: Configuration is acknowledged to be effective. Some warnings might be present in the statusDetails field. - ERROR: Configuration has errors. Actionable for users. Details are present in the statusDetails field. New values might be added in the future.
func (o AutoscalerOutput) Status() pulumi.StringOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.StringOutput { return v.Status }).(pulumi.StringOutput)
}
// Human-readable details about the current state of the autoscaler. Read the documentation for Commonly returned status messages for examples of status messages you might encounter.
func (o AutoscalerOutput) StatusDetails() AutoscalerStatusDetailsResponseArrayOutput {
return o.ApplyT(func(v *Autoscaler) AutoscalerStatusDetailsResponseArrayOutput { return v.StatusDetails }).(AutoscalerStatusDetailsResponseArrayOutput)
}
// URL of the managed instance group that this autoscaler will scale. This field is required when creating an autoscaler.
func (o AutoscalerOutput) Target() pulumi.StringOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.StringOutput { return v.Target }).(pulumi.StringOutput)
}
func (o AutoscalerOutput) Zone() pulumi.StringOutput {
return o.ApplyT(func(v *Autoscaler) pulumi.StringOutput { return v.Zone }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*AutoscalerInput)(nil)).Elem(), &Autoscaler{})
pulumi.RegisterOutputType(AutoscalerOutput{})
}