api_op_CreateLoadBalancer.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 a Lightsail load balancer. To learn more about deciding whether to load
  15  // balance your application, see [Configure your Lightsail instances for load balancing]. You can create up to 10 load balancers per AWS
  16  // Region in your account.
  17  //
  18  // When you create a load balancer, you can specify a unique name and port
  19  // settings. To change additional load balancer settings, use the
  20  // UpdateLoadBalancerAttribute operation.
  21  //
  22  // The create load balancer operation supports tag-based access control via
  23  // request tags. For more information, see the [Amazon Lightsail Developer Guide].
  24  //
  25  // [Configure your Lightsail instances for load balancing]: https://docs.aws.amazon.com/lightsail/latest/userguide/configure-lightsail-instances-for-load-balancing
  26  // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-controlling-access-using-tags
  27  func (c *Client) CreateLoadBalancer(ctx context.Context, params *CreateLoadBalancerInput, optFns ...func(*Options)) (*CreateLoadBalancerOutput, error) {
  28  	if params == nil {
  29  		params = &CreateLoadBalancerInput{}
  30  	}
  31  
  32  	result, metadata, err := c.invokeOperation(ctx, "CreateLoadBalancer", params, optFns, c.addOperationCreateLoadBalancerMiddlewares)
  33  	if err != nil {
  34  		return nil, err
  35  	}
  36  
  37  	out := result.(*CreateLoadBalancerOutput)
  38  	out.ResultMetadata = metadata
  39  	return out, nil
  40  }
  41  
  42  type CreateLoadBalancerInput struct {
  43  
  44  	// The instance port where you're creating your load balancer.
  45  	//
  46  	// This member is required.
  47  	InstancePort int32
  48  
  49  	// The name of your load balancer.
  50  	//
  51  	// This member is required.
  52  	LoadBalancerName *string
  53  
  54  	// The optional alternative domains and subdomains to use with your SSL/TLS
  55  	// certificate ( www.example.com , example.com , m.example.com , blog.example.com ).
  56  	CertificateAlternativeNames []string
  57  
  58  	// The domain name with which your certificate is associated ( example.com ).
  59  	//
  60  	// If you specify certificateDomainName , then certificateName is required (and
  61  	// vice-versa).
  62  	CertificateDomainName *string
  63  
  64  	// The name of the SSL/TLS certificate.
  65  	//
  66  	// If you specify certificateName , then certificateDomainName is required (and
  67  	// vice-versa).
  68  	CertificateName *string
  69  
  70  	// The path you provided to perform the load balancer health check. If you didn't
  71  	// specify a health check path, Lightsail uses the root path of your website ( "/"
  72  	// ).
  73  	//
  74  	// You may want to specify a custom health check path other than the root of your
  75  	// application if your home page loads slowly or has a lot of media or scripting on
  76  	// it.
  77  	HealthCheckPath *string
  78  
  79  	// The IP address type for the load balancer.
  80  	//
  81  	// The possible values are ipv4 for IPv4 only, ipv6 for IPv6 only, and dualstack
  82  	// for IPv4 and IPv6.
  83  	//
  84  	// The default value is dualstack .
  85  	IpAddressType types.IpAddressType
  86  
  87  	// The tag keys and optional values to add to the resource during create.
  88  	//
  89  	// Use the TagResource action to tag a resource after it's created.
  90  	Tags []types.Tag
  91  
  92  	// The name of the TLS policy to apply to the load balancer.
  93  	//
  94  	// Use the [GetLoadBalancerTlsPolicies] action to get a list of TLS policy names that you can specify.
  95  	//
  96  	// For more information about load balancer TLS policies, see [Configuring TLS security policies on your Amazon Lightsail load balancers] in the Amazon
  97  	// Lightsail Developer Guide.
  98  	//
  99  	// [Configuring TLS security policies on your Amazon Lightsail load balancers]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-configure-load-balancer-tls-security-policy
 100  	// [GetLoadBalancerTlsPolicies]: https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetLoadBalancerTlsPolicies.html
 101  	TlsPolicyName *string
 102  
 103  	noSmithyDocumentSerde
 104  }
 105  
 106  type CreateLoadBalancerOutput struct {
 107  
 108  	// An array of objects that describe the result of the action, such as the status
 109  	// of the request, the timestamp of the request, and the resources affected by the
 110  	// request.
 111  	Operations []types.Operation
 112  
 113  	// Metadata pertaining to the operation's result.
 114  	ResultMetadata middleware.Metadata
 115  
 116  	noSmithyDocumentSerde
 117  }
 118  
 119  func (c *Client) addOperationCreateLoadBalancerMiddlewares(stack *middleware.Stack, options Options) (err error) {
 120  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
 121  		return err
 122  	}
 123  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateLoadBalancer{}, middleware.After)
 124  	if err != nil {
 125  		return err
 126  	}
 127  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateLoadBalancer{}, middleware.After)
 128  	if err != nil {
 129  		return err
 130  	}
 131  	if err := addProtocolFinalizerMiddlewares(stack, options, "CreateLoadBalancer"); err != nil {
 132  		return fmt.Errorf("add protocol finalizers: %v", err)
 133  	}
 134  
 135  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
 136  		return err
 137  	}
 138  	if err = addSetLoggerMiddleware(stack, options); err != nil {
 139  		return err
 140  	}
 141  	if err = addClientRequestID(stack); err != nil {
 142  		return err
 143  	}
 144  	if err = addComputeContentLength(stack); err != nil {
 145  		return err
 146  	}
 147  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 148  		return err
 149  	}
 150  	if err = addComputePayloadSHA256(stack); err != nil {
 151  		return err
 152  	}
 153  	if err = addRetry(stack, options); err != nil {
 154  		return err
 155  	}
 156  	if err = addRawResponseToMetadata(stack); err != nil {
 157  		return err
 158  	}
 159  	if err = addRecordResponseTiming(stack); err != nil {
 160  		return err
 161  	}
 162  	if err = addSpanRetryLoop(stack, options); err != nil {
 163  		return err
 164  	}
 165  	if err = addClientUserAgent(stack, options); err != nil {
 166  		return err
 167  	}
 168  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 169  		return err
 170  	}
 171  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 172  		return err
 173  	}
 174  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 175  		return err
 176  	}
 177  	if err = addTimeOffsetBuild(stack, c); err != nil {
 178  		return err
 179  	}
 180  	if err = addUserAgentRetryMode(stack, options); err != nil {
 181  		return err
 182  	}
 183  	if err = addCredentialSource(stack, options); err != nil {
 184  		return err
 185  	}
 186  	if err = addOpCreateLoadBalancerValidationMiddleware(stack); err != nil {
 187  		return err
 188  	}
 189  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateLoadBalancer(options.Region), middleware.Before); err != nil {
 190  		return err
 191  	}
 192  	if err = addRecursionDetection(stack); err != nil {
 193  		return err
 194  	}
 195  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 196  		return err
 197  	}
 198  	if err = addResponseErrorMiddleware(stack); err != nil {
 199  		return err
 200  	}
 201  	if err = addRequestResponseLogging(stack, options); err != nil {
 202  		return err
 203  	}
 204  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 205  		return err
 206  	}
 207  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 208  		return err
 209  	}
 210  	if err = addInterceptAttempt(stack, options); err != nil {
 211  		return err
 212  	}
 213  	if err = addInterceptors(stack, options); err != nil {
 214  		return err
 215  	}
 216  	return nil
 217  }
 218  
 219  func newServiceMetadataMiddleware_opCreateLoadBalancer(region string) *awsmiddleware.RegisterServiceMetadata {
 220  	return &awsmiddleware.RegisterServiceMetadata{
 221  		Region:        region,
 222  		ServiceID:     ServiceID,
 223  		OperationName: "CreateLoadBalancer",
 224  	}
 225  }
 226