Class: TerraBoi::TfLibGenerator

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

Constant Summary collapse

TEMPLATES =
{
  scripts: [
    "push_to_ecr.sh",
    "update_service_pull_from_ecr.sh",
  ],
  task_templates: [
    "web_app.json",
    "head_worker.json",
  ],
  terraform_modules: [
    "ecs_cluster/main.tf",
    "ecs_cluster/var.tf",

    "ecs_web_app/ecs_role.tf",
    "ecs_web_app/load_balancer.tf",
    "ecs_web_app/main.tf",
    "ecs_web_app/output.tf",
    "ecs_web_app/var.tf",

    "ecs_worker/ecs_role.tf",
    "ecs_worker/main.tf",
    "ecs_worker/output.tf",
    "ecs_worker/var.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_lib_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_lib_generator.rb', line 5

def class_options
  @class_options
end

Instance Method Details

#create_ecrObject



49
50
51
52
53
54
55
# File 'lib/generators/terra_boi/tf_lib_generator.rb', line 49

def create_ecr
  TEMPLATES.each do |dir, file_arr|
    file_arr.each do |filename|
      template "lib/#{dir}/#{filename}.erb", "terraform/lib/#{dir}/#{filename}" 
    end
  end
end

#initObject



43
44
45
46
47
# File 'lib/generators/terra_boi/tf_lib_generator.rb', line 43

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