Class: Putpaws::Provision::Resources::TaskDefinition::TemplateContext

Inherits:
Object
  • Object
show all
Defined in:
lib/putpaws/provision/resources/task_definition.rb

Overview

Variables exposed to taskdef ERB templates.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ TemplateContext

Returns a new instance of TemplateContext.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/putpaws/provision/resources/task_definition.rb', line 18

def initialize(config)
  settings = config.settings
  @service_name = config.service_name
  @region = config.region
  @account_id = config.
  @cpu = settings[:cpu].to_s
  @memory = settings[:memory].to_s
  @container_port = (settings[:container_port] || 3000).to_i
  @image = config.ecr_image_uri
  @nginx_image = settings[:nginx_image] || 'public.ecr.aws/nginx/nginx:stable'
  @log_group = config.log_group
  @execution_role_arn = config.roles[:task_execution_role_arn]
  @task_role_arn = config.roles[:task_role_arn]
  @env_json = JSON.generate(
    (settings[:env] || {}).map{|k, v| {name: k.to_s, value: v.to_s}}
  )
  @secrets_json = JSON.generate(
    config.resolved_secrets.map{|name, path|
      {name: name, valueFrom: "arn:aws:ssm:#{config.region}:#{config.}:parameter#{path}"}
    }
  )
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



13
14
15
# File 'lib/putpaws/provision/resources/task_definition.rb', line 13

def 
  @account_id
end

#container_portObject (readonly)

Returns the value of attribute container_port.



13
14
15
# File 'lib/putpaws/provision/resources/task_definition.rb', line 13

def container_port
  @container_port
end

#cpuObject (readonly)

Returns the value of attribute cpu.



13
14
15
# File 'lib/putpaws/provision/resources/task_definition.rb', line 13

def cpu
  @cpu
end

#env_jsonObject (readonly)

Returns the value of attribute env_json.



13
14
15
# File 'lib/putpaws/provision/resources/task_definition.rb', line 13

def env_json
  @env_json
end

#execution_role_arnObject (readonly)

Returns the value of attribute execution_role_arn.



13
14
15
# File 'lib/putpaws/provision/resources/task_definition.rb', line 13

def execution_role_arn
  @execution_role_arn
end

#imageObject (readonly)

Returns the value of attribute image.



13
14
15
# File 'lib/putpaws/provision/resources/task_definition.rb', line 13

def image
  @image
end

#log_groupObject (readonly)

Returns the value of attribute log_group.



13
14
15
# File 'lib/putpaws/provision/resources/task_definition.rb', line 13

def log_group
  @log_group
end

#memoryObject (readonly)

Returns the value of attribute memory.



13
14
15
# File 'lib/putpaws/provision/resources/task_definition.rb', line 13

def memory
  @memory
end

#nginx_imageObject (readonly)

Returns the value of attribute nginx_image.



13
14
15
# File 'lib/putpaws/provision/resources/task_definition.rb', line 13

def nginx_image
  @nginx_image
end

#regionObject (readonly)

Returns the value of attribute region.



13
14
15
# File 'lib/putpaws/provision/resources/task_definition.rb', line 13

def region
  @region
end

#secrets_jsonObject (readonly)

Returns the value of attribute secrets_json.



13
14
15
# File 'lib/putpaws/provision/resources/task_definition.rb', line 13

def secrets_json
  @secrets_json
end

#service_nameObject (readonly)

Returns the value of attribute service_name.



13
14
15
# File 'lib/putpaws/provision/resources/task_definition.rb', line 13

def service_name
  @service_name
end

#task_role_arnObject (readonly)

Returns the value of attribute task_role_arn.



13
14
15
# File 'lib/putpaws/provision/resources/task_definition.rb', line 13

def task_role_arn
  @task_role_arn
end

Instance Method Details

#get_bindingObject



41
42
43
# File 'lib/putpaws/provision/resources/task_definition.rb', line 41

def get_binding
  binding
end