docbrown/config/initializers/aws_sdk.rb
Molly Struve 1be8c72206
[deploy] Refactor:Remove ENVied Gem, Use dotenv Instead for Test and Development (#9621)
* Refactor:Remove ENVied Gem in Favor of Default application.yml

* Copy sample_application.yml for Travis

* Create .env_sample file, Warn of missing ENV variables, ignore .env file

* Use dotenv For ENV variables and create Rake Task to Populate

* Update docs to copy .env_sample file

* make application config a bit more resilient

* update more documentation and only initialize dotenv in dev and test

* Update doc code snippet types and refactor rake task and app config

* remove push defaults

* Make initializers more resilient, remove unused ENV from travis

* Exit new rake task if application.yml does not exist, include dotenv in docs
2020-08-12 11:01:38 -04:00

18 lines
808 B
Ruby

Rails.application.reloader.to_prepare do
AWS_LAMBDA = if Rails.env.production? && ApplicationConfig["AWS_SDK_KEY"].present?
Aws::Lambda::Client.new(
region: ApplicationConfig["AWS_DEFAULT_REGION"],
access_key_id: ApplicationConfig["AWS_SDK_KEY"],
secret_access_key: ApplicationConfig["AWS_SDK_SECRET"],
)
else
# Fake Aws::Lambda::Client
Class.new do
def invoke(*)
# rubocop:disable Performance/OpenStruct
OpenStruct.new(payload: [{ body: { message: 0 }.to_json }.to_json])
# rubocop:enable Performance/OpenStruct
end
end.new
end
end