aws-eni 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f19e4e251a90092251316683eb8f3562300422e5
4
- data.tar.gz: eb37b04707d8d8817fd247a3d440bc44d310dae2
3
+ metadata.gz: 14eb7ab252066d43cf0f289c7d5de6e796fe6b95
4
+ data.tar.gz: b96f9a46cc748d54bbef973a5af74fca467a7b22
5
5
  SHA512:
6
- metadata.gz: 56f2fca8525b755a14d3a78d654bdb5e148e593e53ba74bf193ad57e18ba25955ef5a8697ab2fc83184c6e5c43a3e3c67e80bedeb268884f2fe1c6af7e255497
7
- data.tar.gz: ae0239c63b23e14433074b71afad75f0ceda79954d5aa5adacbae4f9fcc559d577fe1280029aedf8da181777e4d11e113153cc413598926db8dedb9d3108e5ac
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 client library to manage AWS Elastic Network Interfaces from within an EC2 instance.
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 sync
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
- 10.0.1.23
32
- eth1:
33
- 10.0.2.54 => 54.25.169.87 (EIP)
34
- 10.0.2.72 => 52.82.17.251 (EIP)
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
- Add a new private IP
50
+ Associate a new Elastic IP
37
51
 
38
- $ aws-eni add eth1
39
- added 10.0.2.81
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
- Associate a new elastic IP
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
- $ aws-eni associate 10.0.2.81
44
- associated 10.0.2.81 => 52.171.254.36
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 dissociate 10.0.2.81
49
- dissociated 52.171.254.36 from 10.0.2.81
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 remove 10.0.2.81
54
- removed 10.0.2.81 from eth1
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/[my-github-username]/aws-eni/fork )
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`)
@@ -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'
@@ -1,5 +1,5 @@
1
1
  module Aws
2
2
  module ENI
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-eni
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Greiling