Class: AwsSecretsManager::Generators::Install

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/aws_secrets_manager/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_helper_fileObject

rubocop:disable Layout/HeredocIndentation



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/aws_secrets_manager/install_generator.rb', line 10

def create_helper_file
  create_file("config/initializers/aws_secrets_manager.rb", <<-FILE)
# frozen_string_literal: true

require 'aws_secrets_manager'

AwsSecretsManager.configure do |config|
  config.aws_region = ENV.fetch("AWS_REGION", 'eu-west-1')
end

AwsSecretsManager.get_secret_value(
  secrets: [
    {
      name: ENV.fetch('AWS_SECRETS_PLAINTEXT_1', 'aws-secrets-plaintext-1-development'),
      type: AwsSecretsManager::Config::PLAINTEXT
    },
    {
      name: ENV.fetch('AWS_SECRETS_PLAINTEXT_2', 'aws-secrets-plaintext-2-development'),
      type: AwsSecretsManager::Config::PLAINTEXT
    },
    {
      name: ENV.fetch('AWS_SECRETS_KEY_VALUE_1', 'aws-secrets-key-value-1-development'),
      type: AwsSecretsManager::Config::KEY_VALUE
    },
    {
      name: ENV.fetch('AWS_SECRETS_KEY_VALUE_2', 'aws-secrets-key-value-2-development'),
      type: AwsSecretsManager::Config::KEY_VALUE
    },
  ]
)
  FILE
end