Class: Dome::Terraform
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #apply ⇒ Object
- #create_plan ⇒ Object
- #delete_plan_file ⇒ Object
- #delete_terraform_directory ⇒ Object
-
#initialize ⇒ Terraform
constructor
A new instance of Terraform.
- #install_terraform_modules ⇒ Object
- #output ⇒ Object
- #plan ⇒ Object
- #validate_environment ⇒ Object
Methods included from Shell
Constructor Details
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
5 6 7 |
# File 'lib/dome/terraform.rb', line 5 def state @state end |
Instance Method Details
#apply ⇒ Object
31 32 33 34 35 |
# File 'lib/dome/terraform.rb', line 31 def apply command = "terraform apply #{@plan_file}" = 'something went wrong when applying the TF plan' execute_command(command, ) end |
#create_plan ⇒ Object
37 38 39 40 41 |
# File 'lib/dome/terraform.rb', line 37 def create_plan command = "terraform plan -module-depth=1 -refresh=true -out=#{@plan_file} -var-file=params/env.tfvars" = 'something went wrong when creating the TF plan' execute_command(command, ) end |
#delete_plan_file ⇒ Object
50 51 52 53 54 |
# File 'lib/dome/terraform.rb', line 50 def delete_plan_file puts 'Deleting older terraform plan ...'.colorize(:green) puts "About to delete: #{@plan_file}" FileUtils.rm_f @plan_file end |
#delete_terraform_directory ⇒ Object
43 44 45 46 47 48 |
# File 'lib/dome/terraform.rb', line 43 def delete_terraform_directory puts 'Deleting older terraform module cache dir ...'.colorize(:green) terraform_directory = '.terraform' puts "About to delete directory: #{terraform_directory}" FileUtils.rm_rf '.terraform/' end |
#install_terraform_modules ⇒ Object
56 57 58 59 60 |
# File 'lib/dome/terraform.rb', line 56 def install_terraform_modules command = 'terraform get -update=true' = 'something went wrong when pulling remote TF modules' execute_command(command, ) end |
#output ⇒ Object
62 63 64 65 66 |
# File 'lib/dome/terraform.rb', line 62 def output command = 'terraform output' = 'something went wrong when printing TF output variables' execute_command(command, ) end |
#plan ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/dome/terraform.rb', line 23 def plan delete_terraform_directory delete_plan_file install_terraform_modules @state.synchronise_s3_state create_plan end |
#validate_environment ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/dome/terraform.rb', line 13 def validate_environment environment = @environment.environment account = @environment.account @environment. unless @environment.valid_account? account @environment. unless @environment.valid_environment?(account, environment) puts "Team: #{@environment.team.colorize(:green)}" puts '----------------------------------------------------------------' @environment.populate_aws_access_keys end |