Class: CloudConfig::Providers::AwsParameterStore

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud-config/providers/aws_parameter_store.rb

Overview

A class for fetching configuration from the AWS Parameter Store

Examples:

provider = AwsParameterStore.new # Assuming AWS credentials are already configured
provider.set(:example_key, :example_value)
provider.get(:example_key) #=> 'example_value'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_params = {}) ⇒ AwsParameterStore

Create a new instance of CloudConfig::Providers::AwsParameterStore.



17
18
19
# File 'lib/cloud-config/providers/aws_parameter_store.rb', line 17

def initialize(_params = {})
  @client = Aws::SSM::Client.new
end

Instance Attribute Details

#An instance of the AWS Parameter Store client(instanceoftheAWSParameterStoreclient) ⇒ Aws::SSM::Client (readonly)

Returns:

  • (Aws::SSM::Client)


14
# File 'lib/cloud-config/providers/aws_parameter_store.rb', line 14

attr_reader :client

#clientObject (readonly)

Returns the value of attribute client.



14
15
16
# File 'lib/cloud-config/providers/aws_parameter_store.rb', line 14

def client
  @client
end

Instance Method Details

#get(key) ⇒ String

Fetch the value of the key

Parameters:

  • key (String, Symbol)

    Key to fetch

Returns:

  • (String)

    Value of the key



26
27
28
# File 'lib/cloud-config/providers/aws_parameter_store.rb', line 26

def get(key)
  client.get_parameter(name: key).parameter.value
end

#set(key, value) ⇒ Object

Set the value of the key

Parameters:

  • key (String, Symbol)

    Key to set

  • value (Object)

    Value of the key



34
35
36
# File 'lib/cloud-config/providers/aws_parameter_store.rb', line 34

def set(key, value)
  client.put_parameter(name: key, value:)
end