I put credentials into an s3 bucket and I use a ruby block to grab them. I then want to set an environment variable such that when upstart starts a process it uses this variable. However the block of ruby runs after attributes are set so I thought using lazy
would be appropriate, but it's not clear to me how to set env
using lazy
.
Would it be something like:
ruby_block "get-credentials" do
block do
Chef::Log.info 'Getting sdk.'
require 'aws-sdk'
Chef::Log.info 'Getting making aws s3 instance.'
s3 = AWS::S3.new
Chef::Log.info 'Getting credentials from s3.'
bar = s3.buckets['bucket-name'].objects['bar'].read
Chef::Log.info 'Got bar with length #{bar.length}'
node.set['foo']['bar'] = bar
end
action :run
end
env lazy BAR=node.set['foo']['bar']
service 'foo' do
provider Chef::Provider::Service::Upstart
action [ :enable, :start ]
end
I'm not sure. I am still looking through the documentation and experimenting but maybe someone knows. The turn around on testing different variations is taking a really long time.