Aws parameter store basics

Hi All,

I'm trying to do something which should be soooo simple yet I just can't figure it out...

i have the following in my recipe:

aws_ssm_parameter_store 'proxydns' do
path '/myparameter/proxy'
return_key 'proxydns'
action :get
end

file 'c:\temp\proxydns.txt' do
content 'proxydns'
end

All i'm trying to do is reference the output from the 1st code block i.e. 'proxydns' in the second one.

in essence the 1st block grabs a variable out of aws parameter store and the second should write it to a file.

Any help most appreciated.

Chris.

Hi Chris,
I haven't done this before, but based on the example at https://github.com/chef-cookbooks/aws#get-bucket-name-and-retrieve-file it looks like your file resource should be structured like this:

file 'c:\temp\proxydns.txt' do
  content lazy { node.run_state['proxydns'] }
end

the code for the :get action is fairly straightforward and contains this run_state assignment: https://github.com/chef-cookbooks/aws/blob/master/resources/ssm_parameter_store.rb#L51

Thanks Chris, could have sworn I tried that already....

one more quick question, if I wanted to then make the value available to other recipes in a run_list how would I go about doing that?

Cheers

Chris.

I think the node.run_state value should persist across all recipes in the run_list, though any resource that uses it has to come after the aws_ssm_parameter_store call. The lazy method will probably also have to be used in most places, to make sure it is not evaluated until the converge phase (as opposed to the compile phase of the chef run), since it will be empty until the aws_ssm_parameter_store resource is actually converged.

Hope that helps!

Cheers bud, appreciate your help on this.