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/aws-sdk-go-v2/service/ec2/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Attaches the specified VPC to the specified transit gateway. If you attach a VPC
15// with a CIDR range that overlaps the CIDR range of a VPC that is already
16// attached, the new VPC CIDR range is not propagated to the default propagation
17// route table. To send VPC traffic to an attached transit gateway, add a route to
18// the VPC route table using CreateRoute.
19func (c *Client) CreateTransitGatewayVpcAttachment(ctx context.Context, params *CreateTransitGatewayVpcAttachmentInput, optFns ...func(*Options)) (*CreateTransitGatewayVpcAttachmentOutput, error) {
20	if params == nil {
21		params = &CreateTransitGatewayVpcAttachmentInput{}
22	}
23
24	result, metadata, err := c.invokeOperation(ctx, "CreateTransitGatewayVpcAttachment", params, optFns, addOperationCreateTransitGatewayVpcAttachmentMiddlewares)
25	if err != nil {
26		return nil, err
27	}
28
29	out := result.(*CreateTransitGatewayVpcAttachmentOutput)
30	out.ResultMetadata = metadata
31	return out, nil
32}
33
34type CreateTransitGatewayVpcAttachmentInput struct {
35
36	// The IDs of one or more subnets. You can specify only one subnet per Availability
37	// Zone. You must specify at least one subnet, but we recommend that you specify
38	// two subnets for better availability. The transit gateway uses one IP address
39	// from each specified subnet.
40	//
41	// This member is required.
42	SubnetIds []string
43
44	// The ID of the transit gateway.
45	//
46	// This member is required.
47	TransitGatewayId *string
48
49	// The ID of the VPC.
50	//
51	// This member is required.
52	VpcId *string
53
54	// Checks whether you have the required permissions for the action, without
55	// actually making the request, and provides an error response. If you have the
56	// required permissions, the error response is DryRunOperation. Otherwise, it is
57	// UnauthorizedOperation.
58	DryRun bool
59
60	// The VPC attachment options.
61	Options *types.CreateTransitGatewayVpcAttachmentRequestOptions
62
63	// The tags to apply to the VPC attachment.
64	TagSpecifications []types.TagSpecification
65}
66
67type CreateTransitGatewayVpcAttachmentOutput struct {
68
69	// Information about the VPC attachment.
70	TransitGatewayVpcAttachment *types.TransitGatewayVpcAttachment
71
72	// Metadata pertaining to the operation's result.
73	ResultMetadata middleware.Metadata
74}
75
76func addOperationCreateTransitGatewayVpcAttachmentMiddlewares(stack *middleware.Stack, options Options) (err error) {
77	err = stack.Serialize.Add(&awsEc2query_serializeOpCreateTransitGatewayVpcAttachment{}, middleware.After)
78	if err != nil {
79		return err
80	}
81	err = stack.Deserialize.Add(&awsEc2query_deserializeOpCreateTransitGatewayVpcAttachment{}, middleware.After)
82	if err != nil {
83		return err
84	}
85	if err = addSetLoggerMiddleware(stack, options); err != nil {
86		return err
87	}
88	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
89		return err
90	}
91	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
92		return err
93	}
94	if err = addResolveEndpointMiddleware(stack, options); err != nil {
95		return err
96	}
97	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
98		return err
99	}
100	if err = addRetryMiddlewares(stack, options); err != nil {
101		return err
102	}
103	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
104		return err
105	}
106	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
107		return err
108	}
109	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
110		return err
111	}
112	if err = addClientUserAgent(stack); err != nil {
113		return err
114	}
115	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
116		return err
117	}
118	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
119		return err
120	}
121	if err = addOpCreateTransitGatewayVpcAttachmentValidationMiddleware(stack); err != nil {
122		return err
123	}
124	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateTransitGatewayVpcAttachment(options.Region), middleware.Before); err != nil {
125		return err
126	}
127	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
128		return err
129	}
130	if err = addResponseErrorMiddleware(stack); err != nil {
131		return err
132	}
133	if err = addRequestResponseLogging(stack, options); err != nil {
134		return err
135	}
136	return nil
137}
138
139func newServiceMetadataMiddleware_opCreateTransitGatewayVpcAttachment(region string) *awsmiddleware.RegisterServiceMetadata {
140	return &awsmiddleware.RegisterServiceMetadata{
141		Region:        region,
142		ServiceID:     ServiceID,
143		SigningName:   "ec2",
144		OperationName: "CreateTransitGatewayVpcAttachment",
145	}
146}
147