aboutsummaryrefslogtreecommitdiff
path: root/app/jobs/destroy_job.rb
diff options
context:
space:
mode:
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