Class: SimplyGenius::Atmos::Commands::Bootstrap
- Inherits:
-
BaseCommand
- Object
- Clamp::Command
- BaseCommand
- SimplyGenius::Atmos::Commands::Bootstrap
show all
- Defined in:
- lib/simplygenius/atmos/commands/bootstrap.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from UI
#agree, #ask, #choose, color_enabled, color_enabled=, #display, #error, #notify, #say, #warn
Class Method Details
.description ⇒ Object
9
10
11
|
# File 'lib/simplygenius/atmos/commands/bootstrap.rb', line 9
def self.description
"Sets up the initial aws account for use by atmos"
end
|
Instance Method Details
#execute ⇒ Object
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/simplygenius/atmos/commands/bootstrap.rb', line 16
def execute
orig_config = Atmos.config
Atmos.config = Config.new(Atmos.config.atmos_env, 'bootstrap')
tf_init_dir = File.join(Atmos.config.tf_working_dir, '.terraform')
tf_initialized = File.exist?(tf_init_dir)
backend_initialized = File.exist?(File.join(tf_init_dir, 'terraform.tfstate'))
rebootstrap_msg = <<~EOF
Bootstrap should only be performed when provisioning an account for the first
time. Try 'atmos terraform init'
EOF
if !force? && tf_initialized
signal_usage_error(rebootstrap_msg)
end
Atmos.config.provider.auth_manager.authenticate(ENV, bootstrap: true) do |auth_env|
begin
exe = TerraformExecutor.new(process_env: auth_env)
skip_backend = true
skip_secrets = true
if backend_initialized
skip_backend = false
skip_secrets = false
end
exe.run("init", "-input=false", "-lock=false",
skip_backend: true, skip_secrets: true)
exe.run("apply", "-input=false",
skip_backend: true, skip_secrets: true)
exe.run("init", "-input=false", "-force-copy", skip_secrets: true)
Atmos.config = orig_config
exe = TerraformExecutor.new(process_env: auth_env)
exe.run("init", "-input=false", skip_secrets: true)
rescue TerraformExecutor::ProcessFailed => e
logger.error(e.message)
logger.error(rebootstrap_msg)
end
end
end
|