You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now in AWS is possible to define environment variables directly inside the AWS OpsWorks console.
To do that we have to go to "Apps" section and click on the actions "edit" related to our app.
Then, under "Environment Variables" we can declare all env variables we need.
These variables are passed to Chef inside the JSON and we can refer to them with: deploy[:environment_variables]
To let this recipe works both with deploy[:environment_variables] and variables passed with a custom JSON (like this documentation says) I changed a bit the write_config.rb file.
recipes/write_config.rb now is:
node[:deploy].each do |application, deploy|
environment_variables = deploy[:custom_env].to_h.merge(deploy[:environment_variables].to_h)
custom_env_template do
application application
deploy deploy
env environment_variables
end
end
Out of curiosity, why do you want to combine the built-in environment support with this cookbook? If the built-in support works for your needs, maybe you don't need this? I built this cookbook before that support was available. When I tried to switch my apps to use the built-in version, I ran into problems (such as with the number of supported environment variables being limited).
Also, your code example changes the prescribed JSON location for custom environment values (from custom_env.app_name to deploy.app_name.custom_env). This is a fine location, but represents a breaking change with how the cookbook worked in the past. It's fine for you to use that, but I wouldn't want to merge that into this repo. Feel free to make a pull request in any case if you'd like more detailed feedback.
Because without this cookbook the environment variables declared in AWS console built-in support are not available for my rails app!
The built-in support just allow to provide variables to Chef recipes, but then we need to handle this variables in someway to let's our app to use it.
You said that:
When I tried to switch my apps to use the built-in version, I ran into problems (such as with the number of supported environment variables being limited).
That was the past. Now as the official documentation says: There is no specific limit on the number of environment variables.
About the custom JSON, is just a way as I prefer to access to it. Never mind about that change.
Now in AWS is possible to define environment variables directly inside the AWS OpsWorks console.
To do that we have to go to "Apps" section and click on the actions "edit" related to our app.
Then, under "Environment Variables" we can declare all env variables we need.
These variables are passed to Chef inside the JSON and we can refer to them with: deploy[:environment_variables]
To let this recipe works both with deploy[:environment_variables] and variables passed with a custom JSON (like this documentation says) I changed a bit the write_config.rb file.
recipes/write_config.rb now is:
Where my custom JSON is:
@joeyAghion what do you think about this change?
The text was updated successfully, but these errors were encountered: