Class: Ufo::TaskDefinition::Helpers::Ssm::Fetcher
- Inherits:
-
Object
- Object
- Ufo::TaskDefinition::Helpers::Ssm::Fetcher
- Includes:
- AwsServices, Concerns::Names, Utils::Logging
- Defined in:
- lib/ufo/task_definition/helpers/ssm/fetcher.rb
Instance Method Summary collapse
- #base64?(type) ⇒ Boolean
- #fetch(name) ⇒ Object
-
#fetch_parameter(name) ⇒ Object
Note: Cannot use logger if since if ssm helper is used in config it’ll cause an infinite loop.
-
#initialize(options = {}) ⇒ Fetcher
constructor
A new instance of Fetcher.
Methods included from Concerns::Names
Methods included from Utils::Logging
Methods included from AwsServices
#acm, #applicationautoscaling, #aws_options, #cfn, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb, #s3, #ssm_client, #waf_client
Methods included from AwsServices::Concerns
#find_stack, #find_stack_resources, #stack_resources, #status, #task_definition_arns
Constructor Details
#initialize(options = {}) ⇒ Fetcher
Returns a new instance of Fetcher.
7 8 9 10 |
# File 'lib/ufo/task_definition/helpers/ssm/fetcher.rb', line 7 def initialize(={}) @options = @base64 = [:base64] end |
Instance Method Details
#base64?(type) ⇒ Boolean
21 22 23 24 25 26 27 |
# File 'lib/ufo/task_definition/helpers/ssm/fetcher.rb', line 21 def base64?(type) if @base64.nil? type == "SecureString" else @base64 end end |
#fetch(name) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/ufo/task_definition/helpers/ssm/fetcher.rb', line 12 def fetch(name) name = names.expansion(name, dasherize: false) parameter = fetch_parameter(name) return unless parameter value = parameter.value value = Base64.strict_encode64(value).strip if base64?(parameter.type) value end |
#fetch_parameter(name) ⇒ Object
Note: Cannot use logger if since if ssm helper is used in config it’ll cause an infinite loop
30 31 32 33 34 35 36 37 |
# File 'lib/ufo/task_definition/helpers/ssm/fetcher.rb', line 30 def fetch_parameter(name) resp = ssm_client.get_parameter(name: name, with_decryption: true) resp.parameter rescue Aws::SSM::Errors::ParameterNotFound => e puts "WARN: name #{name} not found".color(:yellow) puts e. nil end |