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 // Attaches an SSL/TLS certificate to your Amazon Lightsail content delivery
15 // network (CDN) distribution.
16 //
17 // After the certificate is attached, your distribution accepts HTTPS traffic for
18 // all of the domains that are associated with the certificate.
19 //
20 // Use the CreateCertificate action to create a certificate that you can attach to
21 // your distribution.
22 //
23 // Only certificates created in the us-east-1 Amazon Web Services Region can be
24 // attached to Lightsail distributions. Lightsail distributions are global
25 // resources that can reference an origin in any Amazon Web Services Region, and
26 // distribute its content globally. However, all distributions are located in the
27 // us-east-1 Region.
28 func (c *Client) AttachCertificateToDistribution(ctx context.Context, params *AttachCertificateToDistributionInput, optFns ...func(*Options)) (*AttachCertificateToDistributionOutput, error) {
29 if params == nil {
30 params = &AttachCertificateToDistributionInput{}
31 }
32 33 result, metadata, err := c.invokeOperation(ctx, "AttachCertificateToDistribution", params, optFns, c.addOperationAttachCertificateToDistributionMiddlewares)
34 if err != nil {
35 return nil, err
36 }
37 38 out := result.(*AttachCertificateToDistributionOutput)
39 out.ResultMetadata = metadata
40 return out, nil
41 }
42 43 type AttachCertificateToDistributionInput struct {
44 45 // The name of the certificate to attach to a distribution.
46 //
47 // Only certificates with a status of ISSUED can be attached to a distribution.
48 //
49 // Use the GetCertificates action to get a list of certificate names that you can
50 // specify.
51 //
52 // This is the name of the certificate resource type and is used only to reference
53 // the certificate in other API actions. It can be different than the domain name
54 // of the certificate. For example, your certificate name might be
55 // WordPress-Blog-Certificate and the domain name of the certificate might be
56 // example.com .
57 //
58 // This member is required.
59 CertificateName *string
60 61 // The name of the distribution that the certificate will be attached to.
62 //
63 // Use the GetDistributions action to get a list of distribution names that you
64 // can specify.
65 //
66 // This member is required.
67 DistributionName *string
68 69 noSmithyDocumentSerde
70 }
71 72 type AttachCertificateToDistributionOutput struct {
73 74 // An object that describes the result of the action, such as the status of the
75 // request, the timestamp of the request, and the resources affected by the
76 // request.
77 Operation *types.Operation
78 79 // Metadata pertaining to the operation's result.
80 ResultMetadata middleware.Metadata
81 82 noSmithyDocumentSerde
83 }
84 85 func (c *Client) addOperationAttachCertificateToDistributionMiddlewares(stack *middleware.Stack, options Options) (err error) {
86 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
87 return err
88 }
89 err = stack.Serialize.Add(&awsAwsjson11_serializeOpAttachCertificateToDistribution{}, middleware.After)
90 if err != nil {
91 return err
92 }
93 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpAttachCertificateToDistribution{}, middleware.After)
94 if err != nil {
95 return err
96 }
97 if err := addProtocolFinalizerMiddlewares(stack, options, "AttachCertificateToDistribution"); err != nil {
98 return fmt.Errorf("add protocol finalizers: %v", err)
99 }
100 101 if err = addlegacyEndpointContextSetter(stack, options); err != nil {
102 return err
103 }
104 if err = addSetLoggerMiddleware(stack, options); err != nil {
105 return err
106 }
107 if err = addClientRequestID(stack); err != nil {
108 return err
109 }
110 if err = addComputeContentLength(stack); err != nil {
111 return err
112 }
113 if err = addResolveEndpointMiddleware(stack, options); err != nil {
114 return err
115 }
116 if err = addComputePayloadSHA256(stack); err != nil {
117 return err
118 }
119 if err = addRetry(stack, options); err != nil {
120 return err
121 }
122 if err = addRawResponseToMetadata(stack); err != nil {
123 return err
124 }
125 if err = addRecordResponseTiming(stack); err != nil {
126 return err
127 }
128 if err = addSpanRetryLoop(stack, options); err != nil {
129 return err
130 }
131 if err = addClientUserAgent(stack, options); err != nil {
132 return err
133 }
134 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
135 return err
136 }
137 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
138 return err
139 }
140 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
141 return err
142 }
143 if err = addTimeOffsetBuild(stack, c); err != nil {
144 return err
145 }
146 if err = addUserAgentRetryMode(stack, options); err != nil {
147 return err
148 }
149 if err = addCredentialSource(stack, options); err != nil {
150 return err
151 }
152 if err = addOpAttachCertificateToDistributionValidationMiddleware(stack); err != nil {
153 return err
154 }
155 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opAttachCertificateToDistribution(options.Region), middleware.Before); err != nil {
156 return err
157 }
158 if err = addRecursionDetection(stack); err != nil {
159 return err
160 }
161 if err = addRequestIDRetrieverMiddleware(stack); err != nil {
162 return err
163 }
164 if err = addResponseErrorMiddleware(stack); err != nil {
165 return err
166 }
167 if err = addRequestResponseLogging(stack, options); err != nil {
168 return err
169 }
170 if err = addDisableHTTPSMiddleware(stack, options); err != nil {
171 return err
172 }
173 if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
174 return err
175 }
176 if err = addInterceptAttempt(stack, options); err != nil {
177 return err
178 }
179 if err = addInterceptors(stack, options); err != nil {
180 return err
181 }
182 return nil
183 }
184 185 func newServiceMetadataMiddleware_opAttachCertificateToDistribution(region string) *awsmiddleware.RegisterServiceMetadata {
186 return &awsmiddleware.RegisterServiceMetadata{
187 Region: region,
188 ServiceID: ServiceID,
189 OperationName: "AttachCertificateToDistribution",
190 }
191 }
192