beanstalk_deploy 1.0.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 (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/beanstalk +4 -0
  3. data/lib/beanstalk.rb +69 -0
  4. metadata +75 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ef728d4d8caf9b4c2dbd56acf26db6d88372615e
4
+ data.tar.gz: b5ba70d5d7637a72fa00e7b70860f1da7a988205
5
+ SHA512:
6
+ metadata.gz: 0560ee2d0c273820ed0e26bc598df4fb2adbabd4b6e8eb57932fc2320f7e02d1e72c2d455bd54bfa024c4a28a63c99ebb83ca85ac6def3d20e903b466d30faff
7
+ data.tar.gz: 7b21a87e984ad5aa2bc4032b970d8419193cf0ad9b321fb9d6a04505cad9ffd73067b4847fd40f0489f94f6f7b546577fec510c7d95f7d2be0503a6d28298542
data/bin/beanstalk ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'beanstalk'
4
+ Beanstalk::Deploy.start
data/lib/beanstalk.rb ADDED
@@ -0,0 +1,69 @@
1
+ require 'thor'
2
+ require 'aws-sdk-elasticbeanstalk'
3
+
4
+ module Beanstalk
5
+ class Deploy < Thor
6
+ desc 'deploy', 'Deploy applications to AWS ElasticBeanstalk using the eb-cli'
7
+ option :app_name, :required => true
8
+ option :env_name, :required => true
9
+
10
+ option :source_dir, :aliases => "-s", :default => './src'
11
+ option :profile, :aliases => "-p", :default => 'web-services'
12
+ option :region, :aliases => "-r", :default => 'eu-west-1'
13
+ def deploy
14
+
15
+ app_name = options[:app_name]
16
+ env_name = options[:env_name]
17
+ source_dir = options[:source_dir]
18
+ profile_name = options[:profile]
19
+ region = options[:region]
20
+
21
+ if !ENV['AWS_ACCESS_KEY_ID'].nil? || !ENV['AWS_SECRET_ACCESS_KEY'].nil?
22
+ puts 'Using environment variables for authentication '
23
+ creds = Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'], session_token = nil)
24
+ else
25
+ puts 'Using profile for authentication'
26
+ creds = Aws::SharedCredentials.new(profile_name: profile_name)
27
+ end
28
+
29
+ puts 'Setting up ElasticBeanstalk client'
30
+ eb = Aws::ElasticBeanstalk::Client.new(region: region, credentials: creds)
31
+ puts 'ElasticBeanstalk client setup complete'
32
+
33
+ puts 'Checking applications'
34
+ apps = eb.describe_applications({
35
+ application_names: ["#{app_name}"]
36
+ })
37
+
38
+ if apps.applications.empty?
39
+ puts "Application does not exist, creating #{app_name}."
40
+ app = eb.create_application({
41
+ application_name: "#{app_name}",
42
+ description: "#{app_name}"
43
+ })
44
+ puts 'Application creating completed'
45
+ end
46
+
47
+ puts 'Describing environments '
48
+ envs = eb.describe_environments({
49
+ environment_names: ["#{env_name}"]
50
+ })
51
+
52
+ environment_available = false
53
+ envs.environments.each do |environemt|
54
+ if environemt.status != 'Terminated'
55
+ environment_available = true
56
+ end
57
+ end
58
+
59
+ if (envs.environments.empty?) or (!environment_available)
60
+ puts "CreateEnvironment is starting for #{env_name}."
61
+ system "cd #{source_dir} && eb create #{env_name} --timeout 60"
62
+ else
63
+ puts "Updating #{env_name}."
64
+ system "cd #{source_dir} && eb deploy #{env_name}"
65
+ end
66
+
67
+ end
68
+ end
69
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: beanstalk_deploy
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - StoneWaves
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-01-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.20.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.20.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: aws-sdk-elasticbeanstalk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.0
41
+ description: Deploy applications to AWS ElasticBeanstalk using the eb-cli
42
+ email:
43
+ - mail@stonewaves.xyz
44
+ executables:
45
+ - beanstalk
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - bin/beanstalk
50
+ - lib/beanstalk.rb
51
+ homepage: http://rubygems.org/gems/beanstalk
52
+ licenses:
53
+ - MIT
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.6.11
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Deploy applications to AWS ElasticBeanstalk
75
+ test_files: []