aws-secrets-manager 1.0.9 → 1.1.9

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: 90a8352b08a303335d95acfd19dcb9c0af1928bdf09304b5eea2f86018a4cdfc
4
+ data.tar.gz: 19321b36156444b7fad96727cce32c502f52d79a6cc1ec23207d65d864ed0c18
5
5
  SHA512:
6
- metadata.gz: 68cf52b8b3850b828cbcee77dceaa0e48b3186d2a48e611ea5addd968a6ff42d647636b4d1bad00babc68eba6f0f55899d615bebd8ed6d8b0dec47bc3f42cc01
7
- data.tar.gz: 58d0434be54edee0335669208650f6e2500d86726f1f22b515a65d0399c2e4a58742c9c0f6fad4e6b372842718cfbfd81adf48080631d5b4cd7c69221d36f57f
6
+ metadata.gz: 02ac6598112f119d3971960cd46fceec0d539697074675be469480defb9888ca1c595022c5dbd3808025399edd5f835cf5d0e97afef42b015e9c3bf68319007e
7
+ data.tar.gz: cc2cc2da359f59f3903ed928d45e1e9b0c724371e737a840a5d136308e892586958ebba56b3bc1137fdf59313594f5302c10c08784aa48cbb1472c436d6cf27e
data/README.md CHANGED
@@ -16,28 +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
+
30
+ require 'aws_secrets_manager'
31
+
32
+ AwsSecretsManager.configure do |config|
33
+ config.aws_region = ENV.fetch('AWS_REGION', 'eu-west-1')
34
+ end
35
+
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
+ ]
55
+ )
56
+ ```
57
+
58
+ In complex environments where applications require the use of multiple secrets, this gem 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
+
24
100
  require 'aws_secrets_manager'
25
101
 
26
102
  AwsSecretsManager.configure do |config|
27
- config.aws_region = "AWS_REGION"
103
+ config.aws_region = ENV.fetch('AWS_REGION', 'eu-west-1')
28
104
  end
29
105
 
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
- }]
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
+ ]
39
117
  )
40
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
+ ```
41
130
 
42
131
  ## Development
43
132
 
@@ -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.9"
5
5
  end
@@ -13,6 +13,4 @@ module AwsSecretsManager
13
13
  include Config
14
14
  extend Client
15
15
  extend GetSecretValue
16
-
17
- class Error < StandardError; end
18
16
  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.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksandar Popovic