aboutsummaryrefslogtreecommitdiff
path: root/app/jobs/destroy_job.rb
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-02-06 23:32:48 +0000
committerChristopher Baines <mail@cbaines.net>2018-03-29 07:30:29 +0100
commit700b8b0a112fa976b9850418a7f0c71d95b6dd79 (patch)
tree6e0b4b20f3bd319c4d70b5e363c521ed3c19bdb7 /app/jobs/destroy_job.rb
parent2d7bc302ad6d15461a10a67bd5e7e83e3dda279b (diff)
downloadgovuk-mini-environment-admin-700b8b0a112fa976b9850418a7f0c71d95b6dd79.tar
govuk-mini-environment-admin-700b8b0a112fa976b9850418a7f0c71d95b6dd79.tar.gz
AWS related tweaks
Diffstat (limited to 'app/jobs/destroy_job.rb')
-rw-r--r--app/jobs/destroy_job.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/jobs/destroy_job.rb b/app/jobs/destroy_job.rb
new file mode 100644
index 0000000..7f13fdd
--- /dev/null
+++ b/app/jobs/destroy_job.rb
@@ -0,0 +1,26 @@
+require 'ruby_terraform'
+
+class DestroyJob < TerraformJob
+ @retry_interval = 30
+
+ def run_terraform
+ puts "Destroying #{@mini_environment.name}"
+
+ Dir.chdir('terraform/aws') do
+ RubyTerraform.destroy(
+ vars: {
+ aws_region: 'eu-west-1',
+ slug: @mini_environment.name.parameterize,
+ ssh_public_key: ssh_public_key,
+ },
+ force: true
+ )
+ end
+ end
+
+ def ssh_public_key
+ File.open("#{ENV['HOME']}/.ssh/id_rsa.pub") do |file|
+ file.readline()
+ end
+ end
+end