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 a snapshot of a block storage disk. You can use snapshots for backups, 15// to make copies of disks, and to save data before shutting down a Lightsail 16// instance. You can take a snapshot of an attached disk that is in use; however, 17// snapshots only capture data that has been written to your disk at the time the 18// snapshot command is issued. This may exclude any data that has been cached by 19// any applications or the operating system. If you can pause any file systems on 20// the disk long enough to take a snapshot, your snapshot should be complete. 21// Nevertheless, if you cannot pause all file writes to the disk, you should 22// unmount the disk from within the Lightsail instance, issue the create disk 23// snapshot command, and then remount the disk to ensure a consistent and complete 24// snapshot. You may remount and use your disk while the snapshot status is 25// pending. You can also use this operation to create a snapshot of an instance's 26// system volume. You might want to do this, for example, to recover data from the 27// system volume of a botched instance or to create a backup of the system volume 28// like you would for a block storage disk. To create a snapshot of a system 29// volume, just define the instance name parameter when issuing the snapshot 30// command, and a snapshot of the defined instance's system volume will be created. 31// After the snapshot is available, you can create a block storage disk from the 32// snapshot and attach it to a running instance to access the data on the disk. The 33// create disk snapshot operation supports tag-based access control via request 34// tags. For more information, see the Amazon Lightsail Developer Guide 35// (https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-controlling-access-using-tags). 36func (c *Client) CreateDiskSnapshot(ctx context.Context, params *CreateDiskSnapshotInput, optFns ...func(*Options)) (*CreateDiskSnapshotOutput, error) { 37 if params == nil { 38 params = &CreateDiskSnapshotInput{} 39 } 40 41 result, metadata, err := c.invokeOperation(ctx, "CreateDiskSnapshot", params, optFns, c.addOperationCreateDiskSnapshotMiddlewares) 42 if err != nil { 43 return nil, err 44 } 45 46 out := result.(*CreateDiskSnapshotOutput) 47 out.ResultMetadata = metadata 48 return out, nil 49} 50 51type CreateDiskSnapshotInput struct { 52 53 // The name of the destination disk snapshot (e.g., my-disk-snapshot) based on the 54 // source disk. 55 // 56 // This member is required. 57 DiskSnapshotName *string 58 59 // The unique name of the source disk (e.g., Disk-Virginia-1). This parameter 60 // cannot be defined together with the instance name parameter. The disk name and 61 // instance name parameters are mutually exclusive. 62 DiskName *string 63 64 // The unique name of the source instance (e.g., Amazon_Linux-512MB-Virginia-1). 65 // When this is defined, a snapshot of the instance's system volume is created. 66 // This parameter cannot be defined together with the disk name parameter. The 67 // instance name and disk name parameters are mutually exclusive. 68 InstanceName *string 69 70 // The tag keys and optional values to add to the resource during create. Use the 71 // TagResource action to tag a resource after it's created. 72 Tags []types.Tag 73 74 noSmithyDocumentSerde 75} 76 77type CreateDiskSnapshotOutput struct { 78 79 // An array of objects that describe the result of the action, such as the status 80 // of the request, the timestamp of the request, and the resources affected by the 81 // request. 82 Operations []types.Operation 83 84 // Metadata pertaining to the operation's result. 85 ResultMetadata middleware.Metadata 86 87 noSmithyDocumentSerde 88} 89 90func (c *Client) addOperationCreateDiskSnapshotMiddlewares(stack *middleware.Stack, options Options) (err error) { 91 err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateDiskSnapshot{}, middleware.After) 92 if err != nil { 93 return err 94 } 95 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateDiskSnapshot{}, middleware.After) 96 if err != nil { 97 return err 98 } 99 if err = addSetLoggerMiddleware(stack, options); err != nil { 100 return err 101 } 102 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 103 return err 104 } 105 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 106 return err 107 } 108 if err = addResolveEndpointMiddleware(stack, options); err != nil { 109 return err 110 } 111 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 112 return err 113 } 114 if err = addRetryMiddlewares(stack, options); err != nil { 115 return err 116 } 117 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 118 return err 119 } 120 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 121 return err 122 } 123 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 124 return err 125 } 126 if err = addClientUserAgent(stack); err != nil { 127 return err 128 } 129 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 130 return err 131 } 132 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 133 return err 134 } 135 if err = addOpCreateDiskSnapshotValidationMiddleware(stack); err != nil { 136 return err 137 } 138 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateDiskSnapshot(options.Region), middleware.Before); err != nil { 139 return err 140 } 141 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 142 return err 143 } 144 if err = addResponseErrorMiddleware(stack); err != nil { 145 return err 146 } 147 if err = addRequestResponseLogging(stack, options); err != nil { 148 return err 149 } 150 return nil 151} 152 153func newServiceMetadataMiddleware_opCreateDiskSnapshot(region string) *awsmiddleware.RegisterServiceMetadata { 154 return &awsmiddleware.RegisterServiceMetadata{ 155 Region: region, 156 ServiceID: ServiceID, 157 SigningName: "lightsail", 158 OperationName: "CreateDiskSnapshot", 159 } 160} 161