forked from goamz/goamz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpc.go
189 lines (173 loc) · 7.13 KB
/
vpc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package ec2
// RouteTable describes a route table which contains a set of rules, called routes
// that are used to determine where network traffic is directed.
//
// See http://goo.gl/bI9hkg for more details.
type RouteTable struct {
Id string `xml:"routeTableId"`
VpcId string `xml:"vpcId"`
Routes []Route `xml:"routeSet>item"`
Associations []RouteTableAssociation `xml:"associationSet>item"`
PropagatingVgws []PropagatingVgw `xml:"propagatingVgwSet>item"`
Tags []Tag `xml:"tagSet>item"`
}
// Route describes a route in a route table.
//
// See http://goo.gl/hE5Kxe for more details.
type Route struct {
DestinationCidrBlock string `xml:"destinationCidrBlock"` // The CIDR block used for the destination match.
GatewayId string `xml:"gatewayId"` // The ID of a gateway attached to your VPC.
InstanceId string `xml:"instanceId"` // The ID of a NAT instance in your VPC.
InstanceOwnerId string `xml:"instanceOwnerId"` // The AWS account ID of the owner of the instance.
NetworkInterfaceId string `xml:"networkInterfaceId"` // The ID of the network interface.
State string `xml:"state"` // The state of the route. Valid values: active | blackhole
Origin string `xml:"origin"` // Describes how the route was created. Valid values: Valid values: CreateRouteTable | CreateRoute | EnableVgwRoutePropagation
VpcPeeringConnectionId string `xml:"vpcPeeringConnectionId"` // The ID of the VPC peering connection.
}
// RouteTableAssociation describes an association between a route table and a subnet.
//
// See http://goo.gl/BZB8o8 for more details.
type RouteTableAssociation struct {
Id string `xml:"routeTableAssociationId"` // The ID of the association between a route table and a subnet.
RouteTableId string `xml:"routeTableId"` // The ID of the route table.
SubnetId string `xml:"subnetId"` // The ID of the subnet.
Main bool `xml:"main"` // Indicates whether this is the main route table.
}
// PropagatingVgw describes a virtual private gateway propagating route.
//
// See http://goo.gl/myGQtG for more details.
type PropagatingVgw struct {
GatewayId string `xml:"gatewayID"`
}
// CreateRouteTableResp represents a response from a CreateRouteTable request
//
// See http://goo.gl/LD0TqP for more details.
type CreateRouteTableResp struct {
RequestId string `xml:"requestId"`
RouteTable RouteTable `xml:"routeTable"`
}
// CreateRouteTable creates a route table for the specified VPC.
// After you create a route table, you can add routes and associate the table with a subnet.
//
// See http://goo.gl/V9h6gE for more details..
func (ec2 *EC2) CreateRouteTable(vpcId string) (resp *CreateRouteTableResp, err error) {
params := makeParams("CreateRouteTable")
params["VpcId"] = vpcId
resp = &CreateRouteTableResp{}
err = ec2.query(params, resp)
if err != nil {
return nil, err
}
return
}
// DescribeRouteTablesResp represents a response from a DescribeRouteTables call
//
// See http://goo.gl/T3tVsg for more details.
type DescribeRouteTablesResp struct {
RequestId string `xml:"requestId"`
RouteTables []RouteTable `xml:"routeTableSet>item"`
}
// DescribeRouteTables describes one or more of your route tables
//
// See http://goo.gl/S0RVos for more details.
func (ec2 *EC2) DescribeRouteTables(routeTableIds []string, filter *Filter) (resp *DescribeRouteTablesResp, err error) {
params := makeParams("DescribeRouteTables")
addParamsList(params, "RouteTableId", routeTableIds)
filter.addParams(params)
resp = &DescribeRouteTablesResp{}
err = ec2.query(params, resp)
if err != nil {
return nil, err
}
return
}
// AssociateRouteTableResp represents a response from an AssociateRouteTable call
//
// See http://goo.gl/T4KlYk for more details.
type AssociateRouteTableResp struct {
RequestId string `xml:"requestId"`
AssociationId string `xml:"associationId"`
}
// AssociateRouteTable associates a subnet with a route table.
//
// The subnet and route table must be in the same VPC. This association causes
// traffic originating from the subnet to be routed according to the routes
// in the route table. The action returns an association ID, which you need in
// order to disassociate the route table from the subnet later.
// A route table can be associated with multiple subnets.
//
// See http://goo.gl/bfnONU for more details.
func (ec2 *EC2) AssociateRouteTable(routeTableId, subnetId string) (resp *AssociateRouteTableResp, err error) {
params := makeParams("AssociateRouteTable")
params["RouteTableId"] = routeTableId
params["SubnetId"] = subnetId
resp = &AssociateRouteTableResp{}
err = ec2.query(params, resp)
if err != nil {
return nil, err
}
return
}
// DisassociateRouteTableResp represents the response from a DisassociateRouteTable request
//
// See http://goo.gl/1v4reT for more details.
type DisassociateRouteTableResp struct {
RequestId string `xml:"requestId"`
Return bool `xml:"return"` // True if the request succeeds
}
// DisassociateRouteTable disassociates a subnet from a route table.
//
// See http://goo.gl/A4NJum for more details.
func (ec2 *EC2) DisassociateRouteTable(associationId string) (resp *DisassociateRouteTableResp, err error) {
params := makeParams("DisassociateRouteTable")
params["AssociationId"] = associationId
resp = &DisassociateRouteTableResp{}
err = ec2.query(params, resp)
if err != nil {
return nil, err
}
return
}
// ReplaceRouteTableAssociationResp represents a response from a ReplaceRouteTableAssociation call
//
// See http://goo.gl/VhILGe for more details.
type ReplaceRouteTableAssociationResp struct {
RequestId string `xml:"requestId"`
NewAssociationId string `xml:"newAssociationId"`
}
// ReplaceRouteTableAssociation changes the route table associated with a given subnet in a VPC.
//
// See http://goo.gl/kiit8j for more details.
func (ec2 *EC2) ReplaceRouteTableAssociation(associationId, routeTableId string) (resp *ReplaceRouteTableAssociationResp, err error) {
params := makeParams("ReplaceRouteTableAssociation")
params["AssociationId"] = associationId
params["RouteTableId"] = routeTableId
resp = &ReplaceRouteTableAssociationResp{}
err = ec2.query(params, resp)
if err != nil {
return nil, err
}
return
}
// DeleteRouteTableResp represents a response from a DeleteRouteTable request
//
// See http://goo.gl/b8usig for more details.
type DeleteRouteTableResp struct {
RequestId string `xml:"requestId"`
Return bool `xml:"return"` // True if the request succeeds
}
// DeleteRouteTable deletes the specified route table.
// You must disassociate the route table from any subnets before you can delete it.
// You can't delete the main route table.
//
// See http://goo.gl/crHxT2 for more details.
func (ec2 *EC2) DeleteRouteTable(routeTableId string) (resp *DeleteRouteTableResp, err error) {
params := makeParams("DeleteRouteTable")
params["RouteTableId"] = routeTableId
resp = &DeleteRouteTableResp{}
err = ec2.query(params, resp)
if err != nil {
return nil, err
}
return
}