How to separate DEV and PRODUCTION environments in OpsWorks?
-
21-12-2019 - |
Question
I'm looking for a way to maintain multiple environments (development, test, production) of the same application in OpsWorks. My application only needs a static config file after deployment.
Solution
The easiest thing to do is to just CLONE the opsworks stack after you've made it.
Once done, modify the application branch names ( if different for different envs )
If you're only needing to generate generate a specific config file for a specific environment, you could do something post checkout using deployment hooks ( reference to deployment hook )
## deploy/before_restart.rb ( in your application folder )
stackname = node[:opsworks][:stack][:name]
if stackname.include?("dev")
secret = "boo"
elseif stackname.include?("production")
secret = "boo2"
else
secret = "boo3"
end
file "/etc/website-config.conf" do
content "password=#{secret}"
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow