rails_template_18f 1.3.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +64 -61
  5. data/README.md +11 -16
  6. data/lib/generators/rails_template18f/active_storage/active_storage_generator.rb +7 -6
  7. data/lib/generators/rails_template18f/circleci/circleci_generator.rb +28 -27
  8. data/lib/generators/rails_template18f/circleci/templates/Dockerfile.ci.tt +0 -1
  9. data/lib/generators/rails_template18f/circleci/templates/circleci/config.yml.tt +152 -163
  10. data/lib/generators/rails_template18f/github_actions/github_actions_generator.rb +31 -30
  11. data/lib/generators/rails_template18f/github_actions/templates/github/actions/compile-assets/action.yml +50 -0
  12. data/lib/generators/rails_template18f/github_actions/templates/github/actions/setup-project/action.yml.tt +4 -8
  13. data/lib/generators/rails_template18f/github_actions/templates/github/dependabot.yml.tt +2 -4
  14. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml +72 -0
  15. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml +72 -0
  16. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/owasp-daily-scan.yml.tt +10 -1
  17. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/owasp-scan.yml.tt +1 -1
  18. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/pa11y.yml.tt +2 -2
  19. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-production.yml +46 -3
  20. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-staging.yml +46 -3
  21. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/validate-ssp.yml +2 -2
  22. data/lib/generators/rails_template18f/i18n_js/i18n_js_generator.rb +2 -2
  23. data/lib/generators/rails_template18f/i18n_js/templates/app/javascript/{i18n.js → i18n/index.js} +1 -1
  24. data/lib/generators/rails_template18f/i18n_js/templates/config/i18n-js.yml +1 -1
  25. data/lib/generators/rails_template18f/newrelic/newrelic_generator.rb +4 -2
  26. data/lib/generators/rails_template18f/public_egress/public_egress_generator.rb +86 -54
  27. data/lib/generators/rails_template18f/sidekiq/sidekiq_generator.rb +8 -17
  28. data/lib/generators/rails_template18f/terraform/templates/full_bootstrap/imports.tf.tftpl +25 -0
  29. data/lib/generators/rails_template18f/terraform/templates/full_bootstrap/main.tf.tt +159 -0
  30. data/lib/generators/rails_template18f/terraform/templates/sandbox_bootstrap/imports.tf.tftpl +10 -0
  31. data/lib/generators/rails_template18f/terraform/templates/sandbox_bootstrap/main.tf.tt +117 -0
  32. data/lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt +77 -93
  33. data/lib/generators/rails_template18f/terraform/templates/terraform/app.tf.tt +63 -0
  34. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/apply.sh +15 -0
  35. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/templates/backend_config.tftpl +8 -0
  36. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/templates/bot_secrets.tftpl +5 -0
  37. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/users.auto.tfvars +5 -0
  38. data/lib/generators/rails_template18f/terraform/templates/terraform/main.tf.tt +106 -0
  39. data/lib/generators/rails_template18f/terraform/templates/terraform/production.tfvars.tt +10 -0
  40. data/lib/generators/rails_template18f/terraform/templates/terraform/providers.tf.tt +32 -0
  41. data/lib/generators/rails_template18f/terraform/templates/terraform/sandbox_bot/main.tf +74 -0
  42. data/lib/generators/rails_template18f/terraform/templates/terraform/sandbox_bot/run.sh +17 -0
  43. data/lib/generators/rails_template18f/terraform/templates/terraform/staging.tfvars.tt +8 -0
  44. data/lib/generators/rails_template18f/terraform/templates/terraform/terraform.sh.tt +135 -0
  45. data/lib/generators/rails_template18f/terraform/templates/terraform/variables.tf.tt +99 -0
  46. data/lib/generators/rails_template18f/terraform/terraform_generator.rb +13 -4
  47. data/lib/rails_template18f/generators/cloud_gov_options.rb +9 -6
  48. data/lib/rails_template18f/generators/cloud_gov_parsing.rb +7 -7
  49. data/lib/rails_template18f/generators.rb +0 -1
  50. data/lib/rails_template18f/version.rb +1 -1
  51. data/rails-template-18f.gemspec +4 -4
  52. data/railsrc +4 -2
  53. data/railsrc-hotwire +4 -2
  54. data/template.rb +61 -71
  55. data/templates/README.md.tt +21 -8
  56. data/templates/app/assets/stylesheets/uswds-settings.scss +3 -2
  57. data/templates/app/views/application/_header.html.erb +1 -1
  58. data/templates/app/views/application/_usa_banner.html.erb +3 -3
  59. data/templates/bin/ops/create_service_account.sh.tt +20 -11
  60. data/templates/bin/ops/destroy_service_account.sh.tt +3 -3
  61. data/templates/browserslistrc +1 -2
  62. data/templates/doc/compliance/TODO.md +1 -4
  63. metadata +30 -29
  64. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml.tt +0 -50
  65. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml.tt +0 -50
  66. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/import.sh +0 -13
  67. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/main.tf.tt +0 -22
  68. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/providers.tf +0 -16
  69. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/run.sh.tt +0 -40
  70. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/teardown_creds.sh.tt +0 -5
  71. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/variables.tf +0 -2
  72. data/lib/generators/rails_template18f/terraform/templates/terraform/production/main.tf.tt +0 -90
  73. data/lib/generators/rails_template18f/terraform/templates/terraform/production/providers.tf +0 -23
  74. data/lib/generators/rails_template18f/terraform/templates/terraform/production/variables.tf +0 -2
  75. data/lib/generators/rails_template18f/terraform/templates/terraform/staging/main.tf.tt +0 -70
  76. data/lib/generators/rails_template18f/terraform/templates/terraform/staging/providers.tf +0 -23
  77. data/lib/generators/rails_template18f/terraform/templates/terraform/staging/variables.tf +0 -2
  78. data/lib/rails_template18f/generators/pipeline_options.rb +0 -18
  79. data/templates/app/assets/images/uswds.js +0 -6
  80. data/templates/config/deployment/production.yml +0 -3
  81. data/templates/config/deployment/staging.yml +0 -3
  82. data/templates/manifest.yml.tt +0 -17
@@ -0,0 +1,106 @@
1
+ locals {
2
+ cf_org_name = "<%= cloud_gov_organization %>"
3
+ app_name = "<%= app_name %>"
4
+ space_deployers = setunion([var.cf_user], var.space_deployers)
5
+ }
6
+
7
+ <% if terraform_manage_spaces? %>
8
+ module "app_space" {
9
+ source = "github.com/gsa-tts/terraform-cloudgov//cg_space?ref=v2.1.0"
10
+
11
+ cf_org_name = local.cf_org_name
12
+ cf_space_name = var.cf_space_name
13
+ allow_ssh = var.allow_space_ssh
14
+ deployers = local.space_deployers
15
+ developers = var.space_developers
16
+ security_group_names = ["trusted_local_networks_egress"]
17
+ }
18
+ <% else %>
19
+ data "cloudfoundry_org" "org" {
20
+ name = local.cf_org_name
21
+ }
22
+ data "cloudfoundry_space" "app_space" {
23
+ name = var.cf_space_name
24
+ org = data.cloudfoundry_org.org.id
25
+ }
26
+ data "cloudfoundry_security_group" "trusted_egress_security_group" {
27
+ name = "trusted_local_networks_egress"
28
+ }
29
+ resource "cloudfoundry_security_group_space_bindings" "trusted_egress_binding" {
30
+ security_group = data.cloudfoundry_security_group.trusted_egress_security_group.id
31
+ running_spaces = [data.cloudfoundry_space.app_space.id]
32
+ }
33
+ <% end %>
34
+
35
+ module "database" {
36
+ source = "github.com/gsa-tts/terraform-cloudgov//database?ref=v2.1.0"
37
+
38
+ cf_space_id = <% if terraform_manage_spaces? %>module.app_space.space_id<% else %>data.cloudfoundry_space.app_space.id<% end %>
39
+ name = "${local.app_name}-rds-${var.env}"
40
+ rds_plan_name = var.rds_plan_name<% if terraform_manage_spaces? %>
41
+ # depends_on line is required only for initial creation and destruction. It can be commented out for updates if you see unwanted cascading effects
42
+ depends_on = [module.app_space]<% end %>
43
+ }
44
+ <% if has_active_job? %>
45
+ module "redis" {
46
+ source = "github.com/gsa-tts/terraform-cloudgov//redis?ref=v2.1.0"
47
+
48
+ cf_space_id = <% if terraform_manage_spaces? %>module.app_space.space_id<% else %>data.cloudfoundry_space.app_space.id<% end %>
49
+ name = "${local.app_name}-redis-${var.env}"
50
+ redis_plan_name = var.redis_plan_name<% if terraform_manage_spaces? %>
51
+ # depends_on line is required only for initial creation and destruction. It can be commented out for updates if you see unwanted cascading effects
52
+ depends_on = [module.app_space]<% end %>
53
+ }
54
+ <% end %>
55
+ <% if has_active_storage? %>
56
+ module "s3" {
57
+ source = "github.com/gsa-tts/terraform-cloudgov//s3?ref=v2.1.0"
58
+
59
+ cf_space_id = <% if terraform_manage_spaces? %>module.app_space.space_id<% else %>data.cloudfoundry_space.app_space.id<% end %>
60
+ name = "${local.app_name}-s3-${var.env}"
61
+ s3_plan_name = var.s3_plan_name<% if terraform_manage_spaces? %>
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
63
+ depends_on = [module.app_space]<% end %>
64
+ }
65
+
66
+ module "clamav" {
67
+ source = "github.com/gsa-tts/terraform-cloudgov//clamav?ref=v2.1.0"
68
+
69
+ cf_org_name = local.cf_org_name
70
+ cf_space_name = var.cf_space_name
71
+ name = "${local.app_name}-clamapi-${var.env}"
72
+ clamav_image = "ghcr.io/gsa-tts/clamav-rest/clamav:latest"
73
+ max_file_size = "30M"<% if terraform_manage_spaces? %>
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
75
+ depends_on = [module.app_space]<% end %>
76
+ }
77
+
78
+ resource "cloudfoundry_network_policy" "clamav_routing" {
79
+ provider = cloudfoundry-community
80
+ policy {
81
+ source_app = cloudfoundry_app.app.id
82
+ destination_app = module.clamav.app_id
83
+ port = "61443"
84
+ }
85
+ }
86
+ <% end %>
87
+
88
+ ###########################################################################
89
+ # Before setting var.custom_domain_name, perform the following steps:
90
+ # 1) Domain must be manually created by an OrgManager:
91
+ # cf create-domain var.cf_org_name var.domain_name
92
+ # 2) ACME challenge record must be created.
93
+ # See https://cloud.gov/docs/services/external-domain-service/#how-to-create-an-instance-of-this-service
94
+ ###########################################################################
95
+ module "domain" {
96
+ count = (var.custom_domain_name == null ? 0 : 1)
97
+ source = "github.com/gsa-tts/terraform-cloudgov//domain?ref=v2.1.0"
98
+
99
+ cf_org_name = local.cf_org_name
100
+ cf_space = <% if terraform_manage_spaces? %>module.app_space.space<% else %>data.cloudfoundry_space.app_space<% end %>
101
+ cdn_plan_name = "domain"
102
+ domain_name = var.custom_domain_name
103
+ host_name = var.host_name<% if terraform_manage_spaces? %>
104
+ # depends_on line is required only for initial creation and destruction. It can be commented out for updates if you see unwanted cascading effects
105
+ depends_on = [module.app_space]<% end %>
106
+ }
@@ -0,0 +1,10 @@
1
+ cf_space_name = "<%= cloud_gov_production_space %>"
2
+ env = "production"
3
+ rds_plan_name = "TKTK-production-rds-plan"
4
+ custom_domain_name = null
5
+ host_name = null
6
+ web_instances = 2
7
+ web_memory = "512M"
8
+ <% if has_active_storage? %>s3_plan_name = "basic"<% end %>
9
+ <% if has_active_job? %>redis_plan_name = "TKTK-production-redis-plan"<% end %>
10
+ <% if has_active_job? %>worker_memory = "512M"<% end %>
@@ -0,0 +1,32 @@
1
+ terraform {
2
+ required_version = "~> 1.10"
3
+ required_providers {<% if has_active_storage? %>
4
+ cloudfoundry-community = {
5
+ source = "cloudfoundry-community/cloudfoundry"
6
+ version = "0.53.1"
7
+ }<% end %>
8
+ cloudfoundry = {
9
+ source = "cloudfoundry/cloudfoundry"
10
+ version = "1.2.0"
11
+ }
12
+ }
13
+
14
+ backend "s3" {
15
+ encrypt = true
16
+ use_lockfile = true
17
+ region = "us-gov-west-1"
18
+ }
19
+ }
20
+
21
+ provider "cloudfoundry" {
22
+ api_url = "https://api.fr.cloud.gov"
23
+ user = var.cf_user
24
+ password = var.cf_password
25
+ }
26
+ <% if has_active_storage? %>
27
+ provider "cloudfoundry-community" {
28
+ api_url = "https://api.fr.cloud.gov"
29
+ user = var.cf_user
30
+ password = var.cf_password
31
+ }
32
+ <% end %>
@@ -0,0 +1,74 @@
1
+ terraform {
2
+ required_version = "~> 1.10"
3
+ required_providers {
4
+ cloudfoundry = {
5
+ source = "cloudfoundry/cloudfoundry"
6
+ version = "1.1.0"
7
+ }
8
+ }
9
+ backend "local" {}
10
+ }
11
+ # empty config will let terraform borrow cf-cli's auth
12
+ provider "cloudfoundry" {}
13
+
14
+ variable "sandbox_name" {
15
+ type = string
16
+ description = "Name of the sandbox environment we're deploying into"
17
+ }
18
+
19
+ locals {
20
+ sa_service_name = "${var.sandbox_name}-local-deployer"
21
+ sa_key_name = "deployer-access-key"
22
+ sa_bot_credentials = jsondecode(data.cloudfoundry_service_credential_binding.runner_sa_key.credential_bindings.0.credential_binding).credentials
23
+ sa_cf_username = nonsensitive(local.sa_bot_credentials.username)
24
+ }
25
+
26
+ data "cloudfoundry_service_plans" "cg_service_account" {
27
+ name = "space-deployer"
28
+ service_offering_name = "cloud-gov-service-account"
29
+ }
30
+ data "terraform_remote_state" "bootstrap" {
31
+ backend = "local"
32
+ config = {
33
+ path = "${path.module}/../bootstrap/terraform.tfstate"
34
+ }
35
+ }
36
+ resource "cloudfoundry_service_instance" "runner_service_account" {
37
+ name = local.sa_service_name
38
+ type = "managed"
39
+ space = data.terraform_remote_state.bootstrap.outputs.mgmt_space_id
40
+ service_plan = data.cloudfoundry_service_plans.cg_service_account.service_plans.0.id
41
+ }
42
+
43
+ resource "cloudfoundry_service_credential_binding" "runner_sa_key" {
44
+ name = local.sa_key_name
45
+ service_instance = cloudfoundry_service_instance.runner_service_account.id
46
+ type = "key"
47
+ }
48
+ data "cloudfoundry_service_credential_binding" "runner_sa_key" {
49
+ name = local.sa_key_name
50
+ service_instance = cloudfoundry_service_instance.runner_service_account.id
51
+ depends_on = [cloudfoundry_service_credential_binding.runner_sa_key]
52
+ }
53
+
54
+ data "cloudfoundry_user" "sa_user" {
55
+ name = local.sa_cf_username
56
+ }
57
+ resource "cloudfoundry_org_role" "sa_org_manager" {
58
+ user = data.cloudfoundry_user.sa_user.users.0.id
59
+ type = "organization_manager"
60
+ org = data.terraform_remote_state.bootstrap.outputs.mgmt_org_id
61
+ }
62
+
63
+ resource "local_sensitive_file" "bot_secrets_file" {
64
+ filename = "${path.module}/../secrets.auto.tfvars"
65
+ file_permission = "0600"
66
+
67
+ content = <<-EOT
68
+ # "${local.sa_service_name}"/"${local.sa_key_name}" generated by sandbox_bot terraform module.
69
+ # Run `./run.sh ${var.sandbox_name} destroy` in that directory to clean up
70
+
71
+ cf_user = "${local.sa_cf_username}"
72
+ cf_password = "${local.sa_bot_credentials.password}"
73
+ EOT
74
+ }
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ if [[ $# -lt 2 ]]; then
6
+ echo "usage: $0 SANDBOX_NAME TERRAFORM_CMD [TERRAFORM_ARGS]"
7
+ echo "You must pass the sandbox_name as the first argument and terraform command as the second"
8
+ echo "All other arguments are passed as-is to terraform"
9
+ exit 1
10
+ fi
11
+
12
+ sandbox_name="$1"
13
+ cmd="$2"
14
+ shift 2
15
+
16
+ terraform init -backend-config="path=$sandbox_name/terraform.tfstate" -reconfigure
17
+ terraform "$cmd" -var sandbox_name="$sandbox_name" "$@"
@@ -0,0 +1,8 @@
1
+ cf_space_name = "<%= cloud_gov_staging_space %>"
2
+ env = "staging"
3
+ allow_space_ssh = true
4
+ # host_name must be unique across cloud.gov, default is "<%= app_name %>-${var.env}"
5
+ host_name = null
6
+ space_developers = [
7
+ # enter developer emails that should have ssh access to staging
8
+ ]
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env bash
2
+
3
+ rmk_file="../config/master.key"
4
+ cmd="plan"
5
+
6
+ usage="
7
+ $0: Run terraform commands against a given environment
8
+
9
+ Usage:
10
+ $0 -h
11
+ $0 -e <ENV NAME> [-k <RAILS_MASTER_KEY>] [-f] [-c <TERRAFORM-CMD>] [-- <EXTRA CMD ARGUMENTS>]
12
+
13
+ Options:
14
+ -h: show help and exit
15
+ -e ENV_NAME: The name of the environment to run terraform against
16
+ -k RAILS_MASTER_KEY: RAILS_MASTER_KEY value. Defaults to contents of $rmk_file
17
+ -f: Force, pass -auto-approve to all invocations of terraform
18
+ -c TERRAFORM-CMD: command to run. Defaults to $cmd
19
+ [<EXTRA CMD ARGUMENTS>]: arguments to pass as-is to terraform
20
+ "
21
+
22
+
23
+ rmk=`cat $rmk_file || echo -n ""`
24
+ env=""
25
+ force=""
26
+ args_to_shift=0
27
+
28
+ set -e
29
+ while getopts ":he:k:fc:" opt; do
30
+ case "$opt" in
31
+ e)
32
+ env=${OPTARG}
33
+ args_to_shift=$((args_to_shift + 2))
34
+ ;;
35
+ k)
36
+ rmk=${OPTARG}
37
+ args_to_shift=$((args_to_shift + 2))
38
+ ;;
39
+ f)
40
+ force="-auto-approve"
41
+ args_to_shift=$((args_to_shift + 1))
42
+ ;;
43
+ c)
44
+ cmd=${OPTARG}
45
+ args_to_shift=$((args_to_shift + 2))
46
+ ;;
47
+ h)
48
+ echo "$usage"
49
+ exit 0
50
+ ;;
51
+ esac
52
+ done
53
+
54
+ shift $args_to_shift
55
+ if [[ "$1" = "--" ]]; then
56
+ shift 1
57
+ fi
58
+
59
+ if [[ -z "$env" ]]; then
60
+ echo "-e <ENV_NAME> is required"
61
+ echo "$usage"
62
+ exit 1
63
+ fi
64
+
65
+ if [[ ! -f "$env.tfvars" ]]; then
66
+ echo "$env.tfvars file is missing. Create it first"
67
+ exit 1
68
+ fi
69
+
70
+ # ensure we're logged in via cli
71
+ cf spaces &> /dev/null || cf login -a api.fr.cloud.gov --sso
72
+
73
+ tfm_needs_init=true
74
+ if [[ -f .terraform/terraform.tfstate ]]; then
75
+ backend_state_env=`cat .terraform/terraform.tfstate | jq -r ".backend.config.key" | cut -d '.' -f3`
76
+ if [[ "$backend_state_env" = "$env" ]]; then
77
+ tfm_needs_init=false
78
+ fi
79
+ fi
80
+
81
+ if [[ $tfm_needs_init = true ]]; then
82
+ if [[ ! -f secrets.backend.tfvars ]]; then
83
+ echo "=============================================================================================================="
84
+ echo "= Recreating backend config file. It is fine if this step wants to delete any local_sensitive_file resources"
85
+ echo "=============================================================================================================="
86
+ (cd bootstrap && ./apply.sh $force)
87
+ fi
88
+ terraform init -backend-config=secrets.backend.tfvars -backend-config="key=terraform.tfstate.$env" -reconfigure
89
+ fi
90
+
91
+ echo "=============================================================================================================="
92
+ echo "= Creating a bot deployer for $env"
93
+ echo "=============================================================================================================="
94
+ <% if terraform_manage_spaces? %>
95
+ if [[ "$env" = "staging" ]] || [[ "$env" = "production" ]]; then
96
+ (cd bootstrap && ./apply.sh -var create_bot_secrets_file=true $force)
97
+ else
98
+ (cd sandbox_bot && ./run.sh "$env" apply $force)
99
+ fi
100
+ <% else %>
101
+ if [[ ! -f secrets.auto.tfvars ]]; then
102
+ ../bin/ops/create_service_account.sh -s <%= cloud_gov_staging_space %> -u terraform-deployer -n > secrets.auto.tfvars
103
+ fi
104
+ <% end %>
105
+
106
+ if [[ -f secrets.backend.tfvars ]]; then
107
+ rm secrets.backend.tfvars
108
+ fi
109
+
110
+ echo "=============================================================================================================="
111
+ echo "= Calling $cmd $force on the application infrastructure"
112
+ echo "=============================================================================================================="
113
+ terraform "$cmd" -var-file="$env.tfvars" -var rails_master_key="$rmk" $force "$@"
114
+
115
+ <% if terraform_manage_spaces? %>
116
+ if [[ "$cmd" = "destroy" ]] && [[ "$env" != "staging" ]] && [[ "$env" != "production" ]]; then
117
+ <% else %>
118
+ if [[ "$cmd" = "destroy" ]]; then
119
+ <% end %>
120
+ if [[ -z "$force" ]]; then
121
+ read -p "Destroy the sandbox_bot user? (y/n) " confirm
122
+ if [[ "$confirm" != "y" ]]; then
123
+ exit 0
124
+ fi
125
+ fi
126
+ echo "=============================================================================================================="
127
+ echo "= Destroying the sandbox_bot user"
128
+ echo "=============================================================================================================="
129
+ <% if terraform_manage_spaces? %>
130
+ (cd sandbox_bot && ./run.sh "$env" destroy -auto-approve)
131
+ <% else %>
132
+ ../bin/ops/destroy_service_account.sh -s <%= cloud_gov_staging_space %> -u terraform-deployer
133
+ rm secrets.auto.tfvars
134
+ <% end %>
135
+ fi
@@ -0,0 +1,99 @@
1
+ # Deploy user settings
2
+ variable "cf_user" {
3
+ type = string
4
+ description = "The service account running the terraform"
5
+ }
6
+ variable "cf_password" {
7
+ type = string
8
+ sensitive = true
9
+ description = "The service account password"
10
+ }
11
+
12
+ # app_space settings
13
+ variable "cf_space_name" {
14
+ type = string
15
+ description = "The space name to deploy the app into"
16
+ }
17
+ variable "space_deployers" {
18
+ type = set(string)
19
+ default = []
20
+ description = "A list of users to be granted SpaceDeveloper & SpaceManager on cf_space_name"
21
+ }
22
+ variable "space_developers" {
23
+ type = set(string)
24
+ default = []
25
+ description = "A list of users to be granted SpaceDeveloper on cf_space_name"
26
+ }
27
+ variable "allow_space_ssh" {
28
+ type = bool
29
+ default = false
30
+ description = "Whether to allow ssh to cf_space_name"
31
+ }
32
+
33
+ # supporting services settings
34
+ variable "rds_plan_name" {
35
+ type = string
36
+ default = "micro-psql"
37
+ description = "The name of the rds plan to create"
38
+ }
39
+ <% if has_active_job? %>
40
+ variable "redis_plan_name" {
41
+ type = string
42
+ default = "redis-dev"
43
+ description = "The name of the redis plan to create"
44
+ }
45
+ <% end %>
46
+ <% if has_active_storage? %>
47
+ variable "s3_plan_name" {
48
+ type = string
49
+ default = "basic-sandbox"
50
+ description = "The name of the s3 plan to use"
51
+ }
52
+ <% end %>
53
+
54
+ # routing settings
55
+ variable "custom_domain_name" {
56
+ type = string
57
+ default = null
58
+ description = "The custom domain name to associate with the app. Leave as null to disable the domain service and use an *.app.cloud.gov route"
59
+ }
60
+ variable "host_name" {
61
+ type = string
62
+ default = null
63
+ description = "An optional hostname to prepend to either the custom domain name or app.cloud.gov"
64
+ }
65
+
66
+ # App environment settings
67
+ variable "env" {
68
+ type = string
69
+ description = "The RAILS_ENV to set for the app (staging or production)"
70
+ }
71
+
72
+ variable "rails_master_key" {
73
+ type = string
74
+ sensitive = true
75
+ description = "config/master.key"
76
+ }
77
+
78
+ variable "web_instances" {
79
+ type = number
80
+ default = 1
81
+ description = "The number of instances of the web process"
82
+ }
83
+ variable "web_memory" {
84
+ type = string
85
+ default = "256M"
86
+ description = "The amount of memory to assign to the web processes"
87
+ }
88
+ <% if has_active_job? %>
89
+ variable "worker_instances" {
90
+ type = number
91
+ default = 1
92
+ description = "The number of instances of the worker process"
93
+ }
94
+ variable "worker_memory" {
95
+ type = string
96
+ default = "256M"
97
+ description = "The amount of memory to assign to the worker processes"
98
+ }
99
+ <% end %>
@@ -15,8 +15,17 @@ module RailsTemplate18f
15
15
 
16
16
  def install
17
17
  directory "terraform", mode: :preserve
18
- chmod "terraform/bootstrap/run.sh", 0o755
19
- chmod "terraform/bootstrap/teardown_creds.sh", 0o755
18
+ chmod "terraform/terraform.sh", 0o755
19
+ if terraform_manage_spaces?
20
+ template "full_bootstrap/main.tf", "terraform/bootstrap/main.tf"
21
+ copy_file "full_bootstrap/imports.tf.tftpl", "terraform/bootstrap/templates/imports.tf.tftpl"
22
+ else
23
+ template "sandbox_bootstrap/main.tf", "terraform/bootstrap/main.tf"
24
+ copy_file "sandbox_bootstrap/imports.tf.tftpl", "terraform/bootstrap/templates/imports.tf.tftpl"
25
+ remove_file "terraform/bootstrap/users.auto.tfvars"
26
+ remove_dir "terraform/sandbox_bot"
27
+ remove_file "terraform/production.tfvars"
28
+ end
20
29
  end
21
30
 
22
31
  def ignore_files
@@ -26,9 +35,10 @@ module RailsTemplate18f
26
35
  # Terraform
27
36
  .terraform.lock.hcl
28
37
  **/.terraform/*
29
- secrets.auto.tfvars
38
+ secrets.*.tfvars
30
39
  terraform.tfstate
31
40
  terraform.tfstate.backup
41
+ terraform/dist
32
42
  EOM
33
43
  end
34
44
  end
@@ -36,7 +46,6 @@ module RailsTemplate18f
36
46
  def update_readme
37
47
  gsub_file "README.md", /^(### Automatic linting)\s*$/, '\1 and terraform formatting'
38
48
  gsub_file "README.md", /(ruby linting) (on every)/, '\1 and terraform formatting \2'
39
- gsub_file "README.md", /^Before the first deploy only.*$/, "Follow the instructions in `terraform/README.md` to create the supporting services."
40
49
  end
41
50
 
42
51
  def install_githook
@@ -14,19 +14,22 @@ module RailsTemplate18f
14
14
 
15
15
  private
16
16
 
17
+ def terraform_manage_spaces?
18
+ # when operating in sandbox-gsa we can't use many features that rely
19
+ # on being an OrgManager
20
+ cloud_gov_organization != "sandbox-gsa"
21
+ end
22
+
17
23
  def cloud_gov_organization
18
- return options[:cg_org] if options[:cg_org].present?
19
- super
24
+ @cloud_gov_organization ||= (options[:cg_org].present? ? options[:cg_org] : super)
20
25
  end
21
26
 
22
27
  def cloud_gov_staging_space
23
- return options[:cg_staging] if options[:cg_staging].present?
24
- super
28
+ @cloud_gov_staging_space ||= (options[:cg_staging].present? ? options[:cg_staging] : super)
25
29
  end
26
30
 
27
31
  def cloud_gov_production_space
28
- return options[:cg_prod] if options[:cg_prod].present?
29
- super
32
+ @cloud_gov_production_space ||= (options[:cg_prod].present? ? options[:cg_prod] : super)
30
33
  end
31
34
  end
32
35
  end
@@ -9,8 +9,8 @@ module RailsTemplate18f
9
9
 
10
10
  def cloud_gov_organization
11
11
  if terraform_dir_exists?
12
- staging_main = file_content("terraform/staging/main.tf")
13
- if (matches = staging_main.match(/cf_org_name\s+= "(?<org_name>.*)"/))
12
+ main_tf = file_content("terraform/main.tf")
13
+ if (matches = main_tf.match(/cf_org_name\s+= "(?<org_name>.*)"/))
14
14
  return matches[:org_name]
15
15
  end
16
16
  end
@@ -19,8 +19,8 @@ module RailsTemplate18f
19
19
 
20
20
  def cloud_gov_staging_space
21
21
  if terraform_dir_exists?
22
- staging_main = file_content("terraform/staging/main.tf")
23
- if (matches = staging_main.match(/cf_space_name\s+= "(?<space_name>.*)"/))
22
+ staging_vars = file_content("terraform/staging.tfvars")
23
+ if (matches = staging_vars.match(/cf_space_name\s+= "(?<space_name>.*)"/))
24
24
  return matches[:space_name]
25
25
  end
26
26
  end
@@ -29,12 +29,12 @@ module RailsTemplate18f
29
29
 
30
30
  def cloud_gov_production_space
31
31
  if terraform_dir_exists?
32
- prod_main = file_content("terraform/production/main.tf")
33
- if (matches = prod_main.match(/cf_space_name\s+= "(?<space_name>.*)"/))
32
+ production_vars = file_content("terraform/production.tfvars")
33
+ if (matches = production_vars.match(/cf_space_name\s+= "(?<space_name>.*)"/))
34
34
  return matches[:space_name]
35
35
  end
36
36
  end
37
- "prod"
37
+ "production"
38
38
  end
39
39
  end
40
40
  end
@@ -7,6 +7,5 @@ module RailsTemplate18f
7
7
  autoload :Base
8
8
  autoload :CloudGovOptions
9
9
  autoload :CloudGovParsing
10
- autoload :PipelineOptions
11
10
  end
12
11
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsTemplate18f
4
- VERSION = "1.3.0"
4
+ VERSION = "2.0.0"
5
5
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = "Generators for creating an 18F-flavored Rails app"
12
12
  spec.homepage = "https://github.com/18f/rails-template"
13
- spec.required_ruby_version = ">= 2.7.5"
13
+ spec.required_ruby_version = ">= 3.2.0"
14
14
 
15
15
  spec.metadata["allowed_push_host"] = "https://rubygems.org/"
16
16
 
@@ -31,12 +31,12 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  # For more information and examples about making a new gem, checkout our
33
33
  # guide at: https://bundler.io/guides/creating_gem.html
34
- spec.add_dependency "railties", "~> 7.2.0"
35
- spec.add_dependency "activesupport", "~> 7.2.0"
34
+ spec.add_dependency "railties", "~> 8.0.1"
35
+ spec.add_dependency "activesupport", "~> 8.0.1"
36
36
  spec.add_dependency "thor", "~> 1.3"
37
37
  spec.add_dependency "colorize", "~> 1.1"
38
38
 
39
39
  spec.add_development_dependency "rspec", "~> 3.13"
40
40
  spec.add_development_dependency "ammeter", "~> 1.1"
41
- spec.add_development_dependency "standard", "~> 1.40"
41
+ spec.add_development_dependency "standard", "~> 1.43"
42
42
  end
data/railsrc CHANGED
@@ -5,9 +5,11 @@
5
5
  --skip-hotwire
6
6
  --skip-docker
7
7
  --skip-test
8
- --javascript=webpack
9
- --css=postcss
8
+ --javascript=esbuild
9
+ --css=sass
10
10
  --template=template.rb
11
11
  --database=postgresql
12
12
  --skip-rubocop
13
13
  --skip-ci
14
+ --skip-kamal
15
+ --skip-solid
data/railsrc-hotwire CHANGED
@@ -3,9 +3,11 @@
3
3
  --skip-action-mailbox
4
4
  --skip-docker
5
5
  --skip-test
6
- --javascript=webpack
7
- --css=postcss
6
+ --javascript=esbuild
7
+ --css=sass
8
8
  --template=template.rb
9
9
  --database=postgresql
10
10
  --skip-rubocop
11
11
  --skip-ci
12
+ --skip-kamal
13
+ --skip-solid