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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/aws-ec2.rb +1 -0
- data/lib/aws_ec2/compile.rb +1 -1
- data/lib/aws_ec2/create.rb +11 -0
- data/lib/aws_ec2/hook.rb +2 -1
- data/lib/aws_ec2/s3.rb +29 -0
- data/lib/aws_ec2/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42b56c4659b31e265e4cf80becf741303ea43fb9a1885724f12e6a0e76fbfb1e
|
4
|
+
data.tar.gz: e23f45d1462ee2897a20ad52fe2d57ed207090c8d38eee1d3869b0261f100fc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
data/lib/aws_ec2/compile.rb
CHANGED
data/lib/aws_ec2/create.rb
CHANGED
@@ -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
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
|
data/lib/aws_ec2/version.rb
CHANGED
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.
|
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
|