/
api_op_StartInstanceRefresh.go
183 lines (165 loc) · 6.77 KB
/
api_op_StartInstanceRefresh.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
// Code generated by smithy-go-codegen DO NOT EDIT.
package autoscaling
import (
"context"
"fmt"
awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
"github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
)
// Starts an instance refresh. This operation is part of the instance refresh
// feature (https://docs.aws.amazon.com/autoscaling/ec2/userguide/asg-instance-refresh.html)
// in Amazon EC2 Auto Scaling, which helps you update instances in your Auto
// Scaling group. This feature is helpful, for example, when you have a new AMI or
// a new user data script. You just need to create a new launch template that
// specifies the new AMI or user data script. Then start an instance refresh to
// immediately begin the process of updating instances in the group. If successful,
// the request's response contains a unique ID that you can use to track the
// progress of the instance refresh. To query its status, call the
// DescribeInstanceRefreshes API. To describe the instance refreshes that have
// already run, call the DescribeInstanceRefreshes API. To cancel an instance
// refresh that is in progress, use the CancelInstanceRefresh API. An instance
// refresh might fail for several reasons, such as EC2 launch failures,
// misconfigured health checks, or not ignoring or allowing the termination of
// instances that are in Standby state or protected from scale in. You can monitor
// for failed EC2 launches using the scaling activities. To find the scaling
// activities, call the DescribeScalingActivities API. If you enable auto
// rollback, your Auto Scaling group will be rolled back automatically when the
// instance refresh fails. You can enable this feature before starting an instance
// refresh by specifying the AutoRollback property in the instance refresh
// preferences. Otherwise, to roll back an instance refresh before it finishes, use
// the RollbackInstanceRefresh API.
func (c *Client) StartInstanceRefresh(ctx context.Context, params *StartInstanceRefreshInput, optFns ...func(*Options)) (*StartInstanceRefreshOutput, error) {
if params == nil {
params = &StartInstanceRefreshInput{}
}
result, metadata, err := c.invokeOperation(ctx, "StartInstanceRefresh", params, optFns, c.addOperationStartInstanceRefreshMiddlewares)
if err != nil {
return nil, err
}
out := result.(*StartInstanceRefreshOutput)
out.ResultMetadata = metadata
return out, nil
}
type StartInstanceRefreshInput struct {
// The name of the Auto Scaling group.
//
// This member is required.
AutoScalingGroupName *string
// The desired configuration. For example, the desired configuration can specify a
// new launch template or a new version of the current launch template. Once the
// instance refresh succeeds, Amazon EC2 Auto Scaling updates the settings of the
// Auto Scaling group to reflect the new desired configuration. When you specify a
// new launch template or a new version of the current launch template for your
// desired configuration, consider enabling the SkipMatching property in
// preferences. If it's enabled, Amazon EC2 Auto Scaling skips replacing instances
// that already use the specified launch template and instance types. This can help
// you reduce the number of replacements that are required to apply updates.
DesiredConfiguration *types.DesiredConfiguration
// Sets your preferences for the instance refresh so that it performs as expected
// when you start it. Includes the instance warmup time, the minimum and maximum
// healthy percentages, and the behaviors that you want Amazon EC2 Auto Scaling to
// use if instances that are in Standby state or protected from scale in are
// found. You can also choose to enable additional features, such as the following:
//
// - Auto rollback
// - Checkpoints
// - CloudWatch alarms
// - Skip matching
Preferences *types.RefreshPreferences
// The strategy to use for the instance refresh. The only valid value is Rolling .
Strategy types.RefreshStrategy
noSmithyDocumentSerde
}
type StartInstanceRefreshOutput struct {
// A unique ID for tracking the progress of the instance refresh.
InstanceRefreshId *string
// Metadata pertaining to the operation's result.
ResultMetadata middleware.Metadata
noSmithyDocumentSerde
}
func (c *Client) addOperationStartInstanceRefreshMiddlewares(stack *middleware.Stack, options Options) (err error) {
if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
return err
}
err = stack.Serialize.Add(&awsAwsquery_serializeOpStartInstanceRefresh{}, middleware.After)
if err != nil {
return err
}
err = stack.Deserialize.Add(&awsAwsquery_deserializeOpStartInstanceRefresh{}, middleware.After)
if err != nil {
return err
}
if err := addProtocolFinalizerMiddlewares(stack, options, "StartInstanceRefresh"); err != nil {
return fmt.Errorf("add protocol finalizers: %v", err)
}
if err = addlegacyEndpointContextSetter(stack, options); err != nil {
return err
}
if err = addSetLoggerMiddleware(stack, options); err != nil {
return err
}
if err = addClientRequestID(stack); err != nil {
return err
}
if err = addComputeContentLength(stack); err != nil {
return err
}
if err = addResolveEndpointMiddleware(stack, options); err != nil {
return err
}
if err = addComputePayloadSHA256(stack); err != nil {
return err
}
if err = addRetry(stack, options); err != nil {
return err
}
if err = addRawResponseToMetadata(stack); err != nil {
return err
}
if err = addRecordResponseTiming(stack); err != nil {
return err
}
if err = addClientUserAgent(stack, options); err != nil {
return err
}
if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
return err
}
if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
return err
}
if err = addOpStartInstanceRefreshValidationMiddleware(stack); err != nil {
return err
}
if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartInstanceRefresh(options.Region), middleware.Before); err != nil {
return err
}
if err = addRecursionDetection(stack); err != nil {
return err
}
if err = addRequestIDRetrieverMiddleware(stack); err != nil {
return err
}
if err = addResponseErrorMiddleware(stack); err != nil {
return err
}
if err = addRequestResponseLogging(stack, options); err != nil {
return err
}
if err = addDisableHTTPSMiddleware(stack, options); err != nil {
return err
}
return nil
}
func newServiceMetadataMiddleware_opStartInstanceRefresh(region string) *awsmiddleware.RegisterServiceMetadata {
return &awsmiddleware.RegisterServiceMetadata{
Region: region,
ServiceID: ServiceID,
OperationName: "StartInstanceRefresh",
}
}