aws-eni 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +77 -20
- data/lib/aws-eni/client.rb +2 -1
- data/lib/aws-eni/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14eb7ab252066d43cf0f289c7d5de6e796fe6b95
|
4
|
+
data.tar.gz: b96f9a46cc748d54bbef973a5af74fca467a7b22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48d1acfaaac7ca2ea0777305388fa1cac6f48c1b0a368dc9b08e493ff4a52274fc1813a34027b0c0858c27c4e3c91f3396df2090f1c9152f520133f0b0abbc75
|
7
|
+
data.tar.gz: fb0c4f4a9b9309b8236c729c7ac438f62579a057accf41488c5e3822cb0cb509d52f30aa6dc393ea2f6253cf4c720f568a0ef45e3628ad368c2b2e659210dc7d
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# aws-eni
|
2
2
|
|
3
|
-
A command line tool and
|
3
|
+
A command line tool and ruby library to manage AWS Elastic Network Interfaces from within an EC2 instance.
|
4
|
+
|
5
|
+
## Notes
|
6
|
+
|
7
|
+
Your AWS access credentials will be introspected from either the environment variables or the EC2 instance meta-data (see AWS IAM instance role documentation). Any command which requires a modification of the machine's interface configuration will require super-user privileges to access `/sbin/ip`.
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
@@ -18,45 +22,98 @@ Or install it yourself as:
|
|
18
22
|
|
19
23
|
$ gem install aws-eni
|
20
24
|
|
21
|
-
## Usage
|
25
|
+
## Command Line Usage
|
22
26
|
|
23
27
|
Synchronize your EC2 instance network interface config with AWS.
|
24
28
|
|
25
|
-
$ aws-eni
|
29
|
+
$ aws-eni config
|
30
|
+
synchronized interface config
|
26
31
|
|
27
32
|
List all interface cards, their IPs, and their associations
|
28
33
|
|
29
34
|
$ aws-eni list
|
30
|
-
eth0:
|
31
|
-
|
32
|
-
eth1:
|
33
|
-
|
34
|
-
|
35
|
+
eth0: ID eni-c02ef998 HWaddr 0e:96:b1:4a:15:2c Status UP
|
36
|
+
10.0.0.152 => 52.5.179.113
|
37
|
+
eth1: ID eni-585afa03 HWaddr 0e:90:7a:00:bf:7d Status UP
|
38
|
+
10.0.0.55
|
39
|
+
|
40
|
+
Add a secondary private IP
|
41
|
+
|
42
|
+
$ aws-eni assign eth1
|
43
|
+
IP 10.0.0.45 assigned to eth1 (eni-585afa03)
|
44
|
+
|
45
|
+
$ aws-eni list eth1
|
46
|
+
eth1: ID eni-585afa03 HWaddr 0e:90:7a:00:bf:7d Status UP
|
47
|
+
10.0.0.55
|
48
|
+
10.0.0.45
|
35
49
|
|
36
|
-
|
50
|
+
Associate a new Elastic IP
|
37
51
|
|
38
|
-
$ aws-eni
|
39
|
-
|
52
|
+
$ aws-eni assoc 10.0.0.45
|
53
|
+
EIP 52.5.141.210 (eipalloc-52117737) associated with 10.0.0.45 on eth1 (eni-585afa03)
|
40
54
|
|
41
|
-
|
55
|
+
$ aws-eni list eth1
|
56
|
+
eth1: ID eni-585afa03 HWaddr 0e:90:7a:00:bf:7d Status UP
|
57
|
+
10.0.0.55
|
58
|
+
10.0.0.45 => 52.5.141.210
|
42
59
|
|
43
|
-
|
44
|
-
|
60
|
+
Test a WAN connection through our newly associated Elastic IP
|
61
|
+
|
62
|
+
$ aws-eni test 52.5.141.210
|
63
|
+
EIP 52.5.141.210 connection successful
|
64
|
+
|
65
|
+
$ curl --interface 10.0.0.45 ifconfig.me/ip
|
66
|
+
52.5.141.210
|
45
67
|
|
46
68
|
Dissociate an elastic IP
|
47
69
|
|
48
|
-
$ aws-eni
|
49
|
-
|
70
|
+
$ aws-eni dissoc 52.5.141.210
|
71
|
+
EIP 52.5.141.210 (eipalloc-52117737) dissociated with 10.0.0.45 on eth1 (eni-585afa03)
|
72
|
+
|
73
|
+
$ aws-eni list eth1
|
74
|
+
eth1: ID eni-585afa03 HWaddr 0e:90:7a:00:bf:7d Status UP
|
75
|
+
10.0.0.55
|
76
|
+
10.0.0.45
|
50
77
|
|
51
|
-
Remove a private IP
|
78
|
+
Remove a secondary private IP
|
52
79
|
|
53
|
-
$ aws-eni
|
54
|
-
|
80
|
+
$ aws-eni unassign 10.0.0.45
|
81
|
+
IP 10.0.0.45 removed from eth1 (eni-585afa03)
|
82
|
+
|
83
|
+
$ aws-eni list
|
84
|
+
eth0: ID eni-c02ef998 HWaddr 0e:96:b1:4a:15:2c Status UP
|
85
|
+
10.0.0.152 => 52.5.179.113
|
86
|
+
eth1: ID eni-585afa03 HWaddr 0e:90:7a:00:bf:7d Status UP
|
87
|
+
10.0.0.55
|
88
|
+
|
89
|
+
## Library Usage
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
require 'aws-eni'
|
93
|
+
|
94
|
+
# create and attach a new interface
|
95
|
+
interface = Aws::ENI.create_interface
|
96
|
+
Aws::ENI.attach_interface(interface[:interface_id])
|
97
|
+
|
98
|
+
puts "Attached #{interface[:interface_id]} to #{interface[:device_name]}"
|
99
|
+
|
100
|
+
# add a secondary private IP to our new interface and associate an EIP
|
101
|
+
assign = Aws::ENI.assign_secondary_ip(interface[:device_name])
|
102
|
+
assoc = Aws::ENI.associate_elastic_ip(assign[:private_ip], block: false)
|
103
|
+
|
104
|
+
puts "Associated #{assoc[:public_ip]} with #{assoc[:private_ip]} on #{assoc[:device_name]}"
|
105
|
+
|
106
|
+
# verify our new public IP address (associate_elastic_ip normally does this
|
107
|
+
# automatically if 'block' option is not false)
|
108
|
+
if Aws::ENI.test_association(assoc[:public_ip])
|
109
|
+
puts "#{assoc[:public_ip]} can successfully connect to the internet via #{assoc[:private_ip]}"
|
110
|
+
else
|
111
|
+
```
|
55
112
|
|
56
113
|
|
57
114
|
## Contributing
|
58
115
|
|
59
|
-
1. Fork it ( https://github.com/
|
116
|
+
1. Fork it ( https://github.com/pixelcog/aws-eni/fork )
|
60
117
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
61
118
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
62
119
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/aws-eni/client.rb
CHANGED
@@ -26,6 +26,7 @@ module Aws
|
|
26
26
|
def client
|
27
27
|
@client ||= EC2::Client.new(region: region)
|
28
28
|
rescue StandardError => e
|
29
|
+
raise if e === Errors::ServiceError
|
29
30
|
raise Errors::EnvironmentError, 'Unable to initialize EC2 client'
|
30
31
|
end
|
31
32
|
|
@@ -145,7 +146,7 @@ module Aws
|
|
145
146
|
true
|
146
147
|
rescue EC2::Errors::UnauthorizedOperation
|
147
148
|
false
|
148
|
-
rescue
|
149
|
+
rescue EC2::Errors::ServiceError
|
149
150
|
raise Errors::ClientOperationError, 'Unexpected behavior while testing EC2 client permissions'
|
150
151
|
else
|
151
152
|
raise Errors::ClientOperationError, 'Unexpected behavior while testing EC2 client permissions'
|
data/lib/aws-eni/version.rb
CHANGED