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// Creates a VPN connection between an existing virtual private gateway or transit 15// gateway and a customer gateway. The supported connection type is ipsec.1. The 16// response includes information that you need to give to your network 17// administrator to configure your customer gateway. We strongly recommend that you 18// use HTTPS when calling this operation because the response contains sensitive 19// cryptographic information for configuring your customer gateway device. If you 20// decide to shut down your VPN connection for any reason and later create a new 21// VPN connection, you must reconfigure your customer gateway with the new 22// information returned from this call. This is an idempotent operation. If you 23// perform the operation more than once, Amazon EC2 doesn't return an error. For 24// more information, see AWS Site-to-Site VPN 25// (https://docs.aws.amazon.com/vpn/latest/s2svpn/VPC_VPN.html) in the AWS 26// Site-to-Site VPN User Guide. 27func (c *Client) CreateVpnConnection(ctx context.Context, params *CreateVpnConnectionInput, optFns ...func(*Options)) (*CreateVpnConnectionOutput, error) { 28 if params == nil { 29 params = &CreateVpnConnectionInput{} 30 } 31 32 result, metadata, err := c.invokeOperation(ctx, "CreateVpnConnection", params, optFns, addOperationCreateVpnConnectionMiddlewares) 33 if err != nil { 34 return nil, err 35 } 36 37 out := result.(*CreateVpnConnectionOutput) 38 out.ResultMetadata = metadata 39 return out, nil 40} 41 42// Contains the parameters for CreateVpnConnection. 43type CreateVpnConnectionInput struct { 44 45 // The ID of the customer gateway. 46 // 47 // This member is required. 48 CustomerGatewayId *string 49 50 // The type of VPN connection (ipsec.1). 51 // 52 // This member is required. 53 Type *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 // The options for the VPN connection. 62 Options *types.VpnConnectionOptionsSpecification 63 64 // The tags to apply to the VPN connection. 65 TagSpecifications []types.TagSpecification 66 67 // The ID of the transit gateway. If you specify a transit gateway, you cannot 68 // specify a virtual private gateway. 69 TransitGatewayId *string 70 71 // The ID of the virtual private gateway. If you specify a virtual private gateway, 72 // you cannot specify a transit gateway. 73 VpnGatewayId *string 74} 75 76// Contains the output of CreateVpnConnection. 77type CreateVpnConnectionOutput struct { 78 79 // Information about the VPN connection. 80 VpnConnection *types.VpnConnection 81 82 // Metadata pertaining to the operation's result. 83 ResultMetadata middleware.Metadata 84} 85 86func addOperationCreateVpnConnectionMiddlewares(stack *middleware.Stack, options Options) (err error) { 87 err = stack.Serialize.Add(&awsEc2query_serializeOpCreateVpnConnection{}, middleware.After) 88 if err != nil { 89 return err 90 } 91 err = stack.Deserialize.Add(&awsEc2query_deserializeOpCreateVpnConnection{}, middleware.After) 92 if err != nil { 93 return err 94 } 95 if err = addSetLoggerMiddleware(stack, options); err != nil { 96 return err 97 } 98 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 99 return err 100 } 101 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 102 return err 103 } 104 if err = addResolveEndpointMiddleware(stack, options); err != nil { 105 return err 106 } 107 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 108 return err 109 } 110 if err = addRetryMiddlewares(stack, options); err != nil { 111 return err 112 } 113 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 114 return err 115 } 116 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 117 return err 118 } 119 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 120 return err 121 } 122 if err = addClientUserAgent(stack); err != nil { 123 return err 124 } 125 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 126 return err 127 } 128 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 129 return err 130 } 131 if err = addOpCreateVpnConnectionValidationMiddleware(stack); err != nil { 132 return err 133 } 134 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateVpnConnection(options.Region), middleware.Before); err != nil { 135 return err 136 } 137 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 138 return err 139 } 140 if err = addResponseErrorMiddleware(stack); err != nil { 141 return err 142 } 143 if err = addRequestResponseLogging(stack, options); err != nil { 144 return err 145 } 146 return nil 147} 148 149func newServiceMetadataMiddleware_opCreateVpnConnection(region string) *awsmiddleware.RegisterServiceMetadata { 150 return &awsmiddleware.RegisterServiceMetadata{ 151 Region: region, 152 ServiceID: ServiceID, 153 SigningName: "ec2", 154 OperationName: "CreateVpnConnection", 155 } 156} 157