1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package ec2 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/ec2/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Starts an Amazon EBS-backed instance that you've previously stopped. Instances 15// that use Amazon EBS volumes as their root devices can be quickly stopped and 16// started. When an instance is stopped, the compute resources are released and you 17// are not billed for instance usage. However, your root partition Amazon EBS 18// volume remains and continues to persist your data, and you are charged for 19// Amazon EBS volume usage. You can restart your instance at any time. Every time 20// you start your Windows instance, Amazon EC2 charges you for a full instance 21// hour. If you stop and restart your Windows instance, a new instance hour begins 22// and Amazon EC2 charges you for another full instance hour even if you are still 23// within the same 60-minute period when it was stopped. Every time you start your 24// Linux instance, Amazon EC2 charges a one-minute minimum for instance usage, and 25// thereafter charges per second for instance usage. Before stopping an instance, 26// make sure it is in a state from which it can be restarted. Stopping an instance 27// does not preserve data stored in RAM. Performing this operation on an instance 28// that uses an instance store as its root device returns an error. For more 29// information, see Stopping instances 30// (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Stop_Start.html) in the 31// Amazon EC2 User Guide. 32func (c *Client) StartInstances(ctx context.Context, params *StartInstancesInput, optFns ...func(*Options)) (*StartInstancesOutput, error) { 33 if params == nil { 34 params = &StartInstancesInput{} 35 } 36 37 result, metadata, err := c.invokeOperation(ctx, "StartInstances", params, optFns, addOperationStartInstancesMiddlewares) 38 if err != nil { 39 return nil, err 40 } 41 42 out := result.(*StartInstancesOutput) 43 out.ResultMetadata = metadata 44 return out, nil 45} 46 47type StartInstancesInput struct { 48 49 // The IDs of the instances. 50 // 51 // This member is required. 52 InstanceIds []string 53 54 // Reserved. 55 AdditionalInfo *string 56 57 // Checks whether you have the required permissions for the action, without 58 // actually making the request, and provides an error response. If you have the 59 // required permissions, the error response is DryRunOperation. Otherwise, it is 60 // UnauthorizedOperation. 61 DryRun bool 62} 63 64type StartInstancesOutput struct { 65 66 // Information about the started instances. 67 StartingInstances []types.InstanceStateChange 68 69 // Metadata pertaining to the operation's result. 70 ResultMetadata middleware.Metadata 71} 72 73func addOperationStartInstancesMiddlewares(stack *middleware.Stack, options Options) (err error) { 74 err = stack.Serialize.Add(&awsEc2query_serializeOpStartInstances{}, middleware.After) 75 if err != nil { 76 return err 77 } 78 err = stack.Deserialize.Add(&awsEc2query_deserializeOpStartInstances{}, middleware.After) 79 if err != nil { 80 return err 81 } 82 if err = addSetLoggerMiddleware(stack, options); err != nil { 83 return err 84 } 85 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 86 return err 87 } 88 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 89 return err 90 } 91 if err = addResolveEndpointMiddleware(stack, options); err != nil { 92 return err 93 } 94 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 95 return err 96 } 97 if err = addRetryMiddlewares(stack, options); err != nil { 98 return err 99 } 100 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 101 return err 102 } 103 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 104 return err 105 } 106 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 107 return err 108 } 109 if err = addClientUserAgent(stack); err != nil { 110 return err 111 } 112 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 113 return err 114 } 115 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 116 return err 117 } 118 if err = addOpStartInstancesValidationMiddleware(stack); err != nil { 119 return err 120 } 121 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStartInstances(options.Region), middleware.Before); err != nil { 122 return err 123 } 124 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 125 return err 126 } 127 if err = addResponseErrorMiddleware(stack); err != nil { 128 return err 129 } 130 if err = addRequestResponseLogging(stack, options); err != nil { 131 return err 132 } 133 return nil 134} 135 136func newServiceMetadataMiddleware_opStartInstances(region string) *awsmiddleware.RegisterServiceMetadata { 137 return &awsmiddleware.RegisterServiceMetadata{ 138 Region: region, 139 ServiceID: ServiceID, 140 SigningName: "ec2", 141 OperationName: "StartInstances", 142 } 143} 144