aws-ec2 0.5.2 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d2b33737beb7cc7f0b0f62447883b3cb7ad5235a4b534359f2128b42cde928b
4
- data.tar.gz: b49727f0247691d3f21370fad4ba618064d3c7d69031500241e322edf33ce4bf
3
+ metadata.gz: 42b56c4659b31e265e4cf80becf741303ea43fb9a1885724f12e6a0e76fbfb1e
4
+ data.tar.gz: e23f45d1462ee2897a20ad52fe2d57ed207090c8d38eee1d3869b0261f100fc7
5
5
  SHA512:
6
- metadata.gz: fe62f5a533ba85f766c956e500c3ca5b7771df36936948c1f89c44f359fec08218343dcbbedef841f9a005f3f7127907cda62d3d8b1c9635232985c4741309db
7
- data.tar.gz: e0c4b8db0bf9195693e3be9321376ffa752740d4ee6ac6584b2f44ccbd95f2162e4b489546de2a7672b06b3424f8038dd13d630414d2a2f87255c48b6e327aa7
6
+ metadata.gz: a7b83b59c84b4da126a0d1e6ea7df4ba88c340da499edd2ef35b4d94c69c05d318e5542d0d60ba9698a5633666cfd0c81315c2a56370bb0e0dc5684b2e86ed89
7
+ data.tar.gz: c8e7a78cbff83c6f40366b5c90d235fc84f3605fa1a2052185a37b9bacc65373ad8b19c2af1ec8430973d7a0db78342b1809ae752a6199e208ba296507647341
data/CHANGELOG.md CHANGED
@@ -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.6.0]
7
+ - add scripts_s3_bucket config option
8
+ - halt script if hooks fail
9
+
6
10
  ## [0.5.2]
7
11
  - remove byebug debugging
8
12
 
data/README.md CHANGED
@@ -91,7 +91,7 @@ db_subnet_group_name: default
91
91
  - subnet-789
92
92
  security_group_ids:
93
93
  - sg-123
94
- s3_bucket: mybucket # for the user-data shared scripts
94
+ scripts_s3_bucket: mybucket # enables s3 uploading of generated app/scripts
95
95
  ```
96
96
 
97
97
  The variables are accessible via the `config` helper method. Example (only showing the part of the profile), `profiles/default.yml`:
data/lib/aws-ec2.rb CHANGED
@@ -17,6 +17,7 @@ module AwsEc2
17
17
  autoload :Dotenv, "aws_ec2/dotenv"
18
18
  autoload :Hook, "aws_ec2/hook"
19
19
  autoload :Compile, "aws_ec2/compile"
20
+ autoload :S3, "aws_ec2/s3"
20
21
 
21
22
  extend Core
22
23
  end
@@ -24,7 +24,7 @@ module AwsEc2
24
24
  end
25
25
 
26
26
  def clean
27
- FileUtils.rm_rf(BUILD_ROOT)
27
+ FileUtils.rm_rf("#{BUILD_ROOT}/app")
28
28
  end
29
29
  end
30
30
  end
@@ -15,11 +15,22 @@ module AwsEc2
15
15
  end
16
16
 
17
17
  Hook.run(:before_run_instances, @options)
18
+ sync_scripts_to_s3
18
19
  resp = ec2.run_instances(params)
19
20
  puts "EC2 instance #{@options[:name]} created! 🎉"
20
21
  puts "Visit https://console.aws.amazon.com/ec2/home to check on the status"
21
22
  end
22
23
 
24
+ # Configured by config/[AWS_EC2_ENV].yml.
25
+ # Example: config/development.yml:
26
+ #
27
+ # scripts_s3_bucket: my-bucket
28
+ def sync_scripts_to_s3
29
+ if AwsEc2.config["scripts_s3_bucket"]
30
+ S3.new(@options).upload
31
+ end
32
+ end
33
+
23
34
  # params are main derived from profile files
24
35
  def params
25
36
  @params ||= Params.new(@options).generate
data/lib/aws_ec2/hook.rb CHANGED
@@ -22,7 +22,8 @@ module AwsEc2
22
22
 
23
23
  def sh(command)
24
24
  puts "=> #{command}".colorize(:cyan)
25
- system(command)
25
+ success = system(command)
26
+ abort("Command failed") unless success
26
27
  end
27
28
 
28
29
  def self.run(name, options={})
data/lib/aws_ec2/s3.rb ADDED
@@ -0,0 +1,29 @@
1
+ module AwsEc2
2
+ class S3
3
+ def initialize(options={})
4
+ @options = options
5
+ end
6
+
7
+ def upload(skip_compile=false)
8
+ compiler.compile unless skip_compile
9
+ sync_scripts_to_s3
10
+ compiler.clean unless ENV['AWS_EC2_KEEP'] || skip_compile
11
+ end
12
+
13
+ def sync_scripts_to_s3
14
+ puts "Uploading tmp/app to s3..."
15
+ s3_bucket = AwsEc2.config["scripts_s3_bucket"]
16
+ s3_path = AwsEc2.config["scripts_s3_path"] || "ec2/app"
17
+ sh "aws s3 sync tmp/app s3://#{s3_bucket}/#{s3_path}"
18
+ end
19
+
20
+ def sh(command)
21
+ puts "=> #{command}"
22
+ system command
23
+ end
24
+
25
+ def compiler
26
+ @compiler ||= Compile.new(@options)
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module AwsEc2
2
- VERSION = "0.5.2"
2
+ VERSION = "0.6.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.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
@@ -215,6 +215,7 @@ files:
215
215
  - lib/aws_ec2/help/compile.md
216
216
  - lib/aws_ec2/help/create.md
217
217
  - lib/aws_ec2/hook.rb
218
+ - lib/aws_ec2/s3.rb
218
219
  - lib/aws_ec2/script.rb
219
220
  - lib/aws_ec2/scripts/ami_creation.sh
220
221
  - lib/aws_ec2/scripts/auto_terminate.sh