aws-ec2 0.7.0 → 0.8.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: 0cf9927e8f80013a840c32371fdd48096c1f349002f3f9ee6141a369a326c002
4
- data.tar.gz: c8985115802338c38fab0d24f7d95f1dad7021eef7d15c874b53c1b3ef2e23e3
3
+ metadata.gz: c555a3e325c610710e0db4ab6839ae08a29020f96c06b740c5283b383d4c34a5
4
+ data.tar.gz: 3deb2d4cf2bbf39fb48dea6050ed1be67d2b3dcb4b68298bde8ad2bfc4ed8517
5
5
  SHA512:
6
- metadata.gz: dc87b7836701be0468190525dcf22e3373f5ba0bf9dc2d7050af88ec443de2c0bd83853bfe36683030d8e653f8edf9ac854d68ede7cab351a959f82cb3db3ffb
7
- data.tar.gz: 77de0393c45ccffaa18527d585465ea9864d76739b4fd73550884496fff5d0b55be51ab2a4677c64e0b75e68dd2e54315aacd21c3c07afa461fda1a4ce168fd1
6
+ metadata.gz: 81e3a1e2e6186fb146aa3377afab79430170853bb579c3782a877be38592a33dd0c4980d7bc68c7f992be5b4e4f31e85537b989459fe80b49395c9bcebf3bdaa
7
+ data.tar.gz: 51dacb024e89a664e3c0b642a21220a67108a264f35d39d41ff25f9f9ece4acfec906e9f3ac01300238efc38b3ec9061ba3f4aba04af03ec40cc8009c7604f7e
@@ -3,6 +3,10 @@
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.8.0]
7
+ - aws-ec2 upload_scripts command
8
+ - rename aws-ec2 compile to aws-ec2 compile_scripts
9
+
6
10
  ## [0.7.0]
7
11
  - Rid of name to profile convention, check profile exists and report to user
8
12
  if it does not exist. This is a more expected interface.
@@ -17,8 +17,6 @@ module AwsEc2
17
17
  autoload :Core, "aws_ec2/core"
18
18
  autoload :Dotenv, "aws_ec2/dotenv"
19
19
  autoload :Hook, "aws_ec2/hook"
20
- autoload :Compile, "aws_ec2/compile"
21
- autoload :S3, "aws_ec2/s3"
22
20
 
23
21
  extend Core
24
22
  end
@@ -1,6 +1,5 @@
1
1
  module AwsEc2
2
2
  class CLI < Command
3
- class_option :verbose, type: :boolean
4
3
  class_option :noop, type: :boolean
5
4
  class_option :profile, desc: "profile name to use"
6
5
 
@@ -20,10 +19,17 @@ module AwsEc2
20
19
  Ami.new(options.merge(name: name)).run
21
20
  end
22
21
 
23
- desc "compile", "compiles app/scripts and app/user-data to tmp folder"
24
- long_desc Help.text(:compile)
25
- def compile
26
- Compile.new(options).compile
22
+ desc "compile_scripts", "compiles app/scripts and app/user-data to tmp folder"
23
+ long_desc Help.text(:compile_scripts)
24
+ def compile_scripts
25
+ Script::Compile.new(options).compile
26
+ end
27
+
28
+ desc "upload_scripts", "compiles and uploads scripts to s3"
29
+ long_desc Help.text(:upload_scripts)
30
+ option :compile, type: :boolean, default: true, desc: "compile scripts before uploading"
31
+ def upload_scripts
32
+ Script::Upload.new(options).upload
27
33
  end
28
34
  end
29
35
  end
@@ -28,7 +28,7 @@ module AwsEc2
28
28
  # scripts_s3_bucket: my-bucket
29
29
  def sync_scripts_to_s3
30
30
  if AwsEc2.config["scripts_s3_bucket"]
31
- S3.new(@options).upload
31
+ Script::Upload.new(@options).upload
32
32
  end
33
33
  end
34
34
 
@@ -2,10 +2,12 @@ Examples:
2
2
 
3
3
  $ aws-ec2 ami myrubyami --profile ruby --noop
4
4
 
5
- The launches an EC2 instance with using the profile running it's user-data script. An ami creation script is appended to the end of the user-data script. The ami creation script uses the AWS CLI `aws ec2 create-image` command to create an AMI. It is useful to include to timestamp as a part of the ami name with the date command.
5
+ Launches an EC2 instance to create an AMI. An AMI creation script is appended to the end of the user-data script. The AMI creation script calls `aws ec2 create-image` and causes the instance to reboot at the end.
6
+
7
+ It is useful to include to timestamp as a part of the AMI name with the date command.
6
8
 
7
9
  $ aws-ec2 ami $(date "+ruby-2.5.0_%Y-%m-%d-%H-%M") --profile ruby --noop
8
10
 
9
- Note, it is recommended to use the `set -e` option in your user-data script so that if the script fails, the ami creation script is never reached and instance is left behind so you can debug.
11
+ The instance also automatically gets terminated and cleaned up by a termination script appended to user-data.
10
12
 
11
- The instance also automatically gets terminated and cleaned up.
13
+ It is recommended to use the `set -e` option in your user-data script so that if the script fails, the AMI creation script is never reached and the instance is left behind so you can debug.
@@ -0,0 +1,5 @@
1
+ Examples:
2
+
3
+ $ aws-ec2 compile_scripts
4
+
5
+ Compiles app/scripts and app/user-data files to the tmp folder. Useful for inspection.
@@ -2,10 +2,6 @@ Examples:
2
2
 
3
3
  $ aws-ec2 create my-instance
4
4
 
5
- If you want to create an ami at the end of of a successful user-data script run you can use the `--ami` option. Example:
5
+ To see the snippet of code that gets added to the user-data script you can use the `--noop` option and then view the generated /tmp/aws-ec2/user-data.txt.
6
6
 
7
- $ aws-ec2 create my-instance --ami myname
8
-
9
- To see the snippet of code that gets added to the user-data script you can use the aws-ec2 userdata command.
10
-
11
- $ aws-ec2 userdata myscript --ami myname
7
+ $ aws-ec2 create myscript --noop
@@ -0,0 +1,9 @@
1
+ Examples:
2
+
3
+ $ aws-ec2 upload_scripts
4
+
5
+ Compiles the app/scripts and app/user-data files to the tmp folder. Then uploads the files to an s3 bucket that is configured in config/[AWS_EC2_ENV].yml. Example scripts_s3_bucket config:
6
+
7
+ ```yaml
8
+ scripts_s3_bucket: my-bucket # enables auto sync to s3
9
+ ```
@@ -1,5 +1,8 @@
1
1
  module AwsEc2
2
2
  class Script
3
+ autoload :Compile, "aws_ec2/script/compile"
4
+ autoload :Upload, "aws_ec2/script/upload"
5
+
3
6
  def initialize(options={})
4
7
  @options = options
5
8
  end
@@ -1,8 +1,9 @@
1
1
  require 'fileutils'
2
2
 
3
- module AwsEc2
4
- class Compile < Base
5
- include TemplateHelper
3
+ # Class for aws-ec2 compile_scripts command
4
+ class AwsEc2::Script
5
+ class Compile < AwsEc2::Base
6
+ include AwsEc2::TemplateHelper
6
7
  BUILD_ROOT = "tmp"
7
8
 
8
9
  def compile
@@ -1,13 +1,16 @@
1
- module AwsEc2
2
- class S3
1
+ require 'fileutils'
2
+
3
+ # Class for aws-ec2 upload_scripts command
4
+ class AwsEc2::Script
5
+ class Upload < AwsEc2::Base
3
6
  def initialize(options={})
4
7
  @options = options
5
8
  end
6
9
 
7
- def upload(skip_compile=false)
8
- compiler.compile unless skip_compile
10
+ def upload
11
+ compiler.compile if @options[:compile]
9
12
  sync_scripts_to_s3
10
- compiler.clean unless ENV['AWS_EC2_KEEP'] || skip_compile
13
+ compiler.clean if @options[:compile] and !ENV['AWS_EC2_KEEP']
11
14
  end
12
15
 
13
16
  def sync_scripts_to_s3
@@ -1,3 +1,3 @@
1
1
  module AwsEc2
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
@@ -204,7 +204,6 @@ files:
204
204
  - lib/aws_ec2/base.rb
205
205
  - lib/aws_ec2/cli.rb
206
206
  - lib/aws_ec2/command.rb
207
- - lib/aws_ec2/compile.rb
208
207
  - lib/aws_ec2/config.rb
209
208
  - lib/aws_ec2/core.rb
210
209
  - lib/aws_ec2/create.rb
@@ -212,12 +211,14 @@ files:
212
211
  - lib/aws_ec2/dotenv.rb
213
212
  - lib/aws_ec2/help.rb
214
213
  - lib/aws_ec2/help/ami.md
215
- - lib/aws_ec2/help/compile.md
214
+ - lib/aws_ec2/help/compile_scripts.md
216
215
  - lib/aws_ec2/help/create.md
216
+ - lib/aws_ec2/help/upload_scripts.md
217
217
  - lib/aws_ec2/hook.rb
218
218
  - lib/aws_ec2/profile.rb
219
- - lib/aws_ec2/s3.rb
220
219
  - lib/aws_ec2/script.rb
220
+ - lib/aws_ec2/script/compile.rb
221
+ - lib/aws_ec2/script/upload.rb
221
222
  - lib/aws_ec2/scripts/ami_creation.sh
222
223
  - lib/aws_ec2/scripts/auto_terminate.sh
223
224
  - lib/aws_ec2/template_helper.rb
@@ -1,5 +0,0 @@
1
- Examples:
2
-
3
- $ aws-ec2 compile
4
-
5
- Compiles the scripts in app/scripts and app/user-data to the tmp folder. Useful for inspection.