api_op_CreateInstances.go raw

   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 Amazon Lightsail instances.
  15  //
  16  // The create instances operation supports tag-based access control via request
  17  // tags. For more information, see the [Lightsail Developer Guide].
  18  //
  19  // [Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-controlling-access-using-tags
  20  func (c *Client) CreateInstances(ctx context.Context, params *CreateInstancesInput, optFns ...func(*Options)) (*CreateInstancesOutput, error) {
  21  	if params == nil {
  22  		params = &CreateInstancesInput{}
  23  	}
  24  
  25  	result, metadata, err := c.invokeOperation(ctx, "CreateInstances", params, optFns, c.addOperationCreateInstancesMiddlewares)
  26  	if err != nil {
  27  		return nil, err
  28  	}
  29  
  30  	out := result.(*CreateInstancesOutput)
  31  	out.ResultMetadata = metadata
  32  	return out, nil
  33  }
  34  
  35  type CreateInstancesInput struct {
  36  
  37  	// The Availability Zone in which to create your instance. Use the following
  38  	// format: us-east-2a (case sensitive). You can get a list of Availability Zones
  39  	// by using the [get regions]operation. Be sure to add the include Availability Zones parameter
  40  	// to your request.
  41  	//
  42  	// [get regions]: http://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetRegions.html
  43  	//
  44  	// This member is required.
  45  	AvailabilityZone *string
  46  
  47  	// The ID for a virtual private server image ( app_wordpress_x_x or app_lamp_x_x ).
  48  	// Use the get blueprints operation to return a list of available images (or
  49  	// blueprints).
  50  	//
  51  	// Use active blueprints when creating new instances. Inactive blueprints are
  52  	// listed to support customers with existing instances and are not necessarily
  53  	// available to create new instances. Blueprints are marked inactive when they
  54  	// become outdated due to operating system updates or new application releases.
  55  	//
  56  	// This member is required.
  57  	BlueprintId *string
  58  
  59  	// The bundle of specification information for your virtual private server (or
  60  	// instance), including the pricing plan ( medium_x_x ).
  61  	//
  62  	// This member is required.
  63  	BundleId *string
  64  
  65  	// The names to use for your new Lightsail instances. Separate multiple values
  66  	// using quotation marks and commas, for example:
  67  	// ["MyFirstInstance","MySecondInstance"]
  68  	//
  69  	// This member is required.
  70  	InstanceNames []string
  71  
  72  	// An array of objects representing the add-ons to enable for the new instance.
  73  	AddOns []types.AddOnRequest
  74  
  75  	// (Discontinued) The name for your custom image.
  76  	//
  77  	// In releases prior to June 12, 2017, this parameter was ignored by the API. It
  78  	// is now discontinued.
  79  	//
  80  	// Deprecated: This member has been deprecated.
  81  	CustomImageName *string
  82  
  83  	// The IP address type for the instance.
  84  	//
  85  	// The possible values are ipv4 for IPv4 only, ipv6 for IPv6 only, and dualstack
  86  	// for IPv4 and IPv6.
  87  	//
  88  	// The default value is dualstack .
  89  	IpAddressType types.IpAddressType
  90  
  91  	// The name of your key pair.
  92  	KeyPairName *string
  93  
  94  	// The tag keys and optional values to add to the resource during create.
  95  	//
  96  	// Use the TagResource action to tag a resource after it's created.
  97  	Tags []types.Tag
  98  
  99  	// A launch script you can create that configures a server with additional user
 100  	// data. For example, you might want to run apt-get -y update .
 101  	//
 102  	// Depending on the machine image you choose, the command to get software on your
 103  	// instance varies. Amazon Linux and CentOS use yum , Debian and Ubuntu use apt-get
 104  	// , and FreeBSD uses pkg . For a complete list, see the [Amazon Lightsail Developer Guide].
 105  	//
 106  	// [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/compare-options-choose-lightsail-instance-image
 107  	UserData *string
 108  
 109  	noSmithyDocumentSerde
 110  }
 111  
 112  type CreateInstancesOutput struct {
 113  
 114  	// An array of objects that describe the result of the action, such as the status
 115  	// of the request, the timestamp of the request, and the resources affected by the
 116  	// request.
 117  	Operations []types.Operation
 118  
 119  	// Metadata pertaining to the operation's result.
 120  	ResultMetadata middleware.Metadata
 121  
 122  	noSmithyDocumentSerde
 123  }
 124  
 125  func (c *Client) addOperationCreateInstancesMiddlewares(stack *middleware.Stack, options Options) (err error) {
 126  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
 127  		return err
 128  	}
 129  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateInstances{}, middleware.After)
 130  	if err != nil {
 131  		return err
 132  	}
 133  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateInstances{}, middleware.After)
 134  	if err != nil {
 135  		return err
 136  	}
 137  	if err := addProtocolFinalizerMiddlewares(stack, options, "CreateInstances"); err != nil {
 138  		return fmt.Errorf("add protocol finalizers: %v", err)
 139  	}
 140  
 141  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
 142  		return err
 143  	}
 144  	if err = addSetLoggerMiddleware(stack, options); err != nil {
 145  		return err
 146  	}
 147  	if err = addClientRequestID(stack); err != nil {
 148  		return err
 149  	}
 150  	if err = addComputeContentLength(stack); err != nil {
 151  		return err
 152  	}
 153  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 154  		return err
 155  	}
 156  	if err = addComputePayloadSHA256(stack); err != nil {
 157  		return err
 158  	}
 159  	if err = addRetry(stack, options); err != nil {
 160  		return err
 161  	}
 162  	if err = addRawResponseToMetadata(stack); err != nil {
 163  		return err
 164  	}
 165  	if err = addRecordResponseTiming(stack); err != nil {
 166  		return err
 167  	}
 168  	if err = addSpanRetryLoop(stack, options); err != nil {
 169  		return err
 170  	}
 171  	if err = addClientUserAgent(stack, options); err != nil {
 172  		return err
 173  	}
 174  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 175  		return err
 176  	}
 177  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 178  		return err
 179  	}
 180  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 181  		return err
 182  	}
 183  	if err = addTimeOffsetBuild(stack, c); err != nil {
 184  		return err
 185  	}
 186  	if err = addUserAgentRetryMode(stack, options); err != nil {
 187  		return err
 188  	}
 189  	if err = addCredentialSource(stack, options); err != nil {
 190  		return err
 191  	}
 192  	if err = addOpCreateInstancesValidationMiddleware(stack); err != nil {
 193  		return err
 194  	}
 195  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateInstances(options.Region), middleware.Before); err != nil {
 196  		return err
 197  	}
 198  	if err = addRecursionDetection(stack); err != nil {
 199  		return err
 200  	}
 201  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 202  		return err
 203  	}
 204  	if err = addResponseErrorMiddleware(stack); err != nil {
 205  		return err
 206  	}
 207  	if err = addRequestResponseLogging(stack, options); err != nil {
 208  		return err
 209  	}
 210  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 211  		return err
 212  	}
 213  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 214  		return err
 215  	}
 216  	if err = addInterceptAttempt(stack, options); err != nil {
 217  		return err
 218  	}
 219  	if err = addInterceptors(stack, options); err != nil {
 220  		return err
 221  	}
 222  	return nil
 223  }
 224  
 225  func newServiceMetadataMiddleware_opCreateInstances(region string) *awsmiddleware.RegisterServiceMetadata {
 226  	return &awsmiddleware.RegisterServiceMetadata{
 227  		Region:        region,
 228  		ServiceID:     ServiceID,
 229  		OperationName: "CreateInstances",
 230  	}
 231  }
 232