1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package lightsail 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/lightsail/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Creates one or more Amazon Lightsail instances. The create instances operation 15// supports tag-based access control via request tags. For more information, see 16// the Lightsail Dev Guide 17// (https://lightsail.aws.amazon.com/ls/docs/en/articles/amazon-lightsail-controlling-access-using-tags). 18func (c *Client) CreateInstances(ctx context.Context, params *CreateInstancesInput, optFns ...func(*Options)) (*CreateInstancesOutput, error) { 19 if params == nil { 20 params = &CreateInstancesInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "CreateInstances", params, optFns, addOperationCreateInstancesMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*CreateInstancesOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33type CreateInstancesInput struct { 34 35 // The Availability Zone in which to create your instance. Use the following 36 // format: us-east-2a (case sensitive). You can get a list of Availability Zones by 37 // using the get regions 38 // (http://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetRegions.html) 39 // operation. Be sure to add the include Availability Zones parameter to your 40 // request. 41 // 42 // This member is required. 43 AvailabilityZone *string 44 45 // The ID for a virtual private server image (e.g., app_wordpress_4_4 or 46 // app_lamp_7_0). Use the get blueprints operation to return a list of available 47 // images (or blueprints). Use active blueprints when creating new instances. 48 // Inactive blueprints are listed to support customers with existing instances and 49 // are not necessarily available to create new instances. Blueprints are marked 50 // inactive when they become outdated due to operating system updates or new 51 // application releases. 52 // 53 // This member is required. 54 BlueprintId *string 55 56 // The bundle of specification information for your virtual private server (or 57 // instance), including the pricing plan (e.g., micro_1_0). 58 // 59 // This member is required. 60 BundleId *string 61 62 // The names to use for your new Lightsail instances. Separate multiple values 63 // using quotation marks and commas, for example: 64 // ["MyFirstInstance","MySecondInstance"] 65 // 66 // This member is required. 67 InstanceNames []string 68 69 // An array of objects representing the add-ons to enable for the new instance. 70 AddOns []types.AddOnRequest 71 72 // (Deprecated) The name for your custom image. In releases prior to June 12, 2017, 73 // this parameter was ignored by the API. It is now deprecated. 74 // 75 // Deprecated: This member has been deprecated. 76 CustomImageName *string 77 78 // The IP address type for the instance. The possible values are ipv4 for IPv4 79 // only, and dualstack for IPv4 and IPv6. The default value is dualstack. 80 IpAddressType types.IpAddressType 81 82 // The name of your key pair. 83 KeyPairName *string 84 85 // The tag keys and optional values to add to the resource during create. Use the 86 // TagResource action to tag a resource after it's created. 87 Tags []types.Tag 88 89 // A launch script you can create that configures a server with additional user 90 // data. For example, you might want to run apt-get -y update. Depending on the 91 // machine image you choose, the command to get software on your instance varies. 92 // Amazon Linux and CentOS use yum, Debian and Ubuntu use apt-get, and FreeBSD uses 93 // pkg. For a complete list, see the Dev Guide 94 // (https://lightsail.aws.amazon.com/ls/docs/getting-started/article/compare-options-choose-lightsail-instance-image). 95 UserData *string 96} 97 98type CreateInstancesOutput struct { 99 100 // An array of objects that describe the result of the action, such as the status 101 // of the request, the timestamp of the request, and the resources affected by the 102 // request. 103 Operations []types.Operation 104 105 // Metadata pertaining to the operation's result. 106 ResultMetadata middleware.Metadata 107} 108 109func addOperationCreateInstancesMiddlewares(stack *middleware.Stack, options Options) (err error) { 110 err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateInstances{}, middleware.After) 111 if err != nil { 112 return err 113 } 114 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateInstances{}, middleware.After) 115 if err != nil { 116 return err 117 } 118 if err = addSetLoggerMiddleware(stack, options); err != nil { 119 return err 120 } 121 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 122 return err 123 } 124 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 125 return err 126 } 127 if err = addResolveEndpointMiddleware(stack, options); err != nil { 128 return err 129 } 130 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 131 return err 132 } 133 if err = addRetryMiddlewares(stack, options); err != nil { 134 return err 135 } 136 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 137 return err 138 } 139 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 140 return err 141 } 142 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 143 return err 144 } 145 if err = addClientUserAgent(stack); err != nil { 146 return err 147 } 148 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 149 return err 150 } 151 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 152 return err 153 } 154 if err = addOpCreateInstancesValidationMiddleware(stack); err != nil { 155 return err 156 } 157 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateInstances(options.Region), middleware.Before); err != nil { 158 return err 159 } 160 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 161 return err 162 } 163 if err = addResponseErrorMiddleware(stack); err != nil { 164 return err 165 } 166 if err = addRequestResponseLogging(stack, options); err != nil { 167 return err 168 } 169 return nil 170} 171 172func newServiceMetadataMiddleware_opCreateInstances(region string) *awsmiddleware.RegisterServiceMetadata { 173 return &awsmiddleware.RegisterServiceMetadata{ 174 Region: region, 175 ServiceID: ServiceID, 176 SigningName: "lightsail", 177 OperationName: "CreateInstances", 178 } 179} 180