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// Requests a VPC peering connection between two VPCs: a requester VPC that you own 15// and an accepter VPC with which to create the connection. The accepter VPC can 16// belong to another AWS account and can be in a different Region to the requester 17// VPC. The requester VPC and accepter VPC cannot have overlapping CIDR blocks. 18// Limitations and rules apply to a VPC peering connection. For more information, 19// see the limitations 20// (https://docs.aws.amazon.com/vpc/latest/peering/vpc-peering-basics.html#vpc-peering-limitations) 21// section in the VPC Peering Guide. The owner of the accepter VPC must accept the 22// peering request to activate the peering connection. The VPC peering connection 23// request expires after 7 days, after which it cannot be accepted or rejected. If 24// you create a VPC peering connection request between VPCs with overlapping CIDR 25// blocks, the VPC peering connection has a status of failed. 26func (c *Client) CreateVpcPeeringConnection(ctx context.Context, params *CreateVpcPeeringConnectionInput, optFns ...func(*Options)) (*CreateVpcPeeringConnectionOutput, error) { 27 if params == nil { 28 params = &CreateVpcPeeringConnectionInput{} 29 } 30 31 result, metadata, err := c.invokeOperation(ctx, "CreateVpcPeeringConnection", params, optFns, addOperationCreateVpcPeeringConnectionMiddlewares) 32 if err != nil { 33 return nil, err 34 } 35 36 out := result.(*CreateVpcPeeringConnectionOutput) 37 out.ResultMetadata = metadata 38 return out, nil 39} 40 41type CreateVpcPeeringConnectionInput struct { 42 43 // Checks whether you have the required permissions for the action, without 44 // actually making the request, and provides an error response. If you have the 45 // required permissions, the error response is DryRunOperation. Otherwise, it is 46 // UnauthorizedOperation. 47 DryRun bool 48 49 // The AWS account ID of the owner of the accepter VPC. Default: Your AWS account 50 // ID 51 PeerOwnerId *string 52 53 // The Region code for the accepter VPC, if the accepter VPC is located in a Region 54 // other than the Region in which you make the request. Default: The Region in 55 // which you make the request. 56 PeerRegion *string 57 58 // The ID of the VPC with which you are creating the VPC peering connection. You 59 // must specify this parameter in the request. 60 PeerVpcId *string 61 62 // The tags to assign to the peering connection. 63 TagSpecifications []types.TagSpecification 64 65 // The ID of the requester VPC. You must specify this parameter in the request. 66 VpcId *string 67} 68 69type CreateVpcPeeringConnectionOutput struct { 70 71 // Information about the VPC peering connection. 72 VpcPeeringConnection *types.VpcPeeringConnection 73 74 // Metadata pertaining to the operation's result. 75 ResultMetadata middleware.Metadata 76} 77 78func addOperationCreateVpcPeeringConnectionMiddlewares(stack *middleware.Stack, options Options) (err error) { 79 err = stack.Serialize.Add(&awsEc2query_serializeOpCreateVpcPeeringConnection{}, middleware.After) 80 if err != nil { 81 return err 82 } 83 err = stack.Deserialize.Add(&awsEc2query_deserializeOpCreateVpcPeeringConnection{}, middleware.After) 84 if err != nil { 85 return err 86 } 87 if err = addSetLoggerMiddleware(stack, options); err != nil { 88 return err 89 } 90 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 91 return err 92 } 93 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 94 return err 95 } 96 if err = addResolveEndpointMiddleware(stack, options); err != nil { 97 return err 98 } 99 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 100 return err 101 } 102 if err = addRetryMiddlewares(stack, options); err != nil { 103 return err 104 } 105 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 106 return err 107 } 108 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 109 return err 110 } 111 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 112 return err 113 } 114 if err = addClientUserAgent(stack); err != nil { 115 return err 116 } 117 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 118 return err 119 } 120 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 121 return err 122 } 123 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateVpcPeeringConnection(options.Region), middleware.Before); err != nil { 124 return err 125 } 126 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 127 return err 128 } 129 if err = addResponseErrorMiddleware(stack); err != nil { 130 return err 131 } 132 if err = addRequestResponseLogging(stack, options); err != nil { 133 return err 134 } 135 return nil 136} 137 138func newServiceMetadataMiddleware_opCreateVpcPeeringConnection(region string) *awsmiddleware.RegisterServiceMetadata { 139 return &awsmiddleware.RegisterServiceMetadata{ 140 Region: region, 141 ServiceID: ServiceID, 142 SigningName: "ec2", 143 OperationName: "CreateVpcPeeringConnection", 144 } 145} 146