Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

400 linhas
14 KiB

  1. package ec2
  2. // RouteTable describes a route table which contains a set of rules, called routes
  3. // that are used to determine where network traffic is directed.
  4. //
  5. // See http://goo.gl/bI9hkg for more details.
  6. type RouteTable struct {
  7. Id string `xml:"routeTableId"`
  8. VpcId string `xml:"vpcId"`
  9. Routes []Route `xml:"routeSet>item"`
  10. Associations []RouteTableAssociation `xml:"associationSet>item"`
  11. PropagatingVgws []PropagatingVgw `xml:"propagatingVgwSet>item"`
  12. Tags []Tag `xml:"tagSet>item"`
  13. }
  14. // Route describes a route in a route table.
  15. //
  16. // See http://goo.gl/hE5Kxe for more details.
  17. type Route struct {
  18. DestinationCidrBlock string `xml:"destinationCidrBlock"` // The CIDR block used for the destination match.
  19. GatewayId string `xml:"gatewayId"` // The ID of a gateway attached to your VPC.
  20. InstanceId string `xml:"instanceId"` // The ID of a NAT instance in your VPC.
  21. InstanceOwnerId string `xml:"instanceOwnerId"` // The AWS account ID of the owner of the instance.
  22. NetworkInterfaceId string `xml:"networkInterfaceId"` // The ID of the network interface.
  23. State string `xml:"state"` // The state of the route. Valid values: active | blackhole
  24. Origin string `xml:"origin"` // Describes how the route was created. Valid values: Valid values: CreateRouteTable | CreateRoute | EnableVgwRoutePropagation
  25. VpcPeeringConnectionId string `xml:"vpcPeeringConnectionId"` // The ID of the VPC peering connection.
  26. }
  27. // RouteTableAssociation describes an association between a route table and a subnet.
  28. //
  29. // See http://goo.gl/BZB8o8 for more details.
  30. type RouteTableAssociation struct {
  31. Id string `xml:"routeTableAssociationId"` // The ID of the association between a route table and a subnet.
  32. RouteTableId string `xml:"routeTableId"` // The ID of the route table.
  33. SubnetId string `xml:"subnetId"` // The ID of the subnet.
  34. Main bool `xml:"main"` // Indicates whether this is the main route table.
  35. }
  36. // PropagatingVgw describes a virtual private gateway propagating route.
  37. //
  38. // See http://goo.gl/myGQtG for more details.
  39. type PropagatingVgw struct {
  40. GatewayId string `xml:"gatewayID"`
  41. }
  42. // CreateRouteTableResp represents a response from a CreateRouteTable request
  43. //
  44. // See http://goo.gl/LD0TqP for more details.
  45. type CreateRouteTableResp struct {
  46. RequestId string `xml:"requestId"`
  47. RouteTable RouteTable `xml:"routeTable"`
  48. }
  49. // CreateRouteTable creates a route table for the specified VPC.
  50. // After you create a route table, you can add routes and associate the table with a subnet.
  51. //
  52. // See http://goo.gl/V9h6gE for more details..
  53. func (ec2 *EC2) CreateRouteTable(vpcId string) (resp *CreateRouteTableResp, err error) {
  54. params := makeParams("CreateRouteTable")
  55. params["VpcId"] = vpcId
  56. resp = &CreateRouteTableResp{}
  57. err = ec2.query(params, resp)
  58. if err != nil {
  59. return nil, err
  60. }
  61. return
  62. }
  63. // DescribeRouteTablesResp represents a response from a DescribeRouteTables call
  64. //
  65. // See http://goo.gl/T3tVsg for more details.
  66. type DescribeRouteTablesResp struct {
  67. RequestId string `xml:"requestId"`
  68. RouteTables []RouteTable `xml:"routeTableSet>item"`
  69. }
  70. // DescribeRouteTables describes one or more of your route tables
  71. //
  72. // See http://goo.gl/S0RVos for more details.
  73. func (ec2 *EC2) DescribeRouteTables(routeTableIds []string, filter *Filter) (resp *DescribeRouteTablesResp, err error) {
  74. params := makeParams("DescribeRouteTables")
  75. addParamsList(params, "RouteTableId", routeTableIds)
  76. filter.addParams(params)
  77. resp = &DescribeRouteTablesResp{}
  78. err = ec2.query(params, resp)
  79. if err != nil {
  80. return nil, err
  81. }
  82. return
  83. }
  84. // AssociateRouteTableResp represents a response from an AssociateRouteTable call
  85. //
  86. // See http://goo.gl/T4KlYk for more details.
  87. type AssociateRouteTableResp struct {
  88. RequestId string `xml:"requestId"`
  89. AssociationId string `xml:"associationId"`
  90. }
  91. // AssociateRouteTable associates a subnet with a route table.
  92. //
  93. // The subnet and route table must be in the same VPC. This association causes
  94. // traffic originating from the subnet to be routed according to the routes
  95. // in the route table. The action returns an association ID, which you need in
  96. // order to disassociate the route table from the subnet later.
  97. // A route table can be associated with multiple subnets.
  98. //
  99. // See http://goo.gl/bfnONU for more details.
  100. func (ec2 *EC2) AssociateRouteTable(routeTableId, subnetId string) (resp *AssociateRouteTableResp, err error) {
  101. params := makeParams("AssociateRouteTable")
  102. params["RouteTableId"] = routeTableId
  103. params["SubnetId"] = subnetId
  104. resp = &AssociateRouteTableResp{}
  105. err = ec2.query(params, resp)
  106. if err != nil {
  107. return nil, err
  108. }
  109. return
  110. }
  111. // DisassociateRouteTableResp represents the response from a DisassociateRouteTable request
  112. //
  113. // See http://goo.gl/1v4reT for more details.
  114. type DisassociateRouteTableResp struct {
  115. RequestId string `xml:"requestId"`
  116. Return bool `xml:"return"` // True if the request succeeds
  117. }
  118. // DisassociateRouteTable disassociates a subnet from a route table.
  119. //
  120. // See http://goo.gl/A4NJum for more details.
  121. func (ec2 *EC2) DisassociateRouteTable(associationId string) (resp *DisassociateRouteTableResp, err error) {
  122. params := makeParams("DisassociateRouteTable")
  123. params["AssociationId"] = associationId
  124. resp = &DisassociateRouteTableResp{}
  125. err = ec2.query(params, resp)
  126. if err != nil {
  127. return nil, err
  128. }
  129. return
  130. }
  131. // ReplaceRouteTableAssociationResp represents a response from a ReplaceRouteTableAssociation call
  132. //
  133. // See http://goo.gl/VhILGe for more details.
  134. type ReplaceRouteTableAssociationResp struct {
  135. RequestId string `xml:"requestId"`
  136. NewAssociationId string `xml:"newAssociationId"`
  137. }
  138. // ReplaceRouteTableAssociation changes the route table associated with a given subnet in a VPC.
  139. //
  140. // See http://goo.gl/kiit8j for more details.
  141. func (ec2 *EC2) ReplaceRouteTableAssociation(associationId, routeTableId string) (resp *ReplaceRouteTableAssociationResp, err error) {
  142. params := makeParams("ReplaceRouteTableAssociation")
  143. params["AssociationId"] = associationId
  144. params["RouteTableId"] = routeTableId
  145. resp = &ReplaceRouteTableAssociationResp{}
  146. err = ec2.query(params, resp)
  147. if err != nil {
  148. return nil, err
  149. }
  150. return
  151. }
  152. // DeleteRouteTableResp represents a response from a DeleteRouteTable request
  153. //
  154. // See http://goo.gl/b8usig for more details.
  155. type DeleteRouteTableResp struct {
  156. RequestId string `xml:"requestId"`
  157. Return bool `xml:"return"` // True if the request succeeds
  158. }
  159. // DeleteRouteTable deletes the specified route table.
  160. // You must disassociate the route table from any subnets before you can delete it.
  161. // You can't delete the main route table.
  162. //
  163. // See http://goo.gl/crHxT2 for more details.
  164. func (ec2 *EC2) DeleteRouteTable(routeTableId string) (resp *DeleteRouteTableResp, err error) {
  165. params := makeParams("DeleteRouteTable")
  166. params["RouteTableId"] = routeTableId
  167. resp = &DeleteRouteTableResp{}
  168. err = ec2.query(params, resp)
  169. if err != nil {
  170. return nil, err
  171. }
  172. return
  173. }
  174. // VPC describes a VPC.
  175. //
  176. // See http://goo.gl/WjX0Es for more details.
  177. type VPC struct {
  178. CidrBlock string `xml:"cidrBlock"`
  179. DHCPOptionsID string `xml:"dhcpOptionsId"`
  180. State string `xml:"state"`
  181. VpcId string `xml:"vpcId"`
  182. InstanceTenancy string `xml:"instanceTenancy"`
  183. IsDefault bool `xml:"isDefault"`
  184. Tags []Tag `xml:"tagSet>item"`
  185. }
  186. // CreateVpcResp represents a response from a CreateVpcResp request
  187. //
  188. // See http://goo.gl/QoK11F for more details.
  189. type CreateVpcResp struct {
  190. RequestId string `xml:"requestId"`
  191. VPC VPC `xml:"vpc"` // Information about the VPC.
  192. }
  193. // CreateVpc creates a VPC with the specified CIDR block.
  194. //
  195. // The smallest VPC you can create uses a /28 netmask (16 IP addresses),
  196. // and the largest uses a /16 netmask (65,536 IP addresses).
  197. //
  198. // By default, each instance you launch in the VPC has the default DHCP options,
  199. // which includes only a default DNS server that Amazon provides (AmazonProvidedDNS).
  200. //
  201. // See http://goo.gl/QoK11F for more details.
  202. func (ec2 *EC2) CreateVpc(cidrBlock, instanceTenancy string) (resp *CreateVpcResp, err error) {
  203. params := makeParams("CreateVpc")
  204. params["CidrBlock"] = cidrBlock
  205. if instanceTenancy != "" {
  206. params["InstanceTenancy"] = instanceTenancy
  207. }
  208. resp = &CreateVpcResp{}
  209. err = ec2.query(params, resp)
  210. if err != nil {
  211. return nil, err
  212. }
  213. return
  214. }
  215. // DeleteVpcResp represents a response from a DeleteVpc request
  216. //
  217. // See http://goo.gl/qawyrz for more details.
  218. type DeleteVpcResp struct {
  219. RequestId string `xml:"requestId"`
  220. Return bool `xml:"return"` // True if the request succeeds
  221. }
  222. // DeleteVpc deletes the specified VPC.
  223. //
  224. // You must detach or delete all gateways and resources that are associated with
  225. // the VPC before you can delete it. For example, you must terminate all
  226. // instances running in the VPC, delete all security groups associated with
  227. // the VPC (except the default one), delete all route tables associated with
  228. // the VPC (except the default one), and so on.
  229. //
  230. // See http://goo.gl/qawyrz for more details.
  231. func (ec2 *EC2) DeleteVpc(vpcId string) (resp *DeleteVpcResp, err error) {
  232. params := makeParams("DeleteVpc")
  233. params["VpcId"] = vpcId
  234. resp = &DeleteVpcResp{}
  235. err = ec2.query(params, resp)
  236. if err != nil {
  237. return nil, err
  238. }
  239. return
  240. }
  241. // DescribeVpcsResp represents a response from a DescribeVpcs request
  242. //
  243. // See http://goo.gl/DWQWvZ for more details.
  244. type DescribeVpcsResp struct {
  245. RequestId string `xml:"requestId"`
  246. VPCs []VPC `xml:"vpcSet>item"` // Information about one or more VPCs.
  247. }
  248. // DescribeVpcs describes one or more of your VPCs.
  249. //
  250. // See http://goo.gl/DWQWvZ for more details.
  251. func (ec2 *EC2) DescribeVpcs(vpcIds []string, filter *Filter) (resp *DescribeVpcsResp, err error) {
  252. params := makeParams("DescribeVpcs")
  253. addParamsList(params, "VpcId", vpcIds)
  254. filter.addParams(params)
  255. resp = &DescribeVpcsResp{}
  256. err = ec2.query(params, resp)
  257. if err != nil {
  258. return nil, err
  259. }
  260. return
  261. }
  262. // DeleteRouteResp represents a response from a DeleteRoute request
  263. //
  264. // See http://goo.gl/Uqyt3w for more details.
  265. type DeleteRouteResp struct {
  266. RequestId string `xml:"requestId"`
  267. Return bool `xml:"return"` // True if the request succeeds
  268. }
  269. // DeleteRoute deletes the specified route from the specified route table.
  270. //
  271. // See http://goo.gl/Uqyt3w for more details.
  272. func (ec2 *EC2) DeleteRoute(routeTableId, destinationCidrBlock string) (resp *DeleteRouteResp, err error) {
  273. params := makeParams("DeleteRoute")
  274. params["RouteTableId"] = routeTableId
  275. params["DestinationCidrBlock"] = destinationCidrBlock
  276. resp = &DeleteRouteResp{}
  277. err = ec2.query(params, resp)
  278. if err != nil {
  279. return nil, err
  280. }
  281. return
  282. }
  283. // CreateRouteResp represents a response from a CreateRoute request
  284. //
  285. // See http://goo.gl/c6Bg7e for more details.
  286. type CreateRouteResp struct {
  287. RequestId string `xml:"requestId"`
  288. Return bool `xml:"return"` // True if the request succeeds
  289. }
  290. // CreateRoute structure contains the options for a CreateRoute API call.
  291. type CreateRoute struct {
  292. DestinationCidrBlock string
  293. GatewayId string
  294. InstanceId string
  295. NetworkInterfaceId string
  296. VpcPeeringConnectionId string
  297. }
  298. // CreateRoute creates a route in a route table within a VPC.
  299. // You must specify one of the following targets: Internet gateway or virtual
  300. // private gateway, NAT instance, VPC peering connection, or network interface.
  301. //
  302. // See http://goo.gl/c6Bg7e for more details.
  303. func (ec2 *EC2) CreateRoute(routeTableId string, options *CreateRoute) (resp *CreateRouteResp, err error) {
  304. params := makeParams("CreateRoute")
  305. params["RouteTableId"] = routeTableId
  306. if options.DestinationCidrBlock != "" {
  307. params["DestinationCidrBlock"] = options.DestinationCidrBlock
  308. }
  309. if options.GatewayId != "" {
  310. params["GatewayId"] = options.GatewayId
  311. }
  312. if options.InstanceId != "" {
  313. params["InstanceId"] = options.InstanceId
  314. }
  315. if options.NetworkInterfaceId != "" {
  316. params["NetworkInterfaceId"] = options.NetworkInterfaceId
  317. }
  318. if options.VpcPeeringConnectionId != "" {
  319. params["VpcPeeringConnectionId"] = options.VpcPeeringConnectionId
  320. }
  321. resp = &CreateRouteResp{}
  322. err = ec2.query(params, resp)
  323. if err != nil {
  324. return nil, err
  325. }
  326. return
  327. }
  328. // Subnet describes a subnet
  329. //
  330. // See http://goo.gl/bifW4R
  331. type Subnet struct {
  332. AvailabilityZone string `xml:"availabilityZone"`
  333. AvailableIpAddressCount int `xml:"availableIpAddressCount"`
  334. CidrBlock string `xml:"cidrBlock"`
  335. DefaultForAZ bool `xml:"defaultForAz"`
  336. MapPublicIpOnLaunch bool `xml:"mapPublicIpOnLaunch"`
  337. State string `xml:"state"`
  338. SubnetId string `xml:"subnetId"`
  339. Tags []Tag `xml:"tagSet>item"`
  340. VpcId string `xml:"vpcId"`
  341. }
  342. // DescribeSubnetsResp represents a response from a DescribeSubnets request
  343. //
  344. // See https://goo.gl/1s0UQd for more details.
  345. type DescribeSubnetsResp struct {
  346. RequestId string `xml:"requestId"`
  347. Subnets []Subnet `xml:"subnetSet>item"`
  348. }
  349. // DescribeSubnets describes one or more Subnets.
  350. //
  351. // See https://goo.gl/1s0UQd for more details.
  352. func (ec2 *EC2) DescribeSubnets(subnetIds []string, filter *Filter) (resp *DescribeSubnetsResp, err error) {
  353. params := makeParams("DescribeSubnets")
  354. addParamsList(params, "SubnetId", subnetIds)
  355. filter.addParams(params)
  356. resp = &DescribeSubnetsResp{}
  357. err = ec2.query(params, resp)
  358. if err != nil {
  359. return nil, err
  360. }
  361. return
  362. }