terra_boi 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c36dc0d2b46ebcc92f0b6ed5ef50266ba726528f7d5af498358242f25f9f3a2f
4
- data.tar.gz: 2fecb45f6a00eb0d7b288c49c6a83b5a52723365057c89663375eca4a0aa85ca
3
+ metadata.gz: 65ba7dec23cc3f546b037577d42846ac3fc436398e44c8852499b0fe5fbeef85
4
+ data.tar.gz: 744b3063050d363cd88e73219ee91a5e908ac4a3491190cba6368aa1dfb5f923
5
5
  SHA512:
6
- metadata.gz: cbd2c30b16f582e5ac99384298e57e2c8125c762c644e55b7838c1edb37092a9216efc80cf5835cd5be82d2ac7aa16e7e4bfd3e6889ebbcd2472f467d00ffe13
7
- data.tar.gz: 83b231de3fb16aa1a986437220b7a124313bb3a884e355255d885e8213438309de38ba2ff7cd8d682d78db79692562fe1d36d77fa074229ba90d24a1e56be22b
6
+ metadata.gz: 41feb412ab37ca9e5bdffbe3df50fb465a8fa007d9f7eaf5867222f661c4a522d28b45911c5928268f966337606c95ae9adcd430d4a429787ecab6fac6f10558
7
+ data.tar.gz: 6ee2c8a756a9ad4c74657ea6694ea7b4f2a193a2213ed1a2c460e8e93cf95694afc8bd0a7a748423c4d969c6598fe9a5d478aa3de01fc672e43974aebe704ec5
data/README.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  ## Introduction
4
4
 
5
- This ruby / rails gem was created by [Charlie Reese](https://charliereese.ca/about) for [Clientelify](https://clientelify.com). It creates AWS infrastructure for your rails application and deploys it in 5 steps (3 installation steps and 2 rake tasks). It is free to use.
5
+ Deploy your rails application to AWS with `rake deploy`.
6
+
7
+ This ruby / rails gem was created by [Charlie Reese](https://charliereese.ca/about) for [Clientelify](https://clientelify.com). It creates AWS infrastructure for your rails application and deploys it in 5 steps (3 installation steps and 2 rake tasks). Subsequent deployment is 1 step (`rake deploy`).
8
+
9
+ It is free to use.
6
10
 
7
11
  Out of the box, terra_boi provides remote state locking, load-balancing, simple scaling, zero-downtime deployments, CloudWatch logging, DBs, and S3 buckets for multiple infrastructure environments: by default, terra_boi creates staging and prod environments for your web app.
8
12
 
@@ -1,29 +1,34 @@
1
1
  module TerraBoi
2
2
  module GeneratorHelpers
3
3
  # https://api.rubyonrails.org/classes/Rails/Generators/NamedBase.html#method-i-application_name
4
- def generate_application_name
4
+ def generate_application_name(separators: false)
5
5
  if defined?(Rails) && Rails.application
6
- Rails.application.class.name.split("::").first.underscore
7
- else
8
- "application"
9
- end
10
- end
6
+ app_name = Rails.application.class.name.split("::").first.underscore
7
+ unless separators
8
+ app_name = app_name.gsub('_', '')
9
+ end
11
10
 
12
- def generate_terraform_files(args)
13
- args[:env].each do |env|
14
- template(args[:template],
15
- "terraform_v2/#{env}/#{args[:file_path]}",
16
- {
17
- env: env,
18
- domain_name: (class_options && class_options[:domain_name]) || generate_application_name + '.com'
19
- }
20
- )
21
- end
22
- end
23
- end
11
+ app_name
12
+ else
13
+ "application"
14
+ end
15
+ end
16
+
17
+ def generate_terraform_files(args)
18
+ args[:env].each do |env|
19
+ template(args[:template],
20
+ "terraform_v2/#{env}/#{args[:file_path]}",
21
+ {
22
+ env: env,
23
+ domain_name: (class_options && class_options[:domain_name]) || generate_application_name + '.com'
24
+ }
25
+ )
26
+ end
27
+ end
28
+ end
24
29
  end
25
30
 
26
31
  class Rails::Generators::Base
27
- include TerraBoi::GeneratorHelpers
32
+ include TerraBoi::GeneratorHelpers
28
33
  end
29
-
34
+
@@ -15,11 +15,11 @@ module TerraBoi
15
15
 
16
16
  def init
17
17
  # defined in lib/generators/extensions
18
- self.application_name = generate_application_name
18
+ self.application_name = generate_application_name separators: false
19
19
  end
20
20
 
21
21
  def create_db_config_file
22
22
  template "db_config.erb", "config/database.yml"
23
23
  end
24
24
  end
25
- end
25
+ end
@@ -27,4 +27,4 @@ production:
27
27
  username: <%%= ENV["DB_USERNAME"] %>
28
28
  password: <%%= ENV["DB_PASSWORD"] %>
29
29
  host: <%%= ENV["DB_HOST"] %>
30
- pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
30
+ pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
@@ -20,7 +20,7 @@ variable "db_username" {}
20
20
  variable "db_password" {}
21
21
 
22
22
  module "db_and_s3" {
23
- source = "github.com/charliereese/terraform_modules//data?ref=v0.0.27"
23
+ source = "github.com/charliereese/terraform_modules//data?ref=v0.0.28"
24
24
 
25
25
  env = "<%= config[:env] %>"
26
26
  app_name = "<%= application_name %>"
@@ -28,4 +28,4 @@ module "db_and_s3" {
28
28
  db_encrypted = <%= config[:env] == 'prod' ? true : false %>
29
29
  db_username = var.db_username
30
30
  db_password = var.db_password
31
- }
31
+ }
@@ -12,7 +12,11 @@ aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --
12
12
 
13
13
  # Build your Docker image using the following command
14
14
  DOCKERFILE_PATH="$SCRIPT_DIR/../../../."
15
- docker build -t $AWS_ECR_REPO_NAME $DOCKERFILE_PATH
15
+ if ! docker build -t $AWS_ECR_REPO_NAME $DOCKERFILE_PATH; then
16
+ echo "TERRA_BOI | Command failed. Pruning Docker memory then retrying!"
17
+ echo "TERRA_BOI | Pruning may take a couple minutes..."
18
+ docker system prune -a && docker build -t $AWS_ECR_REPO_NAME $DOCKERFILE_PATH
19
+ fi
16
20
 
17
21
  # After the build completes, tag your image so you can push the image to this repository:
18
22
  docker tag $AWS_ECR_REPO_NAME:latest $AWS_ECR_REPO_URL:latest
@@ -3,8 +3,8 @@
3
3
  # ---------------------------------------------------------------------------------------------------------------------
4
4
 
5
5
  module "remote_state_locking" {
6
- source = "github.com/charliereese/terraform_modules//state?ref=v0.0.25"
6
+ source = "github.com/charliereese/terraform_modules//state?ref=v0.0.28"
7
7
 
8
- app_name = "<%= application_name %>"
9
- region = "us-east-2"
8
+ app_name = "<%= application_name %>"
9
+ region = "us-east-2"
10
10
  }
@@ -35,7 +35,7 @@ module TerraBoi
35
35
 
36
36
  def init
37
37
  # defined in lib/generators/extensions
38
- self.application_name = generate_application_name
38
+ self.application_name = generate_application_name separators: false
39
39
  self.class_options = options
40
40
  end
41
41
 
@@ -51,4 +51,4 @@ module TerraBoi
51
51
  end
52
52
  end
53
53
  end
54
- end
54
+ end
@@ -14,11 +14,11 @@ module TerraBoi
14
14
  )
15
15
 
16
16
  def init
17
- self.application_name = generate_application_name
17
+ self.application_name = generate_application_name separators: false
18
18
  end
19
19
 
20
20
  def create_main_terraform_file
21
21
  template "state_main.erb", "terraform/state/main.tf"
22
22
  end
23
23
  end
24
- end
24
+ end
@@ -155,13 +155,7 @@ end
155
155
 
156
156
  def push_container_to_ecr
157
157
  puts "\nTERRA_BOI | Building application docker container then pushing to ECR...\n".cyan.bold
158
- sh "./terraform/lib/scripts/push_to_ecr.sh" do |ok, res|
159
- if !ok
160
- puts "\nTERRA_BOI | Docker container build and push failed (status = #{res.exitstatus})".cyan.bold
161
- puts "\nTERRA_BOI | Pruning docker (to create more memory) and retrying...\n".cyan.bold
162
- sh "docker system prune -a && ./terraform/lib/scripts/push_to_ecr.sh"
163
- end
164
- end
158
+ sh "./terraform/lib/scripts/push_to_ecr.sh"
165
159
  end
166
160
 
167
161
  def apply_web_app_and_worker
@@ -1,3 +1,3 @@
1
1
  module TerraBoi
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terra_boi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charlie Reese
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-04 00:00:00.000000000 Z
11
+ date: 2020-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -44,13 +44,12 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
- description: 'This gem was created to get rails applications deployed into production
48
- as quickly and easily as possible. It contains generators that create infrastructure
49
- code for load balancing / auto scaling / zero-downtime deployments, (rails) web
50
- apps (EC2 instances), DBs, and S3 buckets. List of items created by this gem''s
51
- generators: Dockerfile, Rails initializer file (for setting up config.hosts), Packer
52
- repository (for creating AWS EC2 AMIs), and Terraform repository (for creating infrastructure
53
- as code to immediately deploy staging / prod infrastructure).'
47
+ description: |-
48
+ Deploy your rails application to AWS with `rake deploy`.
49
+
50
+ This ruby / rails gem was created by Charlie Reese (charliereese.ca/about) for Clientelify. It creates AWS infrastructure for your rails application and deploys it in 5 steps (3 installation steps and 2 rake tasks). It is free to use.
51
+
52
+ Out of the box, terra_boi provides remote state locking, load-balancing, simple scaling, zero-downtime deployments, CloudWatch logging, DBs, and S3 buckets for multiple infrastructure environments: by default, terra_boi creates staging and prod environments for your web app.
54
53
  email:
55
54
  - j.charles.reese@gmail.com
56
55
  executables: []
@@ -125,9 +124,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
124
  - !ruby/object:Gem::Version
126
125
  version: '0'
127
126
  requirements: []
128
- rubygems_version: 3.1.2
127
+ rubygems_version: 3.1.4
129
128
  signing_key:
130
129
  specification_version: 4
131
- summary: Generators to help you get rails applications deployed into production as
132
- quickly and easily as possible.
130
+ summary: Deploy your rails application to AWS with `rake deploy`. terra_boi generates
131
+ AWS infrastructure as code, provisions AWS infrastructure, and then deploys your
132
+ application to it using Terraform, rails generators, and rake tasks.
133
133
  test_files: []