aws-ec2 1.0.0 → 1.1.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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/CHANGELOG.md +10 -0
  4. data/README.md +19 -15
  5. data/docs/example/app/user-data/bootstrap.sh +0 -12
  6. data/lib/aws_ec2/cli.rb +8 -3
  7. data/lib/aws_ec2/core.rb +25 -4
  8. data/lib/aws_ec2/create.rb +19 -9
  9. data/lib/aws_ec2/help/upload.md +3 -2
  10. data/lib/aws_ec2/profile.rb +10 -1
  11. data/lib/aws_ec2/script.rb +19 -3
  12. data/lib/aws_ec2/script/compile.rb +2 -2
  13. data/lib/aws_ec2/script/compress.rb +1 -1
  14. data/lib/aws_ec2/script/templates/ami_creation.sh +12 -0
  15. data/lib/aws_ec2/script/templates/auto_terminate.sh +11 -0
  16. data/lib/aws_ec2/script/templates/auto_terminate_after_timeout.sh +5 -0
  17. data/lib/aws_ec2/script/templates/cloudwatch.sh +3 -0
  18. data/lib/aws_ec2/script/templates/extract_aws_ec2_scripts.sh +48 -0
  19. data/lib/aws_ec2/script/upload.rb +1 -1
  20. data/lib/aws_ec2/scripts/auto_terminate.sh +10 -91
  21. data/lib/aws_ec2/scripts/auto_terminate/after_timeout.sh +18 -0
  22. data/lib/aws_ec2/scripts/auto_terminate/functions.sh +128 -0
  23. data/lib/aws_ec2/scripts/auto_terminate/functions/amazonlinux2.sh +10 -0
  24. data/lib/aws_ec2/scripts/auto_terminate/functions/ubuntu.sh +11 -0
  25. data/lib/aws_ec2/scripts/auto_terminate/setup.sh +31 -0
  26. data/lib/aws_ec2/scripts/cloudwatch.sh +22 -0
  27. data/lib/aws_ec2/scripts/cloudwatch/configure.sh +74 -0
  28. data/lib/aws_ec2/scripts/cloudwatch/install.sh +4 -0
  29. data/lib/aws_ec2/scripts/cloudwatch/service.sh +19 -0
  30. data/lib/aws_ec2/scripts/shared/functions.sh +44 -0
  31. data/lib/aws_ec2/setting.rb +15 -4
  32. data/lib/aws_ec2/template/helper/core_helper.rb +46 -7
  33. data/lib/aws_ec2/template/helper/ssh_key_helper.rb +1 -1
  34. data/lib/aws_ec2/version.rb +1 -1
  35. data/spec/fixtures/demo_project/config/settings.yml +22 -0
  36. data/spec/lib/cli_spec.rb +0 -7
  37. data/spec/lib/params_spec.rb +71 -0
  38. metadata +21 -3
  39. data/lib/aws_ec2/scripts/ami_creation.sh +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41c5379df446fa7ebaeb8a4e7243b70c6b8ef3c91afc6a61af1ab42181695c8a
4
- data.tar.gz: 8d4558040a99f9496bfdf74b1d43aeb470229f370ae9b14cda174a4096e83f34
3
+ metadata.gz: 479b890e45d465cd48dad82e9063f5b9ef3074ca05a47461f68ed93ce8b0fd55
4
+ data.tar.gz: 062a19ef9048e2ff0e284f97b1e1a21a7c44034642ac5639dfef53581f61c23a
5
5
  SHA512:
6
- metadata.gz: 0ce576737f3e0dc3c225c581d1507e9a9d338e048db588f7776cd2faa45e73d580b1789e43103d5e9d61298016457c4ec011e3eddf387eb14573fea292550d78
7
- data.tar.gz: 94969a46aeb9d0e203b141dc7114df127b1bf353405c2d0574996493baaeea4d79c2863773e895d2d47b4228968c0876e94cba8e0606d628a69d893fac045524
6
+ metadata.gz: 7e0452f43bb90b093a39e889a65b581620532ac7dc8803e70d74c5b2a0dc56da645273bcf7814aee9de09d666cc61f05305ab94132e7d745d0b69994b27d3cf3
7
+ data.tar.gz: 3731a44ca9cd7597fbee6f36cb62817ce801fb9404c26f05a7c98f8ade9303f487eca36df301e1c27f0e92d405f8e4f44ac10527fcb1ed32137c3454f865e73d
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --color
2
2
  --format documentation
3
+ --require spec_helper
@@ -3,6 +3,16 @@
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
+ ## [1.1.0]
7
+ - Merge pull request #5 from tongueroo/auto-terminate
8
+ - allow AWS_RDS_CODE_VERSION env variable
9
+ - restructure way scripts work for sanity
10
+ - bash scripts: ami_creation.sh and auto_terminate.sh
11
+ - support only amazonlinux2 and ubuntu
12
+
13
+ ## [1.0.1]
14
+ - update ordering of the info displayed
15
+
6
16
  ## [1.0.0]
7
17
  - Merge pull request #1 from tongueroo/cli-template-upgrade
8
18
  - Merge pull request #2 from tongueroo/render_me_pretty
data/README.md CHANGED
@@ -54,10 +54,10 @@ Directory | Description
54
54
  ------------- | -------------
55
55
  app/helpers | Custom helpers methods. Define them as modules and their methods are made available whenever ERB is available: `profiles`, `app/scripts`, `app/user-data` files, etc. For example, you would define a `module FooHelper` in `app/helpers/foo_helper.rb`.
56
56
  app/partials | Your partials that can to be included in other scripts. This is used in conjunction with the `partial` helper method. With great power comes great responsibility. It is recommended to use partials sparely to keep scripts more straightforward.
57
- app/scripts | Where you define common scripts that can be used to configure the server. These scripts can be automatically uploaded to an s3 bucket for later downloading in your user-data script by setting the `scripts_s3_bucket` config option.
57
+ app/scripts | Where you define common scripts that can be used to configure the server. These scripts can be automatically uploaded to an s3 bucket for later downloading in your user-data script by setting the `s3_folder` settings option.
58
58
  app/user-data | Your user-data scripts that are used to bootstrap EC2 instance.
59
- config/[AWS_EC2_ENV].yml | The config file where you set configs that you want available in your templating logic. Examples are: `config/development.yml` and `config/production.yml`. You access the config variables with the `<%= config["var"] %>` helper.
60
59
  app/user-data/layouts | user-data scripts support layouts. You user-data layouts go in here.
60
+ config/[AWS_EC2_ENV].yml | The config file where you set configs that you want available in your templating logic. Examples are: `config/development.yml` and `config/production.yml`. You access the config variables with the `<%= config["var"] %>` helper.
61
61
  profiles | Your profile files. These files mainly contain parameters that are passed to the aws-sdk run_instances API method.
62
62
  tmp | Where the generated scripts get compiled to. You can manually invoke the compilation via `aws-ec2 compile` to inspect what is generated. This is automatically done as part of the `aws-ec2` create command.
63
63
 
@@ -71,8 +71,9 @@ user_data | Allows you to embed a generated user_data script. More details on t
71
71
  config | Access to the variables set in config/[AWS_EC2_ENV].yml. Examples are `config/development.yml` and `config/production.yml`.
72
72
  latest_ami | Returns an AMI id by searching the AMI name pattern and sorting in reverse order. Example: `latest_ami("ruby-2.5.0_*")` would return the latest ruby AMIs are named with timestamps at the end like so: `ruby-2.5.0_2018-01-30-05-36-02` and `ruby-2.5.0_2018-01-29-05-36-02`.
73
73
  search_ami | Returns a collection of AMI image objects based on a search pattern. The query searches on the AMI name.
74
+ extract_scripts | Use this in your bash script to extract the `app/scripts` files that get uploaded to s3.
74
75
 
75
- For a full list of all the template helpers check out: [aws_ec2/template_helper](lib/aws_ec2/template_helper).
76
+ For a full list of all the template helpers check out: [lib/aws_ec2/template/helper](lib/aws_ec2/template/helper).
76
77
 
77
78
  You can also define custom helpers in the `app/helpers` folder as ruby modules with the naming convention `*_helper.rb`. For example, you would define a `module FooHelper` in `app/helpers/foo_helper.rb`. Custom helpers are first-class citizens and have access to the same variables, methods, and scope as built-in helpers.
78
79
 
@@ -152,9 +153,6 @@ subnets:
152
153
  - subnet-789
153
154
  security_group_ids:
154
155
  - sg-123
155
- scripts_s3_bucket: mybucket # enables s3 uploading of generated app/scripts
156
- # compile_clean: true # uncomment to automatically remove the
157
- # compiled scripts in tmp after aws-ec2 create
158
156
  ```
159
157
 
160
158
  The variables are accessed via the `config` helper method. Here's a filtered example where it shows the relevant part of a profile: `profiles/default.yml`:
@@ -167,17 +165,23 @@ subnet_id: <%= config["subnets"].shuffle %>
167
165
  ...
168
166
  ```
169
167
 
170
- #### Config Options
171
-
172
- There are some config options that change the behavior of the ec2-aws:
173
-
174
- Option | Description
175
- --- | ---
176
- scripts_s3_bucket | Set this to the bucket name where you want the generated scripts in app/scripts and app/user-data to be uploaded to. The upload sync happens right before the internal to run_instances call that launches the instance. If you need more custom logic, you can use the `before_run_instances` hook, covered in the Hooks section.
177
-
178
168
  ### Settings
179
169
 
180
- A `config/settings.yml` file controls the internal behavior of aws-ec2. It is different from config files which are meant for user defined varibles. Settings variables are for internal use.
170
+ A `config/settings.yml` file controls the internal behavior of aws-ec2. It is different from config files which are meant for user defined varibles. Settings variables are for internal use. Example:
171
+
172
+ ```yaml
173
+ development:
174
+ # By setting s3_folder, aws-ec2 will automatically tarball and upload your scripts
175
+ # to set. You then can then use the extract_scripts helper method to download
176
+ # the scripts onto the server.
177
+ s3_folder: boltops-infra-stag/ec2
178
+ # compile_clean: true # uncomment to clean at the end of a compile
179
+ # extract_scripts:
180
+ # to: "/opt"
181
+ # as: "ec2-user"
182
+
183
+ production:
184
+ ```
181
185
 
182
186
  ### Hooks
183
187
 
@@ -1,18 +1,6 @@
1
1
  #!/bin/bash -exu
2
2
 
3
- exec > >(tee "/var/log/user-data.log" | logger -t user-data -s 2>/dev/console) 2>&1
4
3
  export HOME=/root # user-data env runs in weird shell where user is root but HOME is not set
5
- <% pubkey_path = "#{ENV['HOME']}/.ssh/id_rsa.pub" -%>
6
- <% if File.exist?(pubkey_path) -%>
7
- <% pubkey = IO.read(pubkey_path).strip -%>
8
- # Automatically add user's public key
9
- echo <%= pubkey %> >> ~/.ssh/authorized_keys
10
- echo <%= pubkey %> >> /home/ec2-user/.ssh/authorized_keys
11
- chown ec2-user:ec2-user /home/ec2-user/.ssh/authorized_keys
12
- <% else %>
13
- # WARN: unable to find a ~/.ssh/id_rsa.pub locally on your machine. user: <%= ENV['USER'] %>
14
- # Unable to automatically add the public key
15
- <% end -%>
16
4
 
17
5
  sudo yum install -y postgresql
18
6
 
@@ -3,19 +3,24 @@ module AwsEc2
3
3
  class_option :noop, type: :boolean
4
4
  class_option :profile, desc: "profile name to use"
5
5
 
6
+ common_options = Proc.new do
7
+ option :auto_terminate, type: :boolean, default: false, desc: "automatically terminate the instance at the end of user-data"
8
+ option :cloudwatch, type: :boolean, default: false, desc: "enable cloudwatch logging, only supported for amazonlinux"
9
+ end
10
+
6
11
  desc "create NAME", "create ec2 instance"
7
12
  long_desc Help.text(:create)
8
13
  option :ami_name, desc: "when specified, an ami creation script is appended to the user-data script"
9
- option :auto_terminate, type: :boolean, default: false, desc: "automatically terminate the instance at the end of user-data"
10
- option :source_ami, desc: "override the source image_id in profile"
11
14
  option :randomize, type: :boolean, desc: "append random characters to end of name"
15
+ option :source_ami, desc: "override the source image_id in profile"
16
+ common_options.call
12
17
  def create(name)
13
18
  Create.new(options.merge(name: name)).run
14
19
  end
15
20
 
16
21
  desc "ami NAME", "launches instance and uses it create AMI"
17
22
  long_desc Help.text(:ami)
18
- option :auto_terminate, type: :boolean, default: true, desc: "automatically terminate the instance at the end of user-data"
23
+ common_options.call
19
24
  def ami(name)
20
25
  Ami.new(options.merge(name: name)).run
21
26
  end
@@ -1,4 +1,5 @@
1
1
  require 'pathname'
2
+ require 'yaml'
2
3
 
3
4
  module AwsEc2
4
5
  module Core
@@ -11,10 +12,6 @@ module AwsEc2
11
12
  Setting.new.data
12
13
  end
13
14
 
14
- def env
15
- ENV['AWS_EC2_ENV'] || 'development'
16
- end
17
-
18
15
  def root
19
16
  path = ENV['AWS_EC2_ROOT'] || '.'
20
17
  Pathname.new(path)
@@ -26,5 +23,29 @@ module AwsEc2
26
23
  exit
27
24
  end
28
25
  end
26
+
27
+ @@env = nil
28
+ def env
29
+ return @@env if @@env
30
+ env = env_from_profile(ENV['AWS_PROFILE']) || 'development'
31
+ env = ENV['AWS_EC2_ENV'] if ENV['AWS_EC2_ENV'] # highest precedence
32
+ @@env = env
33
+ end
34
+
35
+ private
36
+ # Do not use the Setting class to load the profile because it can cause an
37
+ # infinite loop then if we decide to use AwsEc2.env from within settings class.
38
+ def env_from_profile(aws_profile)
39
+ settings_path = "#{AwsEc2.root}/config/settings.yml"
40
+ return unless File.exist?(settings_path)
41
+
42
+ data = YAML.load_file(settings_path)
43
+ env = data.find do |_env, setting|
44
+ setting ||= {}
45
+ profiles = setting['aws_profiles']
46
+ profiles && profiles.include?(aws_profile)
47
+ end
48
+ env.first if env
49
+ end
29
50
  end
30
51
  end
@@ -12,18 +12,19 @@ module AwsEc2
12
12
  def run
13
13
  Profile.new(@options).check!
14
14
 
15
- puts "Creating EC2 instance #{@name}..."
16
- display_info
17
-
18
15
  Hook.run(:before_run_instances, @options)
19
16
  sync_scripts_to_s3
20
17
 
18
+ puts "Creating EC2 instance #{@name.colorize(:green)}"
19
+ display_ec2_info
21
20
  if @options[:noop]
22
21
  puts "NOOP mode enabled. EC2 instance not created."
23
22
  return
24
23
  end
25
- run_instances(params)
26
- puts "EC2 instance #{@name} created! 🎉"
24
+ resp = run_instances(params)
25
+ instance_id = resp.instances.first.instance_id
26
+ display_spot_info(instance_id)
27
+ puts "EC2 instance #{@name} created: #{instance_id} 🎉"
27
28
  puts "Visit https://console.aws.amazon.com/ec2/home to check on the status"
28
29
  end
29
30
 
@@ -33,10 +34,11 @@ module AwsEc2
33
34
  handle_ec2_service_error!(e)
34
35
  end
35
36
 
36
- # Configured by config/[AWS_EC2_ENV].yml.
37
- # Example: config/development.yml:
37
+ # Configured by config/settings.yml.
38
+ # Example: config/settings.yml:
38
39
  #
39
- # scripts_s3_bucket: my-bucket
40
+ # development:
41
+ # s3_folder: my-bucket/folder
40
42
  def sync_scripts_to_s3
41
43
  if AwsEc2.settings["s3_folder"]
42
44
  Script::Upload.new(@options).run
@@ -48,7 +50,15 @@ module AwsEc2
48
50
  @params ||= Params.new(@options).generate
49
51
  end
50
52
 
51
- def display_info
53
+ def display_spot_info(instance_id)
54
+ resp = ec2.describe_instances(instance_ids: [instance_id])
55
+ spot_id = resp.reservations.first.instances.first.spot_instance_request_id
56
+ return unless spot_id
57
+
58
+ puts "Spot instance request id: #{spot_id}"
59
+ end
60
+
61
+ def display_ec2_info
52
62
  puts "Using the following parameters:"
53
63
  pretty_display(params)
54
64
 
@@ -2,8 +2,9 @@ Examples:
2
2
 
3
3
  $ aws-ec2 upload
4
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:
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/settings.yml. Example s3_folder setting:
6
6
 
7
7
  ```yaml
8
- scripts_s3_bucket: my-bucket # enables auto sync to s3
8
+ development:
9
+ s3_folder: my-bucket/folder # enables auto sync to s3
9
10
  ```
@@ -25,7 +25,16 @@ module AwsEc2
25
25
 
26
26
  puts "Using profile: #{file}".colorize(:green)
27
27
  text = RenderMePretty.result(file, context: context)
28
- data = YAML.load(text)
28
+ begin
29
+ data = YAML.load(text)
30
+ rescue Psych::SyntaxError => e
31
+ tmp_file = file.sub("profiles", "tmp")
32
+ IO.write(tmp_file, text)
33
+ puts "There was an error evaluating in your yaml file #{file}".colorize(:red)
34
+ puts "The evaludated yaml file has been saved at #{tmp_file} for debugging."
35
+ puts "ERROR: #{e.message}"
36
+ exit 1
37
+ end
29
38
  data ? data : {} # in case the file is empty
30
39
  data.has_key?("run_instances") ? data["run_instances"] : data
31
40
  end
@@ -8,23 +8,39 @@ module AwsEc2
8
8
  @options = options
9
9
  end
10
10
 
11
+ def add_to_user_data!(user_data)
12
+ user_data
13
+ end
14
+
15
+ def auto_terminate_after_timeout
16
+ load_template("auto_terminate_after_timeout.sh")
17
+ end
18
+
11
19
  def auto_terminate
20
+ # set variables for the template
12
21
  @ami_name = @options[:ami_name]
13
22
  load_template("auto_terminate.sh")
14
23
  end
15
24
 
25
+ def cloudwatch
26
+ load_template("cloudwatch.sh")
27
+ end
28
+
16
29
  def create_ami
17
- # set some variables for the template
30
+ # set variables for the template
18
31
  @ami_name = @options[:ami_name]
19
32
  @region = `aws configure get region`.strip rescue 'us-east-1'
20
33
  load_template("ami_creation.sh")
21
34
  end
22
35
 
36
+ def extract_aws_ec2_scripts
37
+ load_template("extract_aws_ec2_scripts.sh")
38
+ end
39
+
23
40
  private
24
41
  def load_template(name)
25
- template = IO.read(File.expand_path("../scripts/#{name}", __FILE__))
42
+ template = IO.read(File.expand_path("script/templates/#{name}", File.dirname(__FILE__)))
26
43
  text = ERB.new(template, nil, "-").result(binding)
27
- "#" * 60 + "\n#{text}"
28
44
  end
29
45
  end
30
46
  end
@@ -20,14 +20,14 @@ class AwsEc2::Script
20
20
  end
21
21
 
22
22
  def compile_folder(folder, layout_path=false)
23
- puts "Compiling app/#{folder}:".colorize(:green)
23
+ puts "Compiling app/#{folder} to tmp/app/#{folder}.".colorize(:green)
24
24
  Dir.glob("#{AwsEc2.root}/app/#{folder}/**/*").each do |path|
25
25
  next if File.directory?(path)
26
26
  next if path.include?("layouts")
27
27
 
28
28
  result = RenderMePretty.result(path, layout: layout_path, context: context)
29
29
  tmp_path = path.sub(%r{.*/app/}, "#{BUILD_ROOT}/app/")
30
- puts " #{tmp_path}"
30
+ puts " #{tmp_path}" if @options[:verbose]
31
31
  FileUtils.mkdir_p(File.dirname(tmp_path))
32
32
  IO.write(tmp_path, result)
33
33
  end
@@ -4,7 +4,7 @@ class AwsEc2::Script
4
4
  class Compress < AwsEc2::Base
5
5
  def compress
6
6
  reset
7
- puts "Tarballing #{BUILD_ROOT}/app/scripts folder to scripts.tgz"
7
+ puts "Tarballing #{BUILD_ROOT}/app/scripts folder to scripts.tgz".colorize(:green)
8
8
  tarball_path = create_tarball
9
9
  save_scripts_info(tarball_path)
10
10
  puts "Tarball created at #{tarball_path}"
@@ -0,0 +1,12 @@
1
+ #!/bin/bash -eux
2
+
3
+ # Create AMI Bundle
4
+ AMI_NAME="<%= @ami_name %>"
5
+ INSTANCE_ID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)
6
+ REGION=$(aws configure get region)
7
+ # Note this will cause the instance to reboot. Not using the --no-reboot flag
8
+ # to ensure consistent AMI creation.
9
+ SOURCE_AMI_ID=$(wget -q -O - http://169.254.169.254/latest/meta-data/ami-id)
10
+ echo "$SOURCE_AMI_ID" > /var/log/source-ami-id.txt
11
+ mkdir -p /opt/aws-ec2/data
12
+ aws ec2 create-image --name "$AMI_NAME" --instance-id "$INSTANCE_ID" --region "$REGION" > /opt/aws-ec2/data/ami-id.txt
@@ -0,0 +1,11 @@
1
+ #!/bin/bash -eux
2
+
3
+ /opt/aws-ec2/auto_terminate/setup.sh
4
+
5
+ <% if @options[:auto_terminate] -%>
6
+ <% if @options[:ami_name] %>
7
+ /opt/aws-ec2/auto_terminate.sh later
8
+ <% else %>
9
+ /opt/aws-ec2/auto_terminate.sh now # terminate immediately
10
+ <% end -%>
11
+ <% end -%>
@@ -0,0 +1,5 @@
1
+ #!/bin/bash -eux
2
+
3
+ /opt/aws-ec2/auto_terminate/setup.sh
4
+
5
+ /opt/aws-ec2/auto_terminate.sh after_timeout
@@ -0,0 +1,3 @@
1
+ #!/bin/bash -eux
2
+
3
+ /opt/aws-ec2/cloudwatch.sh ec2
@@ -0,0 +1,48 @@
1
+ #!/bin/bash -eux
2
+
3
+ # Downloads and extract the scripts.
4
+ # The extracted folder from github looks like this:
5
+ # branch-name.tar.gz => aws-ec2-branch-name
6
+ # master.tar.gz => aws-ec2-master
7
+ # v1.0.0.tar.gz => aws-ec2-1.0.0
8
+ function extract_aws_ec2_scripts() {
9
+ local temp_folder
10
+ local url
11
+ local filename
12
+
13
+ rm -rf /opt/aws-ec2 # clean start
14
+
15
+ temp_folder="/opt/aws-ec2-temp"
16
+ rm -rf "$temp_folder"
17
+ mkdir -p "$temp_folder"
18
+
19
+ (
20
+ cd "$temp_folder"
21
+
22
+ <%
23
+ # Examples:
24
+ # AWS_EC2_CODE=v1.0.0
25
+ # AWS_EC2_CODE=master
26
+ # AWS_EC2_CODE=branch-name
27
+ #
28
+ # https://github.com/tongueroo/aws-ec2/archive/v1.0.0.tar.gz
29
+ # https://github.com/tongueroo/aws-ec2/archive/master.tar.gz
30
+ code_version = ENV['AWS_EC2_CODE']
31
+ code_version ||= "v#{AwsEc2::VERSION}"
32
+ %>
33
+ url="https://github.com/tongueroo/aws-ec2/archive/<%= code_version %>.tar.gz"
34
+ filename=$(basename "$url")
35
+ folder="${filename%.tar.gz}" # remove extension
36
+ folder="${folder#v}" # remove leading v character
37
+ folder="aws-ec2-$folder" # IE: aws-ec2-1.0.0
38
+
39
+ wget "$url"
40
+ tar zxf "$filename"
41
+
42
+ mv "$temp_folder/$folder/lib/aws_ec2/scripts" /opt/aws-ec2
43
+ rm -rf "$temp_folder"
44
+ chmod a+x -R /opt/aws-ec2
45
+ )
46
+ }
47
+
48
+ extract_aws_ec2_scripts
@@ -19,7 +19,7 @@ class AwsEc2::Script
19
19
  end
20
20
 
21
21
  def upload(tarball_path)
22
- puts "Uploading scripts.tgz (#{filesize}) to #{s3_dest}"
22
+ puts "Uploading scripts.tgz (#{filesize}) to #{s3_dest}".colorize(:green)
23
23
  obj = s3_resource.bucket(bucket_name).object(key)
24
24
  start_time = Time.now
25
25
  if @options[:noop]