aws-secrets-manager 1.0.9 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78068c78c3948f4cbfc3ceff0670c7ca3800a3bda56f5deb09994156778084b7
4
- data.tar.gz: '09542c519acae56d1a307475a1d6cd490b171be0682986c2cca146bd2a15451b'
3
+ metadata.gz: f4f462d38763ca1dc9c3fc74bf10338dbfd5e4330d05d3a663f794ae774c5165
4
+ data.tar.gz: 3ea98fcbfb0849c80edd0040e33441bea1c7f749aa090ce665b48e01ecb3a9da
5
5
  SHA512:
6
- metadata.gz: 68cf52b8b3850b828cbcee77dceaa0e48b3186d2a48e611ea5addd968a6ff42d647636b4d1bad00babc68eba6f0f55899d615bebd8ed6d8b0dec47bc3f42cc01
7
- data.tar.gz: 58d0434be54edee0335669208650f6e2500d86726f1f22b515a65d0399c2e4a58742c9c0f6fad4e6b372842718cfbfd81adf48080631d5b4cd7c69221d36f57f
6
+ metadata.gz: 8d6f0d797fb190051949f5f1679d6bda75e407d2692eef17459ab6993ba9c987c13819a6c8f635815476d1d8b8f996993c5b1035acd4f3a93aa29fd7c56e36b0
7
+ data.tar.gz: d51630a3de2f2c6a2e6c12620ad41e676e4dd88e89ac9b11dc8e617331b70bde7aba9ea385f4edf1d3024e110114c75cb2ef8b0f5553f943057f555a8066221d
data/README.md CHANGED
@@ -16,29 +16,117 @@ If bundler is not being used to manage dependencies, install the gem by executin
16
16
 
17
17
  ## Usage
18
18
 
19
- If you using Ruby on Rails then rails g aws-secrets-manager:install
19
+ If you using Ruby on Rails then
20
+
21
+ ```ruby
22
+ rails g aws_secrets_manager:install
23
+ ```
20
24
 
21
25
  or manualy add in Rack app config file:
22
26
 
23
27
  ```ruby
28
+ # frozen_string_literal: true
29
+
24
30
  require 'aws_secrets_manager'
25
31
 
26
32
  AwsSecretsManager.configure do |config|
27
- config.aws_region = "AWS_REGION"
33
+ config.aws_region = ENV.fetch('AWS_REGION', 'eu-west-1')
28
34
  end
29
35
 
30
- AwsSecretsManager.get_secret_value(secrets: [
31
- {
32
- name: "secret_name",
33
- type: "plaintext"
34
- },
35
- {
36
- name: "secret_name",
37
- type: "key_value"
38
- }]
36
+ AwsSecretsManager.get_secret_value(
37
+ secrets: [
38
+ {
39
+ name: ENV.fetch('AWS_SECRETS_PLAINTEXT_1', 'aws-secrets-plaintext-1-development'),
40
+ type: AwsSecretsManager::Config::PLAINTEXT
41
+ },
42
+ {
43
+ name: ENV.fetch('AWS_SECRETS_PLAINTEXT_2', 'aws-secrets-plaintext-2-development'),
44
+ type: AwsSecretsManager::Config::PLAINTEXT
45
+ },
46
+ {
47
+ name: ENV.fetch('AWS_SECRETS_KEY_VALUE_1', 'aws-secrets-key-value-1-development'),
48
+ type: AwsSecretsManager::Config::KEY_VALUE
49
+ },
50
+ {
51
+ name: ENV.fetch('AWS_SECRETS_KEY_VALUE_2', 'aws-secrets-key-value-2-development'),
52
+ type: AwsSecretsManager::Config::KEY_VALUE
53
+ },
54
+ ]
39
55
  )
40
56
  ```
41
57
 
58
+ In complex environments where applications require the use of multiple secrets, this game can be an interesting solution.
59
+
60
+ In AWS Secrets Manager if you have secret with name example-1 and with Secret value type => Key/value:
61
+
62
+ ```ruby
63
+ {
64
+ "ex_1":"1",
65
+ "ex_2":"2",
66
+ "ex_3":"3"
67
+ }
68
+ ```
69
+ in console when type ENV you will have 3 env variable like:
70
+
71
+ ```ruby
72
+ {
73
+ "EX_1"=>"1",
74
+ "EX_1"=>"1",
75
+ "EX_1"=>"1"
76
+ }
77
+ ```
78
+
79
+ In AWS Secrets Manager if you have secret with name example-2 and with Secret value type => Plaintext with value: 123456789
80
+
81
+ in console when type ENV you will have 1 env variable like:
82
+
83
+ ```ruby
84
+ {
85
+ "EXAMPLE_2"=>"123456789"
86
+ }
87
+ ```
88
+
89
+ IMPORTANT!!! When type => Plaintext
90
+
91
+ SECRET NAME IS ENV KEY AND Secret value IS ENV VALUE
92
+
93
+ Full example:
94
+
95
+ Config:
96
+
97
+ ```ruby
98
+ # frozen_string_literal: true
99
+
100
+ require 'aws_secrets_manager'
101
+
102
+ AwsSecretsManager.configure do |config|
103
+ config.aws_region = ENV.fetch('AWS_REGION', 'eu-west-1')
104
+ end
105
+
106
+ AwsSecretsManager.get_secret_value(
107
+ secrets: [
108
+ {
109
+ name: 'common-secrets',
110
+ type: AwsSecretsManager::Config::KEY_VALUE
111
+ },
112
+ {
113
+ name: 'fake-ssh-key',
114
+ type: AwsSecretsManager::Config::PLAINTEXT
115
+ },
116
+ ]
117
+ )
118
+ ```
119
+ Console output:
120
+
121
+ ```ruby
122
+ {
123
+ "DATABASE_DSN"=>"postgres://user:pass@server:5432/db",
124
+ "API_KEY"=>"5S6BX2c6vx879eZ",
125
+ "ORIGIN"=>"https://example.com"
126
+ "SMTP_HOST"=>"mailcluster.example.com",
127
+ "FAKE_SSH_KEY"=>"-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCxxx7OfuLEm3wm\njOVKL4+ibYBrrL3p8id2x4DZ3C+7C8ZkwsC6\n"
128
+ }
129
+
42
130
  ## Development
43
131
 
44
132
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AwsSecretsManager
4
- VERSION = "1.0.9"
4
+ VERSION = "1.1.7"
5
5
  end
@@ -14,18 +14,28 @@ if Gem.loaded_specs.key?("rails")
14
14
  require 'aws_secrets_manager'
15
15
 
16
16
  AwsSecretsManager.configure do |config|
17
- config.aws_region = "AWS_REGION"
17
+ config.aws_region = ENV.fetch("AWS_REGION", 'eu-west-1')
18
18
  end
19
19
 
20
- AwsSecretsManager.get_secret_value(secrets: [
21
- {
22
- name: "secret_name",
23
- type: "plaintext"
24
- },
25
- {
26
- name: "secret_name",
27
- type: "key_value"
28
- }]
20
+ AwsSecretsManager.get_secret_value(
21
+ secrets: [
22
+ {
23
+ name: ENV.fetch('AWS_SECRETS_PLAINTEXT_1', 'aws-secrets-plaintext-1-development'),
24
+ type: AwsSecretsManager::Config::PLAINTEXT
25
+ },
26
+ {
27
+ name: ENV.fetch('AWS_SECRETS_PLAINTEXT_2', 'aws-secrets-plaintext-2-development'),
28
+ type: AwsSecretsManager::Config::PLAINTEXT
29
+ },
30
+ {
31
+ name: ENV.fetch('AWS_SECRETS_KEY_VALUE_1', 'aws-secrets-key-value-1-development'),
32
+ type: AwsSecretsManager::Config::KEY_VALUE
33
+ },
34
+ {
35
+ name: ENV.fetch('AWS_SECRETS_KEY_VALUE_2', 'aws-secrets-key-value-2-development'),
36
+ type: AwsSecretsManager::Config::KEY_VALUE
37
+ },
38
+ ]
29
39
  )
30
40
  FILE
31
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-secrets-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksandar Popovic