1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package ec2
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/smithy-go/middleware"
10	smithyhttp "github.com/aws/smithy-go/transport/http"
11)
12
13// Links an EC2-Classic instance to a ClassicLink-enabled VPC through one or more
14// of the VPC's security groups. You cannot link an EC2-Classic instance to more
15// than one VPC at a time. You can only link an instance that's in the running
16// state. An instance is automatically unlinked from a VPC when it's stopped - you
17// can link it to the VPC again when you restart it. After you've linked an
18// instance, you cannot change the VPC security groups that are associated with it.
19// To change the security groups, you must first unlink the instance, and then link
20// it again. Linking your instance to a VPC is sometimes referred to as attaching
21// your instance.
22func (c *Client) AttachClassicLinkVpc(ctx context.Context, params *AttachClassicLinkVpcInput, optFns ...func(*Options)) (*AttachClassicLinkVpcOutput, error) {
23	if params == nil {
24		params = &AttachClassicLinkVpcInput{}
25	}
26
27	result, metadata, err := c.invokeOperation(ctx, "AttachClassicLinkVpc", params, optFns, addOperationAttachClassicLinkVpcMiddlewares)
28	if err != nil {
29		return nil, err
30	}
31
32	out := result.(*AttachClassicLinkVpcOutput)
33	out.ResultMetadata = metadata
34	return out, nil
35}
36
37type AttachClassicLinkVpcInput struct {
38
39	// The ID of one or more of the VPC's security groups. You cannot specify security
40	// groups from a different VPC.
41	//
42	// This member is required.
43	Groups []string
44
45	// The ID of an EC2-Classic instance to link to the ClassicLink-enabled VPC.
46	//
47	// This member is required.
48	InstanceId *string
49
50	// The ID of a ClassicLink-enabled VPC.
51	//
52	// This member is required.
53	VpcId *string
54
55	// Checks whether you have the required permissions for the action, without
56	// actually making the request, and provides an error response. If you have the
57	// required permissions, the error response is DryRunOperation. Otherwise, it is
58	// UnauthorizedOperation.
59	DryRun bool
60}
61
62type AttachClassicLinkVpcOutput struct {
63
64	// Returns true if the request succeeds; otherwise, it returns an error.
65	Return bool
66
67	// Metadata pertaining to the operation's result.
68	ResultMetadata middleware.Metadata
69}
70
71func addOperationAttachClassicLinkVpcMiddlewares(stack *middleware.Stack, options Options) (err error) {
72	err = stack.Serialize.Add(&awsEc2query_serializeOpAttachClassicLinkVpc{}, middleware.After)
73	if err != nil {
74		return err
75	}
76	err = stack.Deserialize.Add(&awsEc2query_deserializeOpAttachClassicLinkVpc{}, middleware.After)
77	if err != nil {
78		return err
79	}
80	if err = addSetLoggerMiddleware(stack, options); err != nil {
81		return err
82	}
83	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
84		return err
85	}
86	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
87		return err
88	}
89	if err = addResolveEndpointMiddleware(stack, options); err != nil {
90		return err
91	}
92	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
93		return err
94	}
95	if err = addRetryMiddlewares(stack, options); err != nil {
96		return err
97	}
98	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
99		return err
100	}
101	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
102		return err
103	}
104	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
105		return err
106	}
107	if err = addClientUserAgent(stack); err != nil {
108		return err
109	}
110	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
111		return err
112	}
113	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
114		return err
115	}
116	if err = addOpAttachClassicLinkVpcValidationMiddleware(stack); err != nil {
117		return err
118	}
119	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opAttachClassicLinkVpc(options.Region), middleware.Before); err != nil {
120		return err
121	}
122	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
123		return err
124	}
125	if err = addResponseErrorMiddleware(stack); err != nil {
126		return err
127	}
128	if err = addRequestResponseLogging(stack, options); err != nil {
129		return err
130	}
131	return nil
132}
133
134func newServiceMetadataMiddleware_opAttachClassicLinkVpc(region string) *awsmiddleware.RegisterServiceMetadata {
135	return &awsmiddleware.RegisterServiceMetadata{
136		Region:        region,
137		ServiceID:     ServiceID,
138		SigningName:   "ec2",
139		OperationName: "AttachClassicLinkVpc",
140	}
141}
142