rails_template_18f 2.2.0 → 2.3.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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile.lock +82 -69
  4. data/lib/generators/rails_template18f/auditree/auditree_generator.rb +2 -2
  5. data/lib/generators/rails_template18f/circleci/templates/circleci/config.yml.tt +6 -2
  6. data/lib/generators/rails_template18f/github_actions/templates/github/dependabot.yml.tt +16 -0
  7. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml +4 -1
  8. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml +4 -1
  9. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-production.yml +4 -1
  10. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-staging.yml +4 -1
  11. data/lib/generators/rails_template18f/gitlab_ci/gitlab_ci_generator.rb +9 -9
  12. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/{node.yml.tt → node.yml} +1 -1
  13. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/rails.yml +11 -18
  14. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab-ci.yml.tt +81 -154
  15. data/lib/generators/rails_template18f/public_egress/public_egress_generator.rb +1 -1
  16. data/lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/apply.sh +4 -4
  17. data/lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/main.tf.tt +42 -26
  18. data/lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/setup_shadowenv.sh +4 -2
  19. data/lib/generators/rails_template18f/terraform/templates/s3_bootstrap/full/main.tf.tt +6 -19
  20. data/lib/generators/rails_template18f/terraform/templates/s3_bootstrap/sandbox/main.tf.tt +5 -18
  21. data/lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt +4 -4
  22. data/lib/generators/rails_template18f/terraform/templates/terraform/app.tf.tt +6 -6
  23. data/lib/generators/rails_template18f/terraform/templates/terraform/main.tf.tt +15 -13
  24. data/lib/generators/rails_template18f/terraform/templates/terraform/{production.tfvars.tt → production.env.tfvars.tt} +0 -1
  25. data/lib/generators/rails_template18f/terraform/templates/terraform/providers.tf.tt +5 -1
  26. data/lib/generators/rails_template18f/terraform/templates/terraform/{staging.tfvars.tt → staging.env.tfvars.tt} +1 -2
  27. data/lib/generators/rails_template18f/terraform/templates/terraform/terraform.sh.tt +15 -6
  28. data/lib/generators/rails_template18f/terraform/templates/terraform/variables.tf.tt +9 -5
  29. data/lib/generators/rails_template18f/terraform/terraform_generator.rb +2 -1
  30. data/lib/rails_template18f/generators/cloud_gov_parsing.rb +2 -2
  31. data/lib/rails_template18f/version.rb +1 -1
  32. data/template.rb +1 -1
  33. data/templates/README.md.tt +1 -1
  34. metadata +5 -7
  35. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/terraform.yml +0 -33
  36. data/lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/bot_secrets.tftpl +0 -5
@@ -1,17 +1,16 @@
1
1
  locals {
2
- cf_org_name = "<%= cloud_gov_organization %>"
3
- app_name = "<%= app_name.tr("_", "-") %>"<% if terraform_manage_spaces? %>
4
- space_deployers = setunion([var.cf_user], var.space_deployers)<% end %>
2
+ cf_org_name = "<%= cloud_gov_organization %>"
3
+ app_name = "<%= app_name.tr("_", "-") %>"
5
4
  }
6
5
  <% if terraform_manage_spaces? %>
7
6
  module "app_space" {
8
7
  source = "github.com/gsa-tts/terraform-cloudgov//cg_space?ref=v2.3.0"
9
8
 
10
9
  cf_org_name = local.cf_org_name
11
- cf_space_name = var.cf_space_name
10
+ cf_space_name = coalesce(var.cf_space_name, "${local.app_name}-${var.environment_slug}")
12
11
  allow_ssh = var.allow_ssh
13
- deployers = local.space_deployers
14
- developers = var.space_developers
12
+ deployers = var.space_deployers
13
+ developers = setunion([var.cf_user], var.space_developers)
15
14
  auditors = var.space_auditors
16
15
  security_group_names = ["trusted_local_networks_egress"]
17
16
  }
@@ -35,7 +34,7 @@ module "database" {
35
34
  source = "github.com/gsa-tts/terraform-cloudgov//database?ref=v2.3.0"
36
35
 
37
36
  cf_space_id = <% if terraform_manage_spaces? %>module.app_space.space_id<% else %>data.cloudfoundry_space.app_space.id<% end %>
38
- name = "${local.app_name}-rds-${var.env}"
37
+ name = "${local.app_name}-rds-${var.environment_slug}"
39
38
  rds_plan_name = var.rds_plan_name<% if terraform_manage_spaces? %>
40
39
  # depends_on line is required only for initial creation and destruction. It can be commented out for updates if you see unwanted cascading effects
41
40
  depends_on = [module.app_space]<% end %>
@@ -45,8 +44,11 @@ module "redis" {
45
44
  source = "github.com/gsa-tts/terraform-cloudgov//redis?ref=v2.3.0"
46
45
 
47
46
  cf_space_id = <% if terraform_manage_spaces? %>module.app_space.space_id<% else %>data.cloudfoundry_space.app_space.id<% end %>
48
- name = "${local.app_name}-redis-${var.env}"
49
- redis_plan_name = var.redis_plan_name<% if terraform_manage_spaces? %>
47
+ name = "${local.app_name}-redis-${var.environment_slug}"
48
+ redis_plan_name = var.redis_plan_name
49
+ json_params = jsonencode({
50
+ engineVersion = "7.0"
51
+ })<% if terraform_manage_spaces? %>
50
52
  # depends_on line is required only for initial creation and destruction. It can be commented out for updates if you see unwanted cascading effects
51
53
  depends_on = [module.app_space]<% end %>
52
54
  }
@@ -55,7 +57,7 @@ module "s3" {
55
57
  source = "github.com/gsa-tts/terraform-cloudgov//s3?ref=v2.3.0"
56
58
 
57
59
  cf_space_id = <% if terraform_manage_spaces? %>module.app_space.space_id<% else %>data.cloudfoundry_space.app_space.id<% end %>
58
- name = "${local.app_name}-s3-${var.env}"
60
+ name = "${local.app_name}-s3-${var.environment_slug}"
59
61
  s3_plan_name = var.s3_plan_name<% if terraform_manage_spaces? %>
60
62
  # depends_on line is required only for initial creation and destruction. It can be commented out for updates if you see unwanted cascading effects
61
63
  depends_on = [module.app_space]<% end %>
@@ -66,7 +68,7 @@ module "clamav" {
66
68
 
67
69
  cf_org_name = local.cf_org_name
68
70
  cf_space_name = var.cf_space_name
69
- name = "${local.app_name}-clamapi-${var.env}"
71
+ name = "${local.app_name}-clamapi-${var.environment_slug}"
70
72
  clamav_image = "ghcr.io/gsa-tts/clamav-rest/clamav:latest"
71
73
  max_file_size = "30M"<% if terraform_manage_spaces? %>
72
74
  # depends_on line is required only for initial creation and destruction. It can be commented out for updates if you see unwanted cascading effects
@@ -109,9 +111,9 @@ module "app_route" {
109
111
  source = "github.com/gsa-tts/terraform-cloudgov//app_route?ref=v2.3.0"
110
112
 
111
113
  cf_org_name = local.cf_org_name
112
- cf_space_name = var.cf_space_name
114
+ cf_space_name = <% if terraform_manage_spaces? %>module.app_space.space_name<% else %>var.cf_space_name<% end %>
113
115
  app_ids = [cloudfoundry_app.app.id]
114
- hostname = coalesce(var.host_name, "${local.app_name}-${var.env}")<% if terraform_manage_spaces? %>
116
+ hostname = coalesce(var.host_name, "${local.app_name}-${var.environment_slug}")<% if terraform_manage_spaces? %>
115
117
  # depends_on line is required only for initial creation and destruction. It can be commented out for updates if you see unwanted cascading effects
116
118
  depends_on = [module.app_space]<% end %>
117
119
  }
@@ -1,5 +1,4 @@
1
1
  cf_space_name = "<%= cloud_gov_production_space %>"
2
- env = "production"
3
2
  rds_plan_name = "TKTK-production-rds-plan"
4
3
  custom_domain_name = null
5
4
  host_name = null
@@ -3,7 +3,11 @@ terraform {
3
3
  required_providers {
4
4
  cloudfoundry = {
5
5
  source = "cloudfoundry/cloudfoundry"
6
- version = "~> 1.7"
6
+ version = "~> 1.10"
7
+ }
8
+ archive = {
9
+ source = "hashicorp/archive"
10
+ version = "~> 2"
7
11
  }
8
12
  }
9
13
 
@@ -1,7 +1,6 @@
1
1
  cf_space_name = "<%= cloud_gov_staging_space %>"
2
- env = "staging"
3
2
  allow_ssh = true
4
- # host_name must be unique across cloud.gov, default is "<%= app_name %>-${var.env}"
3
+ # host_name must be unique across cloud.gov, default is "<%= app_name.tr("_", "-") %>-${var.environment_slug}"
5
4
  host_name = null<% if terraform_manage_spaces? %>
6
5
  space_developers = [
7
6
  # enter developer emails that should have ssh access to staging
@@ -56,8 +56,8 @@ if [[ "$1" = "--" ]]; then
56
56
  shift 1
57
57
  fi<% if use_gitlab_backend? %>
58
58
 
59
- if [ -z "$GITLAB_PROJECT_ID" ] || [ -z "$GITLAB_HOSTNAME" ]; then
60
- echo "GITLAB_PROJECT_ID or GITLAB_HOSTNAME have not been set. Running bootstrap/setup_shadowenv.sh first"
59
+ if [ -z "$GITLAB_PROJECT_ID" ] || [ -z "$GITLAB_BASE_URL" ]; then
60
+ echo "GITLAB_PROJECT_ID or GITLAB_BASE_URL have not been set. Running bootstrap/setup_shadowenv.sh now..."
61
61
  (cd bootstrap && ./setup_shadowenv.sh)
62
62
  eval "$(shadowenv hook)"
63
63
  fi<% elsif use_s3_backend? %>
@@ -76,16 +76,25 @@ if [[ -z "$env" ]]; then
76
76
  exit 1
77
77
  fi
78
78
 
79
- if [[ ! -f "$env.tfvars" ]]; then
80
- echo "$env.tfvars file is missing. Create it first"
79
+ if [[ ! -f "$env.env.tfvars" ]]; then
80
+ echo "$env.env.tfvars file is missing. Create it first"
81
81
  exit 1
82
82
  fi
83
83
 
84
+ if [[ "$env" = "staging" ]] || [[ "$env" = "production" ]]; then
85
+ echo "environment_type = \"$env\"" > env_vars.auto.tfvars
86
+ echo "environment_slug = \"$env\"" >> env_vars.auto.tfvars
87
+ elif [[ "$env" = "sandbox" ]]; then
88
+ echo "environment_type = \"review\"" > env_vars.auto.tfvars
89
+ else
90
+ rm env_vars.auto.tfvars
91
+ fi
92
+
84
93
  # ensure we're logged in via cli
85
94
  cf spaces &> /dev/null || cf login -a api.fr.cloud.gov --sso
86
95
 
87
96
  tfm_needs_init=true<% if use_gitlab_backend? %>
88
- tf_state_address="https://$GITLAB_HOSTNAME/api/v4/projects/$GITLAB_PROJECT_ID/terraform/state/$env"
97
+ tf_state_address="$GITLAB_BASE_URL/projects/$GITLAB_PROJECT_ID/terraform/state/$env"
89
98
  if [[ -f .terraform/terraform.tfstate ]]; then
90
99
  backend_state_address=$(cat .terraform/terraform.tfstate | jq -r ".backend.config.address")
91
100
  if [[ "$backend_state_address" = "$tf_state_address" ]]; then
@@ -117,4 +126,4 @@ fi
117
126
  echo "=============================================================================================================="
118
127
  echo "= Calling $cmd $force on the application infrastructure"
119
128
  echo "=============================================================================================================="
120
- terraform "$cmd" -var-file="$env.tfvars" -var rails_master_key="$rmk" $force "$@"
129
+ terraform "$cmd" -var-file="$env.env.tfvars" -var rails_master_key="$rmk" $force "$@"
@@ -8,6 +8,7 @@ variable "cf_user" {
8
8
  variable "cf_space_name" {
9
9
  type = string
10
10
  description = "The space name to deploy the app into"
11
+ default = null
11
12
  }<% if terraform_manage_spaces? %>
12
13
  variable "space_deployers" {
13
14
  type = set(string)
@@ -63,10 +64,14 @@ variable "host_name" {
63
64
  }
64
65
 
65
66
  # App environment settings
66
- variable "env" {
67
+ variable "environment_type" {
67
68
  type = string
68
69
  description = "The RAILS_ENV to set for the app (staging or production)"
69
70
  }
71
+ variable "environment_slug" {
72
+ type = string
73
+ description = "environment_name after being sluggified"
74
+ }
70
75
 
71
76
  variable "rails_master_key" {
72
77
  type = string
@@ -83,8 +88,8 @@ variable "web_memory" {
83
88
  type = string
84
89
  default = "256M"
85
90
  description = "The amount of memory to assign to the web processes"
86
- }
87
- <% if has_active_job? %>
91
+ }<% if has_active_job? %>
92
+
88
93
  variable "worker_instances" {
89
94
  type = number
90
95
  default = 1
@@ -94,5 +99,4 @@ variable "worker_memory" {
94
99
  type = string
95
100
  default = "256M"
96
101
  description = "The amount of memory to assign to the worker processes"
97
- }
98
- <% end %>
102
+ }<% end %>
@@ -37,7 +37,7 @@ module RailsTemplate18f
37
37
  end
38
38
  unless terraform_manage_spaces?
39
39
  remove_file "terraform/bootstrap/users.auto.tfvars"
40
- remove_file "terraform/production.tfvars"
40
+ remove_file "terraform/production.env.tfvars"
41
41
  end
42
42
  end
43
43
 
@@ -63,6 +63,7 @@ module RailsTemplate18f
63
63
  .terraform.lock.hcl
64
64
  **/.terraform/*
65
65
  secrets.*.tfvars
66
+ env_vars.auto.tfvars
66
67
  terraform.tfstate
67
68
  terraform.tfstate.backup
68
69
  terraform/dist
@@ -19,7 +19,7 @@ module RailsTemplate18f
19
19
 
20
20
  def cloud_gov_staging_space
21
21
  if terraform_dir_exists?
22
- staging_vars = file_content("terraform/staging.tfvars")
22
+ staging_vars = file_content("terraform/staging.env.tfvars")
23
23
  if (matches = staging_vars.match(/cf_space_name\s+= "(?<space_name>.*)"/))
24
24
  return matches[:space_name]
25
25
  end
@@ -29,7 +29,7 @@ module RailsTemplate18f
29
29
 
30
30
  def cloud_gov_production_space
31
31
  if terraform_dir_exists?
32
- production_vars = file_content("terraform/production.tfvars")
32
+ production_vars = file_content("terraform/production.env.tfvars")
33
33
  if (matches = production_vars.match(/cf_space_name\s+= "(?<space_name>.*)"/))
34
34
  return matches[:space_name]
35
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsTemplate18f
4
- VERSION = "2.2.0"
4
+ VERSION = "2.3.0"
5
5
  end
data/template.rb CHANGED
@@ -422,7 +422,7 @@ if cloud_gov_org_tktk?
422
422
  Fill in the cloud.gov organization and space information in:
423
423
  * terraform/bootstrap/main.tf
424
424
  * terraform/main.tf
425
- * terraform/*.tfvars
425
+ * terraform/*.env.tfvars
426
426
  EOM
427
427
  end
428
428
  register_announcement("Terraform", "Run the bootstrap script and update the appropriate CI/CD environment variables defined in the Deployment section of the README")
@@ -150,7 +150,7 @@ Otherwise:
150
150
 
151
151
  #### Non-secrets
152
152
 
153
- Configuration that changes by environment, but is public, should be added to the `tfvars` files, such as `terraform/production.tfvars` and `terraform/staging.tfvars`
153
+ Configuration that changes by environment, but is public, should be added to the `tfvars` files, such as `terraform/production.env.tfvars` and `terraform/staging.env.tfvars`
154
154
 
155
155
  ## Documentation
156
156
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_template_18f
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Ahearn
@@ -168,10 +168,9 @@ files:
168
168
  - lib/generators/rails_template18f/github_actions/templates/oscal/component-definitions/github_actions/component-definition.json.tt
169
169
  - lib/generators/rails_template18f/gitlab_ci/gitlab_ci_generator.rb
170
170
  - lib/generators/rails_template18f/gitlab_ci/templates/gitlab-ci.yml.tt
171
- - lib/generators/rails_template18f/gitlab_ci/templates/gitlab/node.yml.tt
171
+ - lib/generators/rails_template18f/gitlab_ci/templates/gitlab/node.yml
172
172
  - lib/generators/rails_template18f/gitlab_ci/templates/gitlab/rails.yml
173
173
  - lib/generators/rails_template18f/gitlab_ci/templates/gitlab/ruby.yml
174
- - lib/generators/rails_template18f/gitlab_ci/templates/gitlab/terraform.yml
175
174
  - lib/generators/rails_template18f/i18n/i18n_generator.rb
176
175
  - lib/generators/rails_template18f/i18n/templates/config/locales/en.yml.tt
177
176
  - lib/generators/rails_template18f/i18n/templates/config/locales/es.yml
@@ -198,7 +197,6 @@ files:
198
197
  - lib/generators/rails_template18f/sidekiq/sidekiq_generator.rb
199
198
  - lib/generators/rails_template18f/sidekiq/templates/config/initializers/redis.rb
200
199
  - lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/apply.sh
201
- - lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/bot_secrets.tftpl
202
200
  - lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/main.tf.tt
203
201
  - lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/setup_shadowenv.sh
204
202
  - lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/users.auto.tfvars
@@ -214,9 +212,9 @@ files:
214
212
  - lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt
215
213
  - lib/generators/rails_template18f/terraform/templates/terraform/app.tf.tt
216
214
  - lib/generators/rails_template18f/terraform/templates/terraform/main.tf.tt
217
- - lib/generators/rails_template18f/terraform/templates/terraform/production.tfvars.tt
215
+ - lib/generators/rails_template18f/terraform/templates/terraform/production.env.tfvars.tt
218
216
  - lib/generators/rails_template18f/terraform/templates/terraform/providers.tf.tt
219
- - lib/generators/rails_template18f/terraform/templates/terraform/staging.tfvars.tt
217
+ - lib/generators/rails_template18f/terraform/templates/terraform/staging.env.tfvars.tt
220
218
  - lib/generators/rails_template18f/terraform/templates/terraform/terraform.sh.tt
221
219
  - lib/generators/rails_template18f/terraform/templates/terraform/variables.tf.tt
222
220
  - lib/generators/rails_template18f/terraform/terraform_generator.rb
@@ -288,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
286
  - !ruby/object:Gem::Version
289
287
  version: '0'
290
288
  requirements: []
291
- rubygems_version: 3.6.7
289
+ rubygems_version: 3.6.9
292
290
  specification_version: 4
293
291
  summary: Generators for creating an 18F-flavored Rails app
294
292
  test_files: []
@@ -1,33 +0,0 @@
1
- # Shared setup helpers for terraform jobs
2
- .terraform:setup:
3
- stage: deploy
4
- inherit:
5
- default: false
6
- image:
7
- name: "hashicorp/terraform"
8
- entrypoint: ["sh"]
9
- variables:
10
- CF_API_URL: https://api.fr.cloud.gov
11
- TF_STATE_NAME: staging
12
- TF_HTTP_ADDRESS: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/terraform/state/${TF_STATE_NAME}
13
- TF_HTTP_LOCK_ADDRESS: ${TF_HTTP_ADDRESS}/lock
14
- TF_HTTP_UNLOCK_ADDRESS: ${TF_HTTP_ADDRESS}/lock
15
- TF_HTTP_USERNAME: gitlab-ci-token
16
- TF_HTTP_PASSWORD: ${CI_JOB_TOKEN}
17
- dependencies: []
18
- before_script:
19
- - cd terraform
20
- - terraform init
21
- rules:
22
- - if: $CI_PIPELINE_SOURCE != "schedule"
23
-
24
- .terraform:variables:staging:
25
- dependencies: null
26
- variables:
27
- CF_USER: $CF_USERNAME
28
-
29
- .terraform:variables:production:
30
- dependencies: null
31
- variables:
32
- CF_USER: $CF_USERNAME
33
- TF_STATE_NAME: "production"
@@ -1,5 +0,0 @@
1
- # Generated via bootstrap module. Remove this file when finished
2
- # credentials for service "${service_name}"/"${key_name}"
3
-
4
- cf_user = "${username}"
5
- cf_password = "${password}"