Skip to content

Instantly share code, notes, and snippets.

@rayterrill
Created May 22, 2018 15:18
Embed
What would you like to do?
Chef code to use AWS Secrets Manager in a Chef Recipe
# Chef code to use AWS Secrets Manager in a Chef Recipe
include_recipe "chef-vault"
vault = chef_vault_item(:chefsecrets, "awschefsecretsmanager")
aws_access_key = vault["access_key_id"]
aws_secret_key = vault["secret_access_key"]
require 'aws-sdk'
require 'json'
client = Aws::SecretsManager::Client.new(region: 'us-west-2', access_key_id: aws_access_key, secret_access_key: aws_secret_key)
resp = client.get_secret_value({secret_id: 'Mongo/admin'})
password = JSON.parse(resp.secret_string)
# DO NOT DO THIS. JUST SHORTCUTTING TO MAKE SURE THINGS WORK
file '/tmp/output' do
content "#{password['Password']}"
mode '0755'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment