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 // Creates one or more new instances from a manual or automatic snapshot of an
15 // instance.
16 //
17 // The create instances from snapshot operation supports tag-based access control
18 // via request tags and resource tags applied to the resource identified by
19 // instance snapshot name . For more information, see the [Amazon Lightsail Developer Guide].
20 //
21 // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-controlling-access-using-tags
22 func (c *Client) CreateInstancesFromSnapshot(ctx context.Context, params *CreateInstancesFromSnapshotInput, optFns ...func(*Options)) (*CreateInstancesFromSnapshotOutput, error) {
23 if params == nil {
24 params = &CreateInstancesFromSnapshotInput{}
25 }
26 27 result, metadata, err := c.invokeOperation(ctx, "CreateInstancesFromSnapshot", params, optFns, c.addOperationCreateInstancesFromSnapshotMiddlewares)
28 if err != nil {
29 return nil, err
30 }
31 32 out := result.(*CreateInstancesFromSnapshotOutput)
33 out.ResultMetadata = metadata
34 return out, nil
35 }
36 37 type CreateInstancesFromSnapshotInput struct {
38 39 // The Availability Zone where you want to create your instances. Use the
40 // following formatting: us-east-2a (case sensitive). You can get a list of
41 // Availability Zones by using the [get regions]operation. Be sure to add the include
42 // Availability Zones parameter to your request.
43 //
44 // [get regions]: http://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetRegions.html
45 //
46 // This member is required.
47 AvailabilityZone *string
48 49 // The bundle of specification information for your virtual private server (or
50 // instance), including the pricing plan ( micro_x_x ).
51 //
52 // This member is required.
53 BundleId *string
54 55 // The names for your new instances.
56 //
57 // This member is required.
58 InstanceNames []string
59 60 // An array of objects representing the add-ons to enable for the new instance.
61 AddOns []types.AddOnRequest
62 63 // An object containing information about one or more disk mappings.
64 AttachedDiskMapping map[string][]types.DiskMap
65 66 // The name of the instance snapshot on which you are basing your new instances.
67 // Use the get instance snapshots operation to return information about your
68 // existing snapshots.
69 //
70 // Constraint:
71 //
72 // - This parameter cannot be defined together with the source instance name
73 // parameter. The instance snapshot name and source instance name parameters are
74 // mutually exclusive.
75 InstanceSnapshotName *string
76 77 // The IP address type for the instance.
78 //
79 // The possible values are ipv4 for IPv4 only, ipv6 for IPv6 only, and dualstack
80 // for IPv4 and IPv6.
81 //
82 // The default value is dualstack .
83 IpAddressType types.IpAddressType
84 85 // The name for your key pair.
86 KeyPairName *string
87 88 // The date of the automatic snapshot to use for the new instance. Use the get
89 // auto snapshots operation to identify the dates of the available automatic
90 // snapshots.
91 //
92 // Constraints:
93 //
94 // - Must be specified in YYYY-MM-DD format.
95 //
96 // - This parameter cannot be defined together with the use latest restorable
97 // auto snapshot parameter. The restore date and use latest restorable auto
98 // snapshot parameters are mutually exclusive.
99 //
100 // - Define this parameter only when creating a new instance from an automatic
101 // snapshot. For more information, see the [Amazon Lightsail Developer Guide].
102 //
103 // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-configuring-automatic-snapshots
104 RestoreDate *string
105 106 // The name of the source instance from which the source automatic snapshot was
107 // created.
108 //
109 // Constraints:
110 //
111 // - This parameter cannot be defined together with the instance snapshot name
112 // parameter. The source instance name and instance snapshot name parameters are
113 // mutually exclusive.
114 //
115 // - Define this parameter only when creating a new instance from an automatic
116 // snapshot. For more information, see the [Amazon Lightsail Developer Guide].
117 //
118 // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-configuring-automatic-snapshots
119 SourceInstanceName *string
120 121 // The tag keys and optional values to add to the resource during create.
122 //
123 // Use the TagResource action to tag a resource after it's created.
124 Tags []types.Tag
125 126 // A Boolean value to indicate whether to use the latest available automatic
127 // snapshot.
128 //
129 // Constraints:
130 //
131 // - This parameter cannot be defined together with the restore date parameter.
132 // The use latest restorable auto snapshot and restore date parameters are
133 // mutually exclusive.
134 //
135 // - Define this parameter only when creating a new instance from an automatic
136 // snapshot. For more information, see the [Amazon Lightsail Developer Guide].
137 //
138 // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-configuring-automatic-snapshots
139 UseLatestRestorableAutoSnapshot *bool
140 141 // You can create a launch script that configures a server with additional user
142 // data. For example, apt-get -y update .
143 //
144 // Depending on the machine image you choose, the command to get software on your
145 // instance varies. Amazon Linux and CentOS use yum , Debian and Ubuntu use apt-get
146 // , and FreeBSD uses pkg . For a complete list, see the [Amazon Lightsail Developer Guide].
147 //
148 // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/compare-options-choose-lightsail-instance-image
149 UserData *string
150 151 noSmithyDocumentSerde
152 }
153 154 type CreateInstancesFromSnapshotOutput struct {
155 156 // An array of objects that describe the result of the action, such as the status
157 // of the request, the timestamp of the request, and the resources affected by the
158 // request.
159 Operations []types.Operation
160 161 // Metadata pertaining to the operation's result.
162 ResultMetadata middleware.Metadata
163 164 noSmithyDocumentSerde
165 }
166 167 func (c *Client) addOperationCreateInstancesFromSnapshotMiddlewares(stack *middleware.Stack, options Options) (err error) {
168 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
169 return err
170 }
171 err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateInstancesFromSnapshot{}, middleware.After)
172 if err != nil {
173 return err
174 }
175 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateInstancesFromSnapshot{}, middleware.After)
176 if err != nil {
177 return err
178 }
179 if err := addProtocolFinalizerMiddlewares(stack, options, "CreateInstancesFromSnapshot"); err != nil {
180 return fmt.Errorf("add protocol finalizers: %v", err)
181 }
182 183 if err = addlegacyEndpointContextSetter(stack, options); err != nil {
184 return err
185 }
186 if err = addSetLoggerMiddleware(stack, options); err != nil {
187 return err
188 }
189 if err = addClientRequestID(stack); err != nil {
190 return err
191 }
192 if err = addComputeContentLength(stack); err != nil {
193 return err
194 }
195 if err = addResolveEndpointMiddleware(stack, options); err != nil {
196 return err
197 }
198 if err = addComputePayloadSHA256(stack); err != nil {
199 return err
200 }
201 if err = addRetry(stack, options); err != nil {
202 return err
203 }
204 if err = addRawResponseToMetadata(stack); err != nil {
205 return err
206 }
207 if err = addRecordResponseTiming(stack); err != nil {
208 return err
209 }
210 if err = addSpanRetryLoop(stack, options); err != nil {
211 return err
212 }
213 if err = addClientUserAgent(stack, options); err != nil {
214 return err
215 }
216 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
217 return err
218 }
219 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
220 return err
221 }
222 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
223 return err
224 }
225 if err = addTimeOffsetBuild(stack, c); err != nil {
226 return err
227 }
228 if err = addUserAgentRetryMode(stack, options); err != nil {
229 return err
230 }
231 if err = addCredentialSource(stack, options); err != nil {
232 return err
233 }
234 if err = addOpCreateInstancesFromSnapshotValidationMiddleware(stack); err != nil {
235 return err
236 }
237 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateInstancesFromSnapshot(options.Region), middleware.Before); err != nil {
238 return err
239 }
240 if err = addRecursionDetection(stack); err != nil {
241 return err
242 }
243 if err = addRequestIDRetrieverMiddleware(stack); err != nil {
244 return err
245 }
246 if err = addResponseErrorMiddleware(stack); err != nil {
247 return err
248 }
249 if err = addRequestResponseLogging(stack, options); err != nil {
250 return err
251 }
252 if err = addDisableHTTPSMiddleware(stack, options); err != nil {
253 return err
254 }
255 if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
256 return err
257 }
258 if err = addInterceptAttempt(stack, options); err != nil {
259 return err
260 }
261 if err = addInterceptors(stack, options); err != nil {
262 return err
263 }
264 return nil
265 }
266 267 func newServiceMetadataMiddleware_opCreateInstancesFromSnapshot(region string) *awsmiddleware.RegisterServiceMetadata {
268 return &awsmiddleware.RegisterServiceMetadata{
269 Region: region,
270 ServiceID: ServiceID,
271 OperationName: "CreateInstancesFromSnapshot",
272 }
273 }
274