aboutsummaryrefslogtreecommitdiff
path: root/app/jobs/setup_job.rb
blob: 6b4f9fe10c74fcda3e33313ee2ca3b0364ee0007 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'ruby_terraform'

class SetupJob < TerraformJob
  def run_terraform
    puts "Setting up #{@mini_environment.name}"

    RubyTerraform.init(
      source: 'terraform/aws',
      path: 'terraform/aws',
      backend: true,
      backend_config: {
        address: 'http://localhost:3000' + Rails.application.routes.url_helpers.terraform_http_backend_path
      }
    )

    RubyTerraform.apply(
      directory: 'terraform/aws', 
      vars: {
        slug: @mini_environment.name.parameterize
      },
      auto_approve: true
    )
  end
end