Class: TerraBoi::TfEnvGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/terra_boi/tf_env_generator.rb

Constant Summary collapse

TEMPLATES =
{
	ecs_cluster: [
		"ecs_cluster.tf",
	],
	head_worker: [
		"ecs.tf",
	],
	web_app: [
		"ecs.tf",
	],
	data: [
		"main.tf",
		"output.tf",
	]
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#application_nameObject

Returns the value of attribute application_name.



5
6
7
# File 'lib/generators/terra_boi/tf_env_generator.rb', line 5

def application_name
  @application_name
end

#class_optionsObject

Returns the value of attribute class_options.



5
6
7
# File 'lib/generators/terra_boi/tf_env_generator.rb', line 5

def class_options
  @class_options
end

Instance Method Details

#create_ecsObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/generators/terra_boi/tf_env_generator.rb', line 42

def create_ecs
	class_options[:envs].each do |env|
		TEMPLATES.each do |dir, file_arr|
			file_arr.each do |filename|
				template "env/#{dir}/#{filename}.erb", "terraform/#{env}/#{dir}/#{filename}", {
					env: env,
				}
			end
		end
	end
end

#initObject



36
37
38
39
40
# File 'lib/generators/terra_boi/tf_env_generator.rb', line 36

def init
	# defined in lib/generators/extensions
	self.application_name = generate_application_name separators: false
	self.class_options = options
end