aws-ec2 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: aac747aab04913b92a6d0ca90cfba5879165e990ef388f990d644eace36da3d2
4
- data.tar.gz: 18066ba7f63d5323f83e4b548339ea17d2ca6385b05548e406dad3673c67d4df
3
+ metadata.gz: dea551aeb6e2d51a45460e30e408f4a82a32f61356f2e1391bcc837081272d28
4
+ data.tar.gz: f2dbabe12ceb094fba4fa6accb920e5a4bd38436ba5095dc1e26a1b53acb573c
5
5
  SHA512:
6
- metadata.gz: 27ad69472b8f9978e6bdda165fd1b4d6ccbd67227a09776670aae71704ce458ea815541c826caf1b32dd2a8b0ab218a87ae623fbbc5f09f79fdc8cf4e81c7769
7
- data.tar.gz: c6573808f67f7f8a9170995a9f4c55cbcba27c4da522dc5ed2b59d691cf2c91720834a4c67ef1e19f7c71f97303ea5a5c0325ba8a4010cfb14cc8934542f006d
6
+ metadata.gz: 158ca61a47b19c5ed7ebc3a81331170df07cd7c55dac58df4610948a14c2e7ead29f7f132c1654479b7b0559da220952681f950cfe0977ef1a9c7401584205f2
7
+ data.tar.gz: 0e1d65584446dc61b176a75f0d16bb6f113b8574e103980e592875c500d4d002f59e2faf82e99def3eae12d62af28b8d34e1e0662729655c02c0933bfcef2174
data/CHANGELOG.md CHANGED
@@ -3,5 +3,8 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.2.0]
7
+ - add config files support. example: config/development.yml
8
+
6
9
  ## [0.1.0]
7
10
  - initial release
data/README.md CHANGED
@@ -9,17 +9,17 @@ Example:
9
9
  ## Usage
10
10
 
11
11
  ```sh
12
- $ aws-ec2 create myserver --profile myserver
12
+ aws-ec2 create myserver --profile myserver
13
13
  ```
14
14
 
15
- In a nutshell, the profile parameters are passed to the ruby aws-sdk [AWS::EC2::Client#run_instances](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/EC2/Client.html#run_instances-instance_method) method. So you can specify any parameter you wish that is available there.
15
+ In a nutshell, the profile parameters are passed to the ruby aws-sdk [AWS::EC2::Client#run_instances](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/EC2/Client.html#run_instances-instance_method) method. So you can specify any parameter you wish that is available there. To check out what a profile looks like look at the [example default](example/profiles/default.yml)
16
16
 
17
17
  ### Convention
18
18
 
19
19
  By convention, the profile name matches the first parameter after the create command. So the command above could be shortened to:
20
20
 
21
21
  ```
22
- $ aws-ec2 create myserver
22
+ aws-ec2 create myserver
23
23
  ```
24
24
 
25
25
  ## User-Data
@@ -34,6 +34,14 @@ The user-data script is generated on the machine that is running the aws-ec2 com
34
34
 
35
35
  To use the user-data script when creating an EC2 instance, you can use the helper method in the profile.
36
36
 
37
+ ## Noop mode
38
+
39
+ You can do a test run with the `--noop` flag. This will print out what settings will be used to launch the instance.
40
+
41
+ ```sh
42
+ aws-ec2 create myserver --profile myserver --noop
43
+ ```
44
+
37
45
  ## Spot Instance Support
38
46
 
39
47
  Spot instance support natively supported by the AWS run_instances command. Simply add `instance_market_options` to the parameters to request for a spot instance. The available spot market options are available here:
@@ -4,7 +4,7 @@ exec > >(tee "/var/log/user-data.log" | logger -t user-data -s 2>/dev/console) 2
4
4
  export HOME=/root # user-data env runs in weird shell where user is root but HOME is not set
5
5
  <% pubkey_path = "#{ENV['HOME']}/.ssh/id_rsa.pub" -%>
6
6
  <% if File.exist?(pubkey_path) -%>
7
- <% pubkey = IO.read(pubkey_path) %>
7
+ <% pubkey = IO.read(pubkey_path).strip -%>
8
8
  # Automatically add user's public key
9
9
  echo <%= pubkey %> >> ~/.ssh/authorized_keys
10
10
  echo <%= pubkey %> >> /home/ec2-user/.ssh/authorized_keys
@@ -24,7 +24,7 @@ yum install -y git gcc make readline-devel openssl-devel
24
24
  git clone git://github.com/sstephenson/ruby-build.git /tmp/ruby-build
25
25
  cd /tmp/ruby-build
26
26
  ./install.sh
27
- echo 'export PATH="/usr/local/bin:$PATH' >> ~/.bashrc
27
+ echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
28
28
 
29
29
  # Install rbenv for root
30
30
  git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
data/lib/aws-ec2.rb CHANGED
@@ -12,4 +12,8 @@ module AwsEc2
12
12
  autoload :Spot, "aws_ec2/spot"
13
13
  autoload :TemplateHelper, "aws_ec2/template_helper"
14
14
  autoload :UserData, "aws_ec2/user_data"
15
+ autoload :Config, "aws_ec2/config"
16
+ autoload :Core, "aws_ec2/core"
17
+
18
+ extend Core
15
19
  end
@@ -0,0 +1,17 @@
1
+ require 'yaml'
2
+
3
+ module AwsEc2
4
+ class Config
5
+ def initialize(path="#{AwsEc2.root}/config/#{AwsEc2.env}.yml")
6
+ @path = path
7
+ end
8
+
9
+ def settings
10
+ YAML.load_file(@path)
11
+ rescue Errno::ENOENT => e
12
+ puts e.message
13
+ puts "The #{@path} does not exist. Please double check that it exists."
14
+ exit
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ module AwsEc2
2
+ module Core
3
+ @@config = nil
4
+ def config
5
+ @@config ||= Config.new.settings
6
+ end
7
+
8
+ def env
9
+ ENV['AWS_EC2_ENV'] || 'development'
10
+ end
11
+
12
+ def root
13
+ ENV['AWS_EC2_ROOT'] || '.'
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module AwsEc2
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-19 00:00:00.000000000 Z
11
+ date: 2018-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -165,6 +165,8 @@ files:
165
165
  - lib/aws_ec2/aws_services.rb
166
166
  - lib/aws_ec2/cli.rb
167
167
  - lib/aws_ec2/command.rb
168
+ - lib/aws_ec2/config.rb
169
+ - lib/aws_ec2/core.rb
168
170
  - lib/aws_ec2/create.rb
169
171
  - lib/aws_ec2/help.rb
170
172
  - lib/aws_ec2/help/create.md