Class: TerraformDevKit::TemplateConfigFile

Inherits:
Object
  • Object
show all
Defined in:
lib/TerraformDevKit/template_config_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(content, project, env, aws_config, extra_vars: {}) ⇒ TemplateConfigFile

Returns a new instance of TemplateConfigFile.



5
6
7
8
9
10
11
# File 'lib/TerraformDevKit/template_config_file.rb', line 5

def initialize(content, project, env, aws_config, extra_vars: {})
  @content = content
  @project = project
  @env = env
  @aws_config = aws_config
  @extra_vars = extra_vars
end

Instance Method Details

#renderObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/TerraformDevKit/template_config_file.rb', line 13

def render
  args = {
    Profile: @aws_config.fetch('profile', ''),
    Region:  @aws_config.fetch('region'),
    Environment: @env.name,
    LocalBackend: @env.local_backend?,
    ProjectName: @project.name,
    ProjectAcronym: @project.acronym
  }
  args.merge!(@extra_vars)
  Mustache.render(
    @content,
    args
  )
end