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// Allocates an Elastic IP address to your AWS account. After you allocate the 15// Elastic IP address you can associate it with an instance or network interface. 16// After you release an Elastic IP address, it is released to the IP address pool 17// and can be allocated to a different AWS account. You can allocate an Elastic IP 18// address from an address pool owned by AWS or from an address pool created from a 19// public IPv4 address range that you have brought to AWS for use with your AWS 20// resources using bring your own IP addresses (BYOIP). For more information, see 21// Bring Your Own IP Addresses (BYOIP) 22// (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-byoip.html) in the 23// Amazon Elastic Compute Cloud User Guide. [EC2-VPC] If you release an Elastic IP 24// address, you might be able to recover it. You cannot recover an Elastic IP 25// address that you released after it is allocated to another AWS account. You 26// cannot recover an Elastic IP address for EC2-Classic. To attempt to recover an 27// Elastic IP address that you released, specify it in this operation. An Elastic 28// IP address is for use either in the EC2-Classic platform or in a VPC. By 29// default, you can allocate 5 Elastic IP addresses for EC2-Classic per Region and 30// 5 Elastic IP addresses for EC2-VPC per Region. For more information, see Elastic 31// IP Addresses 32// (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html) 33// in the Amazon Elastic Compute Cloud User Guide. You can allocate a carrier IP 34// address which is a public IP address from a telecommunication carrier, to a 35// network interface which resides in a subnet in a Wavelength Zone (for example an 36// EC2 instance). 37func (c *Client) AllocateAddress(ctx context.Context, params *AllocateAddressInput, optFns ...func(*Options)) (*AllocateAddressOutput, error) { 38 if params == nil { 39 params = &AllocateAddressInput{} 40 } 41 42 result, metadata, err := c.invokeOperation(ctx, "AllocateAddress", params, optFns, addOperationAllocateAddressMiddlewares) 43 if err != nil { 44 return nil, err 45 } 46 47 out := result.(*AllocateAddressOutput) 48 out.ResultMetadata = metadata 49 return out, nil 50} 51 52type AllocateAddressInput struct { 53 54 // [EC2-VPC] The Elastic IP address to recover or an IPv4 address from an address 55 // pool. 56 Address *string 57 58 // The ID of a customer-owned address pool. Use this parameter to let Amazon EC2 59 // select an address from the address pool. Alternatively, specify a specific 60 // address from the address pool. 61 CustomerOwnedIpv4Pool *string 62 63 // Indicates whether the Elastic IP address is for use with instances in a VPC or 64 // instances in EC2-Classic. Default: If the Region supports EC2-Classic, the 65 // default is standard. Otherwise, the default is vpc. 66 Domain types.DomainType 67 68 // Checks whether you have the required permissions for the action, without 69 // actually making the request, and provides an error response. If you have the 70 // required permissions, the error response is DryRunOperation. Otherwise, it is 71 // UnauthorizedOperation. 72 DryRun bool 73 74 // A unique set of Availability Zones, Local Zones, or Wavelength Zones from which 75 // AWS advertises IP addresses. Use this parameter to limit the IP address to this 76 // location. IP addresses cannot move between network border groups. Use 77 // DescribeAvailabilityZones 78 // (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html) 79 // to view the network border groups. You cannot use a network border group with 80 // EC2 Classic. If you attempt this operation on EC2 classic, you will receive an 81 // InvalidParameterCombination error. For more information, see Error Codes 82 // (https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html). 83 NetworkBorderGroup *string 84 85 // The ID of an address pool that you own. Use this parameter to let Amazon EC2 86 // select an address from the address pool. To specify a specific address from the 87 // address pool, use the Address parameter instead. 88 PublicIpv4Pool *string 89 90 // The tags to assign to the Elastic IP address. 91 TagSpecifications []types.TagSpecification 92} 93 94type AllocateAddressOutput struct { 95 96 // [EC2-VPC] The ID that AWS assigns to represent the allocation of the Elastic IP 97 // address for use with instances in a VPC. 98 AllocationId *string 99 100 // The carrier IP address. This option is only available for network interfaces 101 // which reside in a subnet in a Wavelength Zone (for example an EC2 instance). 102 CarrierIp *string 103 104 // The customer-owned IP address. 105 CustomerOwnedIp *string 106 107 // The ID of the customer-owned address pool. 108 CustomerOwnedIpv4Pool *string 109 110 // Indicates whether the Elastic IP address is for use with instances in a VPC 111 // (vpc) or instances in EC2-Classic (standard). 112 Domain types.DomainType 113 114 // The set of Availability Zones, Local Zones, or Wavelength Zones from which AWS 115 // advertises IP addresses. 116 NetworkBorderGroup *string 117 118 // The Elastic IP address. 119 PublicIp *string 120 121 // The ID of an address pool. 122 PublicIpv4Pool *string 123 124 // Metadata pertaining to the operation's result. 125 ResultMetadata middleware.Metadata 126} 127 128func addOperationAllocateAddressMiddlewares(stack *middleware.Stack, options Options) (err error) { 129 err = stack.Serialize.Add(&awsEc2query_serializeOpAllocateAddress{}, middleware.After) 130 if err != nil { 131 return err 132 } 133 err = stack.Deserialize.Add(&awsEc2query_deserializeOpAllocateAddress{}, middleware.After) 134 if err != nil { 135 return err 136 } 137 if err = addSetLoggerMiddleware(stack, options); err != nil { 138 return err 139 } 140 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 141 return err 142 } 143 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 144 return err 145 } 146 if err = addResolveEndpointMiddleware(stack, options); err != nil { 147 return err 148 } 149 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 150 return err 151 } 152 if err = addRetryMiddlewares(stack, options); err != nil { 153 return err 154 } 155 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 156 return err 157 } 158 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 159 return err 160 } 161 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 162 return err 163 } 164 if err = addClientUserAgent(stack); err != nil { 165 return err 166 } 167 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 168 return err 169 } 170 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 171 return err 172 } 173 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opAllocateAddress(options.Region), middleware.Before); err != nil { 174 return err 175 } 176 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 177 return err 178 } 179 if err = addResponseErrorMiddleware(stack); err != nil { 180 return err 181 } 182 if err = addRequestResponseLogging(stack, options); err != nil { 183 return err 184 } 185 return nil 186} 187 188func newServiceMetadataMiddleware_opAllocateAddress(region string) *awsmiddleware.RegisterServiceMetadata { 189 return &awsmiddleware.RegisterServiceMetadata{ 190 Region: region, 191 ServiceID: ServiceID, 192 SigningName: "ec2", 193 OperationName: "AllocateAddress", 194 } 195} 196