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 name of your key pair.
79	KeyPairName *string
80
81	// The tag keys and optional values to add to the resource during create. Use the
82	// TagResource action to tag a resource after it's created.
83	Tags []types.Tag
84
85	// A launch script you can create that configures a server with additional user
86	// data. For example, you might want to run apt-get -y update. Depending on the
87	// machine image you choose, the command to get software on your instance varies.
88	// Amazon Linux and CentOS use yum, Debian and Ubuntu use apt-get, and FreeBSD uses
89	// pkg. For a complete list, see the Dev Guide
90	// (https://lightsail.aws.amazon.com/ls/docs/getting-started/article/compare-options-choose-lightsail-instance-image).
91	UserData *string
92}
93
94type CreateInstancesOutput struct {
95
96	// An array of objects that describe the result of the action, such as the status
97	// of the request, the timestamp of the request, and the resources affected by the
98	// request.
99	Operations []types.Operation
100
101	// Metadata pertaining to the operation's result.
102	ResultMetadata middleware.Metadata
103}
104
105func addOperationCreateInstancesMiddlewares(stack *middleware.Stack, options Options) (err error) {
106	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateInstances{}, middleware.After)
107	if err != nil {
108		return err
109	}
110	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateInstances{}, middleware.After)
111	if err != nil {
112		return err
113	}
114	if err = addSetLoggerMiddleware(stack, options); err != nil {
115		return err
116	}
117	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
118		return err
119	}
120	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
121		return err
122	}
123	if err = addResolveEndpointMiddleware(stack, options); err != nil {
124		return err
125	}
126	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
127		return err
128	}
129	if err = addRetryMiddlewares(stack, options); err != nil {
130		return err
131	}
132	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
133		return err
134	}
135	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
136		return err
137	}
138	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
139		return err
140	}
141	if err = addClientUserAgent(stack); err != nil {
142		return err
143	}
144	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
145		return err
146	}
147	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
148		return err
149	}
150	if err = addOpCreateInstancesValidationMiddleware(stack); err != nil {
151		return err
152	}
153	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateInstances(options.Region), middleware.Before); err != nil {
154		return err
155	}
156	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
157		return err
158	}
159	if err = addResponseErrorMiddleware(stack); err != nil {
160		return err
161	}
162	if err = addRequestResponseLogging(stack, options); err != nil {
163		return err
164	}
165	return nil
166}
167
168func newServiceMetadataMiddleware_opCreateInstances(region string) *awsmiddleware.RegisterServiceMetadata {
169	return &awsmiddleware.RegisterServiceMetadata{
170		Region:        region,
171		ServiceID:     ServiceID,
172		SigningName:   "lightsail",
173		OperationName: "CreateInstances",
174	}
175}
176