Module: Proteus::Commands::Plan

Defined in:
lib/proteus/commands/plan.rb

Class Method Summary collapse

Class Method Details

.included(thor_class) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/proteus/commands/plan.rb', line 4

def self.included(thor_class)
  thor_class.class_eval do

    desc "plan", "Runs terraform plan"
    long_desc "      Runs terraform plan.\n\n      With --limit option, the plan run will be limited to the specified targets\n    LONGDESC\n    option :limit, type: :array, aliases: \"-l\", default: []\n    option :destroy, type: :boolean, default: false\n    option :parallelism, type: :numeric, aliases: \"-p\", default: 10\n    def plan\n      module_manager = Proteus::Modules::Manager.new(context: context, environment: environment)\n      module_manager.clean\n      module_manager.render_modules\n\n      fmt_cmd = <<~FMT_CMD\n        cd \#{context_path(context)} && \\\n        terraform fmt -list=true .\n      FMT_CMD\n\n      fmt_output = syscall(\n        fmt_cmd.squeeze(' '),\n        capture: true,\n        suppress: true\n      )\n\n      say \"Formatted files:\", :green\n      say fmt_output, :green\n\n      init(verbose: parent_options[:verbose]) if not dryrun\n\n      terraform_command = <<~TERRAFORM_COMMAND\n        cd \#{context_path(context)} && \\\n        terraform plan \\\n        \#{\"-destroy\" if options[:destroy]} \\\n        -parallelism=\#{options[:parallelism]} \\\n        -input=false \\\n        -refresh=true \\\n        -var-file=\#{var_file(context, environment)} \\\n        -out=\#{plan_file(context, environment)} \\\n        \#{aws_profile} \#{limit(options[:limit])} \\\n        \#{context_path(context)}\n      TERRAFORM_COMMAND\n\n       syscall terraform_command.squeeze(' '), dryrun: dryrun\n    end\n  end\nend\n"