rails_template_18f 2.0.0 → 2.2.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 +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +9 -7
- data/lib/generators/rails_template18f/active_storage/active_storage_generator.rb +4 -3
- data/lib/generators/rails_template18f/auditree/auditree_generator.rb +36 -6
- data/lib/generators/rails_template18f/auditree/templates/gitlab/auditree.yml.tt +48 -0
- data/lib/generators/rails_template18f/circleci/templates/circleci/config.yml.tt +12 -2
- data/lib/generators/rails_template18f/cloud_gov_config/cloud_gov_config_generator.rb +0 -8
- data/lib/generators/rails_template18f/cloud_gov_config/templates/app/models/cloud_gov_config.rb +6 -7
- data/lib/generators/rails_template18f/cloud_gov_config/templates/spec/models/cloud_gov_config_spec.rb +13 -19
- data/lib/generators/rails_template18f/github_actions/github_actions_generator.rb +0 -4
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml +3 -1
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml +3 -1
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-production.yml +3 -1
- data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-staging.yml +3 -1
- data/lib/generators/rails_template18f/gitlab_ci/gitlab_ci_generator.rb +138 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/node.yml.tt +11 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/rails.yml +75 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/ruby.yml +7 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/terraform.yml +33 -0
- data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab-ci.yml.tt +213 -0
- data/lib/generators/rails_template18f/oscal/oscal_generator.rb +15 -1
- data/lib/generators/rails_template18f/oscal/templates/bin/trestle.tt +10 -1
- data/lib/generators/rails_template18f/oscal/templates/gitlab/trestle.yml.tt +29 -0
- data/lib/generators/rails_template18f/public_egress/public_egress_generator.rb +16 -32
- data/lib/generators/rails_template18f/sidekiq/templates/config/initializers/redis.rb +1 -1
- data/lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/apply.sh +25 -0
- data/lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/main.tf.tt +98 -0
- data/lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/setup_shadowenv.sh +59 -0
- data/lib/generators/rails_template18f/terraform/templates/s3_bootstrap/common/templates/backend_config.tftpl +6 -0
- data/lib/generators/rails_template18f/terraform/templates/s3_bootstrap/common/templates/bot_secrets.tftpl +5 -0
- data/lib/generators/rails_template18f/terraform/templates/s3_bootstrap/common/users.auto.tfvars +5 -0
- data/lib/generators/rails_template18f/terraform/templates/{full_bootstrap → s3_bootstrap/full}/main.tf.tt +4 -11
- data/lib/generators/rails_template18f/terraform/templates/{sandbox_bootstrap → s3_bootstrap/sandbox}/main.tf.tt +3 -3
- data/lib/generators/rails_template18f/terraform/templates/terraform/.shadowenv.d/.gitignore +3 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt +38 -36
- data/lib/generators/rails_template18f/terraform/templates/terraform/app.tf.tt +1 -6
- data/lib/generators/rails_template18f/terraform/templates/terraform/main.tf.tt +30 -19
- data/lib/generators/rails_template18f/terraform/templates/terraform/production.tfvars.tt +3 -0
- data/lib/generators/rails_template18f/terraform/templates/terraform/providers.tf.tt +4 -24
- data/lib/generators/rails_template18f/terraform/templates/terraform/staging.tfvars.tt +5 -5
- data/lib/generators/rails_template18f/terraform/templates/terraform/terraform.sh.tt +40 -55
- data/lib/generators/rails_template18f/terraform/templates/terraform/variables.tf.tt +11 -12
- data/lib/generators/rails_template18f/terraform/terraform_generator.rb +78 -6
- data/lib/rails_template18f/version.rb +1 -1
- data/template.rb +50 -25
- data/templates/{pa11yci.js → pa11yci.js.tt} +5 -0
- metadata +28 -20
- data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/templates/backend_config.tftpl +0 -8
- data/lib/generators/rails_template18f/terraform/templates/terraform/sandbox_bot/main.tf +0 -74
- data/lib/generators/rails_template18f/terraform/templates/terraform/sandbox_bot/run.sh +0 -17
- /data/lib/generators/rails_template18f/{github_actions → oscal}/templates/github/workflows/assemble-ssp.yml.tt +0 -0
- /data/lib/generators/rails_template18f/{github_actions → oscal}/templates/github/workflows/validate-ssp.yml +0 -0
- /data/lib/generators/rails_template18f/terraform/templates/{terraform/bootstrap/templates → gitlab_bootstrap}/bot_secrets.tftpl +0 -0
- /data/lib/generators/rails_template18f/terraform/templates/{terraform/bootstrap → gitlab_bootstrap}/users.auto.tfvars +0 -0
- /data/lib/generators/rails_template18f/terraform/templates/{terraform/bootstrap → s3_bootstrap/common}/apply.sh +0 -0
- /data/lib/generators/rails_template18f/terraform/templates/{full_bootstrap → s3_bootstrap/full}/imports.tf.tftpl +0 -0
- /data/lib/generators/rails_template18f/terraform/templates/{sandbox_bootstrap → s3_bootstrap/sandbox}/imports.tf.tftpl +0 -0
data/template.rb
CHANGED
@@ -99,8 +99,13 @@ end
|
|
99
99
|
cloud_gov_staging_space = default_staging_space if cloud_gov_staging_space.blank?
|
100
100
|
cloud_gov_production_space = default_prod_space if cloud_gov_production_space.blank?
|
101
101
|
|
102
|
+
@gitlab_ci = yes?("Create GitLab CI config? (y/n)")
|
102
103
|
@github_actions = yes?("Create GitHub Actions? (y/n)")
|
103
104
|
@circleci_pipeline = yes?("Create CircleCI config? (y/n)")
|
105
|
+
local_terraform_backend = false
|
106
|
+
unless [@gitlab_ci, @github_actions, @circleci_pipeline].any?
|
107
|
+
local_terraform_backend = yes?("Use a local file to store terraform state? This is only appropriate for short-lived proofs of concept but will make it easier to deploy for a single dev. (y/n)")
|
108
|
+
end
|
104
109
|
newrelic = yes?("Create FEDRAMP New Relic config files? (y/n)")
|
105
110
|
dap = yes?("If this will be a public site, should we include Digital Analytics Program code? (y/n)")
|
106
111
|
supported_languages = []
|
@@ -127,20 +132,27 @@ register_announcement("Documentation", <<~EOM)
|
|
127
132
|
EOM
|
128
133
|
|
129
134
|
# do early so later generators register files in the correct location
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
135
|
+
run_oscal_generator = ->(register_announcement = false) {
|
136
|
+
if compliance_trestle
|
137
|
+
after_bundle do
|
138
|
+
generator_arguments = []
|
139
|
+
generator_arguments << "--oscal_repo=#{compliance_trestle_repo}" if compliance_trestle_submodule
|
140
|
+
generator_arguments << "--ci=github" if @github_actions
|
141
|
+
generator_arguments << "--ci=gitlab" if @gitlab_ci
|
142
|
+
generator_arguments << "--ci=circleci" if @circleci_pipeline
|
143
|
+
generate "rails_template18f:oscal", *generator_arguments
|
144
|
+
end
|
145
|
+
if register_announcement
|
146
|
+
register_announcement("OSCAL Documentation", <<~EOM)
|
147
|
+
OSCAL files have been generated with some default implementation statements in `doc/compliance/oscal`
|
139
148
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
end
|
149
|
+
All generated statements must be reviewed for accuracy with your system's implementation before being
|
150
|
+
submitted for authorization.
|
151
|
+
EOM
|
152
|
+
end
|
153
|
+
end
|
154
|
+
}
|
155
|
+
run_oscal_generator.call(true)
|
144
156
|
|
145
157
|
# ensure dependencies are installed
|
146
158
|
copy_file "Brewfile"
|
@@ -193,7 +205,7 @@ chmod "bin/ops/create_service_account.sh", 0o755
|
|
193
205
|
chmod "bin/ops/destroy_service_account.sh", 0o755
|
194
206
|
chmod "bin/ops/set_space_egress.sh", 0o755
|
195
207
|
copy_file "pa11y.js"
|
196
|
-
|
208
|
+
template "pa11yci.js"
|
197
209
|
copy_file "editorconfig", ".editorconfig"
|
198
210
|
copy_file "zap.conf"
|
199
211
|
after_bundle do
|
@@ -398,13 +410,19 @@ after_bundle do
|
|
398
410
|
"--cg-staging=#{cloud_gov_staging_space}",
|
399
411
|
"--cg-prod=#{cloud_gov_production_space}"
|
400
412
|
]
|
413
|
+
if @gitlab_ci
|
414
|
+
generator_arguments << "--backend=gitlab"
|
415
|
+
elsif local_terraform_backend
|
416
|
+
generator_arguments << "--backend=local"
|
417
|
+
end
|
401
418
|
generate "rails_template18f:terraform", *generator_arguments
|
402
419
|
end
|
403
420
|
if cloud_gov_org_tktk?
|
404
421
|
register_announcement("Terraform", <<~EOM)
|
405
|
-
Fill in the cloud.gov organization information in:
|
422
|
+
Fill in the cloud.gov organization and space information in:
|
406
423
|
* terraform/bootstrap/main.tf
|
407
424
|
* terraform/main.tf
|
425
|
+
* terraform/*.tfvars
|
408
426
|
EOM
|
409
427
|
end
|
410
428
|
register_announcement("Terraform", "Run the bootstrap script and update the appropriate CI/CD environment variables defined in the Deployment section of the README")
|
@@ -430,11 +448,6 @@ if @github_actions
|
|
430
448
|
]
|
431
449
|
generate "rails_template18f:github_actions", *generator_arguments
|
432
450
|
end
|
433
|
-
if cloud_gov_org_tktk?
|
434
|
-
register_announcement("GitHub Actions", <<~EOM)
|
435
|
-
* Fill in the cloud.gov organization information in .github/workflows/deploy-staging.yml
|
436
|
-
EOM
|
437
|
-
end
|
438
451
|
register_announcement("GitHub Actions", <<~EOM)
|
439
452
|
* Create environment variable secrets for deploy users as defined in the Deployment section of the README
|
440
453
|
EOM
|
@@ -449,16 +462,28 @@ if @circleci_pipeline
|
|
449
462
|
]
|
450
463
|
generate "rails_template18f:circleci", *generator_arguments
|
451
464
|
end
|
452
|
-
if cloud_gov_org_tktk?
|
453
|
-
register_announcement("CircleCI", <<~EOM)
|
454
|
-
* Fill in the cloud.gov organization information in .circleci/config.yml
|
455
|
-
EOM
|
456
|
-
end
|
457
465
|
register_announcement("CircleCI", <<~EOM)
|
458
466
|
* Create project environment variables for deploy users as defined in the Deployment section of the README
|
459
467
|
EOM
|
460
468
|
end
|
461
469
|
|
470
|
+
if @gitlab_ci
|
471
|
+
after_bundle do
|
472
|
+
generator_arguments = [
|
473
|
+
"--cg-org=#{@cloud_gov_organization}",
|
474
|
+
"--cg-staging=#{cloud_gov_staging_space}",
|
475
|
+
"--cg-prod=#{cloud_gov_production_space}"
|
476
|
+
]
|
477
|
+
generate "rails_template18f:gitlab_ci", *generator_arguments
|
478
|
+
end
|
479
|
+
register_announcement("GitLab CI", <<~EOM)
|
480
|
+
* Create project environment variables for deploy users as defined in the Deployment section of the README
|
481
|
+
EOM
|
482
|
+
end
|
483
|
+
|
484
|
+
# rerun so we can update the correct CI systems
|
485
|
+
run_oscal_generator.call
|
486
|
+
|
462
487
|
if auditree
|
463
488
|
after_bundle do
|
464
489
|
generate "rails_template18f:auditree", "--evidence_locker=#{auditree_evidence_repo}"
|
@@ -2,7 +2,12 @@ let defaults = require("./pa11y.js");
|
|
2
2
|
|
3
3
|
// set chrome path for github actions
|
4
4
|
defaults.defaults.chromeLaunchConfig = {
|
5
|
+
<% if @gitlab_ci %>
|
6
|
+
"executablePath": "/usr/bin/chromium",
|
7
|
+
"args": ["--no-sandbox"]
|
8
|
+
<% else %>
|
5
9
|
"executablePath": "/usr/bin/google-chrome"
|
10
|
+
<% end %>
|
6
11
|
};
|
7
12
|
|
8
13
|
module.exports = defaults;
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_template_18f
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Ahearn
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: railties
|
@@ -108,7 +107,6 @@ dependencies:
|
|
108
107
|
- - "~>"
|
109
108
|
- !ruby/object:Gem::Version
|
110
109
|
version: '1.43'
|
111
|
-
description:
|
112
110
|
email:
|
113
111
|
- ryan.ahearn@gsa.gov
|
114
112
|
executables:
|
@@ -140,6 +138,7 @@ files:
|
|
140
138
|
- lib/generators/rails_template18f/auditree/templates/bin/auditree.tt
|
141
139
|
- lib/generators/rails_template18f/auditree/templates/github/actions/auditree-cmd/action.yml.tt
|
142
140
|
- lib/generators/rails_template18f/auditree/templates/github/workflows/auditree-validation.yml.tt
|
141
|
+
- lib/generators/rails_template18f/auditree/templates/gitlab/auditree.yml.tt
|
143
142
|
- lib/generators/rails_template18f/circleci/circleci_generator.rb
|
144
143
|
- lib/generators/rails_template18f/circleci/templates/Dockerfile.ci.tt
|
145
144
|
- lib/generators/rails_template18f/circleci/templates/bin/ci-server-start
|
@@ -156,7 +155,6 @@ files:
|
|
156
155
|
- lib/generators/rails_template18f/github_actions/templates/github/actions/setup-languages/action.yml.tt
|
157
156
|
- lib/generators/rails_template18f/github_actions/templates/github/actions/setup-project/action.yml.tt
|
158
157
|
- lib/generators/rails_template18f/github_actions/templates/github/dependabot.yml.tt
|
159
|
-
- lib/generators/rails_template18f/github_actions/templates/github/workflows/assemble-ssp.yml.tt
|
160
158
|
- lib/generators/rails_template18f/github_actions/templates/github/workflows/brakeman-analysis.yml
|
161
159
|
- lib/generators/rails_template18f/github_actions/templates/github/workflows/dependency-scans.yml
|
162
160
|
- lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml
|
@@ -167,8 +165,13 @@ files:
|
|
167
165
|
- lib/generators/rails_template18f/github_actions/templates/github/workflows/rspec.yml.tt
|
168
166
|
- lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-production.yml
|
169
167
|
- lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-staging.yml
|
170
|
-
- lib/generators/rails_template18f/github_actions/templates/github/workflows/validate-ssp.yml
|
171
168
|
- lib/generators/rails_template18f/github_actions/templates/oscal/component-definitions/github_actions/component-definition.json.tt
|
169
|
+
- lib/generators/rails_template18f/gitlab_ci/gitlab_ci_generator.rb
|
170
|
+
- lib/generators/rails_template18f/gitlab_ci/templates/gitlab-ci.yml.tt
|
171
|
+
- lib/generators/rails_template18f/gitlab_ci/templates/gitlab/node.yml.tt
|
172
|
+
- lib/generators/rails_template18f/gitlab_ci/templates/gitlab/rails.yml
|
173
|
+
- lib/generators/rails_template18f/gitlab_ci/templates/gitlab/ruby.yml
|
174
|
+
- lib/generators/rails_template18f/gitlab_ci/templates/gitlab/terraform.yml
|
172
175
|
- lib/generators/rails_template18f/i18n/i18n_generator.rb
|
173
176
|
- lib/generators/rails_template18f/i18n/templates/config/locales/en.yml.tt
|
174
177
|
- lib/generators/rails_template18f/i18n/templates/config/locales/es.yml
|
@@ -186,26 +189,33 @@ files:
|
|
186
189
|
- lib/generators/rails_template18f/oscal/templates/bin/trestle.tt
|
187
190
|
- lib/generators/rails_template18f/oscal/templates/doc/compliance/oscal/trestle-config.yaml.tt
|
188
191
|
- lib/generators/rails_template18f/oscal/templates/github/actions/trestle-cmd/action.yml.tt
|
192
|
+
- lib/generators/rails_template18f/oscal/templates/github/workflows/assemble-ssp.yml.tt
|
193
|
+
- lib/generators/rails_template18f/oscal/templates/github/workflows/validate-ssp.yml
|
194
|
+
- lib/generators/rails_template18f/oscal/templates/gitlab/trestle.yml.tt
|
189
195
|
- lib/generators/rails_template18f/public_egress/public_egress_generator.rb
|
190
196
|
- lib/generators/rails_template18f/rails_erd/rails_erd_generator.rb
|
191
197
|
- lib/generators/rails_template18f/rails_erd/templates/erdconfig
|
192
198
|
- lib/generators/rails_template18f/sidekiq/sidekiq_generator.rb
|
193
199
|
- lib/generators/rails_template18f/sidekiq/templates/config/initializers/redis.rb
|
194
|
-
- lib/generators/rails_template18f/terraform/templates/
|
195
|
-
- lib/generators/rails_template18f/terraform/templates/
|
196
|
-
- lib/generators/rails_template18f/terraform/templates/
|
197
|
-
- lib/generators/rails_template18f/terraform/templates/
|
200
|
+
- lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/apply.sh
|
201
|
+
- lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/bot_secrets.tftpl
|
202
|
+
- lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/main.tf.tt
|
203
|
+
- lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/setup_shadowenv.sh
|
204
|
+
- lib/generators/rails_template18f/terraform/templates/gitlab_bootstrap/users.auto.tfvars
|
205
|
+
- lib/generators/rails_template18f/terraform/templates/s3_bootstrap/common/apply.sh
|
206
|
+
- lib/generators/rails_template18f/terraform/templates/s3_bootstrap/common/templates/backend_config.tftpl
|
207
|
+
- lib/generators/rails_template18f/terraform/templates/s3_bootstrap/common/templates/bot_secrets.tftpl
|
208
|
+
- lib/generators/rails_template18f/terraform/templates/s3_bootstrap/common/users.auto.tfvars
|
209
|
+
- lib/generators/rails_template18f/terraform/templates/s3_bootstrap/full/imports.tf.tftpl
|
210
|
+
- lib/generators/rails_template18f/terraform/templates/s3_bootstrap/full/main.tf.tt
|
211
|
+
- lib/generators/rails_template18f/terraform/templates/s3_bootstrap/sandbox/imports.tf.tftpl
|
212
|
+
- lib/generators/rails_template18f/terraform/templates/s3_bootstrap/sandbox/main.tf.tt
|
213
|
+
- lib/generators/rails_template18f/terraform/templates/terraform/.shadowenv.d/.gitignore
|
198
214
|
- lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt
|
199
215
|
- lib/generators/rails_template18f/terraform/templates/terraform/app.tf.tt
|
200
|
-
- lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/apply.sh
|
201
|
-
- lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/templates/backend_config.tftpl
|
202
|
-
- lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/templates/bot_secrets.tftpl
|
203
|
-
- lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/users.auto.tfvars
|
204
216
|
- lib/generators/rails_template18f/terraform/templates/terraform/main.tf.tt
|
205
217
|
- lib/generators/rails_template18f/terraform/templates/terraform/production.tfvars.tt
|
206
218
|
- lib/generators/rails_template18f/terraform/templates/terraform/providers.tf.tt
|
207
|
-
- lib/generators/rails_template18f/terraform/templates/terraform/sandbox_bot/main.tf
|
208
|
-
- lib/generators/rails_template18f/terraform/templates/terraform/sandbox_bot/run.sh
|
209
219
|
- lib/generators/rails_template18f/terraform/templates/terraform/staging.tfvars.tt
|
210
220
|
- lib/generators/rails_template18f/terraform/templates/terraform/terraform.sh.tt
|
211
221
|
- lib/generators/rails_template18f/terraform/templates/terraform/variables.tf.tt
|
@@ -255,7 +265,7 @@ files:
|
|
255
265
|
- templates/lib/tasks/cf.rake
|
256
266
|
- templates/lib/tasks/scanning.rake
|
257
267
|
- templates/pa11y.js
|
258
|
-
- templates/pa11yci.js
|
268
|
+
- templates/pa11yci.js.tt
|
259
269
|
- templates/zap.conf
|
260
270
|
homepage: https://github.com/18f/rails-template
|
261
271
|
licenses: []
|
@@ -264,7 +274,6 @@ metadata:
|
|
264
274
|
homepage_uri: https://github.com/18f/rails-template
|
265
275
|
source_code_uri: https://github.com/18f/rails-template
|
266
276
|
changelog_uri: https://github.com/18f/rails-template/blob/main/CHANGELOG.md
|
267
|
-
post_install_message:
|
268
277
|
rdoc_options: []
|
269
278
|
require_paths:
|
270
279
|
- lib
|
@@ -279,8 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
288
|
- !ruby/object:Gem::Version
|
280
289
|
version: '0'
|
281
290
|
requirements: []
|
282
|
-
rubygems_version: 3.
|
283
|
-
signing_key:
|
291
|
+
rubygems_version: 3.6.7
|
284
292
|
specification_version: 4
|
285
293
|
summary: Generators for creating an 18F-flavored Rails app
|
286
294
|
test_files: []
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# remove this file after initializing your terraform
|
2
|
-
# you can always regenerate it by running ./apply.sh
|
3
|
-
# within the bootstrap module
|
4
|
-
|
5
|
-
bucket = "${creds.bucket}"
|
6
|
-
region = "${creds.region}"
|
7
|
-
access_key = "${creds.access_key_id}"
|
8
|
-
secret_key = "${creds.secret_access_key}"
|
@@ -1,74 +0,0 @@
|
|
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
|
-
}
|
@@ -1,17 +0,0 @@
|
|
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" "$@"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|