api_op_AttachInstancesToLoadBalancer.go raw
1 // Code generated by smithy-go-codegen DO NOT EDIT.
2
3 package lightsail
4
5 import (
6 "context"
7 "fmt"
8 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
9 "github.com/aws/aws-sdk-go-v2/service/lightsail/types"
10 "github.com/aws/smithy-go/middleware"
11 smithyhttp "github.com/aws/smithy-go/transport/http"
12 )
13
14 // Attaches one or more Lightsail instances to a load balancer.
15 //
16 // After some time, the instances are attached to the load balancer and the health
17 // check status is available.
18 //
19 // The attach instances to load balancer operation supports tag-based access
20 // control via resource tags applied to the resource identified by load balancer
21 // name . For more information, see the [Lightsail Developer Guide].
22 //
23 // [Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-controlling-access-using-tags
24 func (c *Client) AttachInstancesToLoadBalancer(ctx context.Context, params *AttachInstancesToLoadBalancerInput, optFns ...func(*Options)) (*AttachInstancesToLoadBalancerOutput, error) {
25 if params == nil {
26 params = &AttachInstancesToLoadBalancerInput{}
27 }
28
29 result, metadata, err := c.invokeOperation(ctx, "AttachInstancesToLoadBalancer", params, optFns, c.addOperationAttachInstancesToLoadBalancerMiddlewares)
30 if err != nil {
31 return nil, err
32 }
33
34 out := result.(*AttachInstancesToLoadBalancerOutput)
35 out.ResultMetadata = metadata
36 return out, nil
37 }
38
39 type AttachInstancesToLoadBalancerInput struct {
40
41 // An array of strings representing the instance name(s) you want to attach to
42 // your load balancer.
43 //
44 // An instance must be running before you can attach it to your load balancer.
45 //
46 // There are no additional limits on the number of instances you can attach to
47 // your load balancer, aside from the limit of Lightsail instances you can create
48 // in your account (20).
49 //
50 // This member is required.
51 InstanceNames []string
52
53 // The name of the load balancer.
54 //
55 // This member is required.
56 LoadBalancerName *string
57
58 noSmithyDocumentSerde
59 }
60
61 type AttachInstancesToLoadBalancerOutput struct {
62
63 // An array of objects that describe the result of the action, such as the status
64 // of the request, the timestamp of the request, and the resources affected by the
65 // request.
66 Operations []types.Operation
67
68 // Metadata pertaining to the operation's result.
69 ResultMetadata middleware.Metadata
70
71 noSmithyDocumentSerde
72 }
73
74 func (c *Client) addOperationAttachInstancesToLoadBalancerMiddlewares(stack *middleware.Stack, options Options) (err error) {
75 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
76 return err
77 }
78 err = stack.Serialize.Add(&awsAwsjson11_serializeOpAttachInstancesToLoadBalancer{}, middleware.After)
79 if err != nil {
80 return err
81 }
82 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpAttachInstancesToLoadBalancer{}, middleware.After)
83 if err != nil {
84 return err
85 }
86 if err := addProtocolFinalizerMiddlewares(stack, options, "AttachInstancesToLoadBalancer"); err != nil {
87 return fmt.Errorf("add protocol finalizers: %v", err)
88 }
89
90 if err = addlegacyEndpointContextSetter(stack, options); err != nil {
91 return err
92 }
93 if err = addSetLoggerMiddleware(stack, options); err != nil {
94 return err
95 }
96 if err = addClientRequestID(stack); err != nil {
97 return err
98 }
99 if err = addComputeContentLength(stack); err != nil {
100 return err
101 }
102 if err = addResolveEndpointMiddleware(stack, options); err != nil {
103 return err
104 }
105 if err = addComputePayloadSHA256(stack); err != nil {
106 return err
107 }
108 if err = addRetry(stack, options); err != nil {
109 return err
110 }
111 if err = addRawResponseToMetadata(stack); err != nil {
112 return err
113 }
114 if err = addRecordResponseTiming(stack); err != nil {
115 return err
116 }
117 if err = addSpanRetryLoop(stack, options); err != nil {
118 return err
119 }
120 if err = addClientUserAgent(stack, options); err != nil {
121 return err
122 }
123 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
124 return err
125 }
126 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
127 return err
128 }
129 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
130 return err
131 }
132 if err = addTimeOffsetBuild(stack, c); err != nil {
133 return err
134 }
135 if err = addUserAgentRetryMode(stack, options); err != nil {
136 return err
137 }
138 if err = addCredentialSource(stack, options); err != nil {
139 return err
140 }
141 if err = addOpAttachInstancesToLoadBalancerValidationMiddleware(stack); err != nil {
142 return err
143 }
144 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opAttachInstancesToLoadBalancer(options.Region), middleware.Before); err != nil {
145 return err
146 }
147 if err = addRecursionDetection(stack); err != nil {
148 return err
149 }
150 if err = addRequestIDRetrieverMiddleware(stack); err != nil {
151 return err
152 }
153 if err = addResponseErrorMiddleware(stack); err != nil {
154 return err
155 }
156 if err = addRequestResponseLogging(stack, options); err != nil {
157 return err
158 }
159 if err = addDisableHTTPSMiddleware(stack, options); err != nil {
160 return err
161 }
162 if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
163 return err
164 }
165 if err = addInterceptAttempt(stack, options); err != nil {
166 return err
167 }
168 if err = addInterceptors(stack, options); err != nil {
169 return err
170 }
171 return nil
172 }
173
174 func newServiceMetadataMiddleware_opAttachInstancesToLoadBalancer(region string) *awsmiddleware.RegisterServiceMetadata {
175 return &awsmiddleware.RegisterServiceMetadata{
176 Region: region,
177 ServiceID: ServiceID,
178 OperationName: "AttachInstancesToLoadBalancer",
179 }
180 }
181