ssm_env 0.1.8 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 97104554b9b5e31d042dd09931660e71ee90e763
4
- data.tar.gz: cbfe8f4766626b0111a42e2bf9b352bd70448ff1
2
+ SHA256:
3
+ metadata.gz: b34d28c279bb7029318ab60da22e40d69486fbeda7243e3453f6d8be38b88f32
4
+ data.tar.gz: 1b801f4ba5451052f7023ec642846a359d3bf2803edd67410ec9f3a0e7c5b23d
5
5
  SHA512:
6
- metadata.gz: ed83eadf1d87c037a364b742897283c1bec87950df566d2bedfad85bfc9041e1090ef2b52ae28720278d7dc29d9db9d0d7b3e872f2ebcdb0c193834b3ddfcf74
7
- data.tar.gz: 3e8c10fae27d5e9f328c423201c283dde8a26315310a3b093929350e55b7bdc485f4c5caeb549538984a9f6a86ccc70348028c84749661f1e520521a66c9df91
6
+ metadata.gz: 28e1be859f9ad6491926c026bca12520e7b61e14b3ac07be4360ac9b1ce32d1a5794a8a9dfa8a7aa70e2c59be83e43e41df5f2b4681f6244ee69daef3980ccfe
7
+ data.tar.gz: 5416103bbe2e1fcc388fac3a685bfd9445992871400696860e09f2b3c5be4bf2ec30322c441da5c31fc05bda9d81ffa96ebe2506887d63b871be172be19527b5
data/MIT-LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2018-2019 Everlance
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- #### Use this from the command line like
25
+ #### Use this from the command line like
26
26
 
27
27
  **Output Values**
28
28
  ```
@@ -42,15 +42,56 @@ ssm_env save -p .env -i "BRANCH_KEY,VACUUM_RATE"
42
42
  ssm_env save -p .env -i ssm_param_names.yml
43
43
  ```
44
44
 
45
- #### Use this in ruby like
45
+ #### Use this in ruby like
46
46
  ```
47
47
  ssm_env = SsmEnv.new.run(params_list: [BRANCH_KEY, VACUUM_LIMIT])
48
48
  # Update the environment
49
- ssm_env.to_env
49
+ ssm_env.to_env
50
50
  # Store in a file
51
51
  ssm_env.to_file('/tmp/my_vars.env')
52
52
  ```
53
53
 
54
+ #### Using this with Rails (Production)
55
+ ```
56
+ # Fetch parameters from AWS SSM
57
+ param_names = [
58
+ "STRIPE_API_KEY",
59
+ "OTHER_SECRET_KEY",
60
+ ]
61
+
62
+ # NOTE: You don't need to provide AWS credentials. You only need to give your EC2 server an Instance Role that allows SSM read access.
63
+ ssm_params = SsmEnv.fetch(params_list: param_names)
64
+
65
+ # Make parameters ENV variables
66
+ SsmEnv.to_env(ssm_params: ssm_params)
67
+
68
+ # Use the parameters through ENV variables in your Rails app
69
+ ENV['STRIPE_API_KEY']
70
+ ```
71
+
72
+ #### Using this with Rails (Local Development)
73
+ ```
74
+ # Fetch parameters from AWS SSM
75
+ param_names = [
76
+ "STRIPE_API_KEY",
77
+ "OTHER_SECRET_KEY",
78
+ ]
79
+
80
+ # NOTE: you can provide access_key_id and secret_access_key for local development (you can use a gem such as dotenv to have these credentials in a .env file that is not committed to source code)
81
+ # You could also omit access_key_id and secret_access_key, but make sure they are exported in your ~/.profile as ENV variables
82
+ ssm_params = SsmEnv.fetch(
83
+ params_list: param_names,
84
+ access_key_id: ENV['LOCAL_DEV_AWS_ACCESS_KEY_ID'],
85
+ secret_access_key: ENV['LOCAL_DEV_AWS_SECRET_ACCESS_KEY'])
86
+
87
+ # Make parameters ENV variables
88
+ SsmEnv.to_env(ssm_params: ssm_params)
89
+
90
+ # Use the parameters through ENV variables in your Rails app
91
+ ENV['STRIPE_API_KEY']
92
+
93
+ ```
94
+
54
95
  ## Development
55
96
 
56
97
  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.
@@ -60,4 +101,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
60
101
  ## Contributing
61
102
 
62
103
  Bug reports and pull requests are welcome on GitHub at https://github.com/Everlance/ssm_env.
63
-
@@ -1,3 +1,3 @@
1
1
  module SsmEnv
2
- VERSION = "0.1.8"
2
+ VERSION = "0.3"
3
3
  end
data/lib/ssm_env.rb CHANGED
@@ -5,8 +5,8 @@ require "ssm_env/fetcher"
5
5
  require "ssm_env/client"
6
6
 
7
7
  module SsmEnv
8
- def self.fetch(params_list: )
9
- @fetcher ||= SsmEnv::Fetcher.new(client: SsmEnv.client)
8
+ def self.fetch(params_list: , access_key_id: nil, secret_access_key: nil)
9
+ @fetcher ||= SsmEnv::Fetcher.new(client: SsmEnv.client(access_key_id, secret_access_key))
10
10
  @ssm_params = @fetcher.fetch(params: params_list)
11
11
  end
12
12
  def self.to_env(ssm_params: )
@@ -17,10 +17,10 @@ module SsmEnv
17
17
  ssm_params.each { |name, attribs| f << "#{name}=#{attribs[:value]}\n"}
18
18
  end
19
19
  end
20
- def self.client
20
+ def self.client(access_key_id, secret_access_key)
21
21
  @client = Client.get_client(region: SsmEnv.config.region,
22
- access_key_id: SsmEnv.config.access_key_id,
23
- secret_access_key: SsmEnv.config.secret_access_key)
22
+ access_key_id: access_key_id || SsmEnv.config.access_key_id,
23
+ secret_access_key: secret_access_key || SsmEnv.config.secret_access_key)
24
24
  end
25
25
  def self.config
26
26
  @config ||= OpenStruct.new(
data/ssm_env.gemspec CHANGED
@@ -8,6 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = SsmEnv::VERSION
9
9
  spec.authors = ["Rob Lane"]
10
10
  spec.email = ["rob@everlance.com"]
11
+ spec.license = 'MIT'
11
12
 
12
13
  spec.summary = "Synchronize your AWS SSM parameters to your environment"
13
14
 
@@ -16,8 +17,8 @@ Gem::Specification.new do |spec|
16
17
  spec.executables << 'ssm_env'
17
18
  spec.require_paths = ["lib"]
18
19
 
19
- spec.add_runtime_dependency "aws-sdk", "~> 2.0"
20
- spec.add_runtime_dependency "thor", "0.19.1"
20
+ spec.add_runtime_dependency "aws-sdk", "~> 3.0"
21
+ spec.add_runtime_dependency "thor", "~> 1.1"
21
22
 
22
23
  spec.add_development_dependency "bundler", "~> 1.11"
23
24
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssm_env
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Lane
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-01 00:00:00.000000000 Z
11
+ date: 2021-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.19.1
33
+ version: '1.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.19.1
40
+ version: '1.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
- description:
83
+ description:
84
84
  email:
85
85
  - rob@everlance.com
86
86
  executables:
@@ -92,6 +92,7 @@ files:
92
92
  - ".rspec"
93
93
  - ".travis.yml"
94
94
  - Gemfile
95
+ - MIT-LICENSE
95
96
  - README.md
96
97
  - Rakefile
97
98
  - bin/console
@@ -102,10 +103,11 @@ files:
102
103
  - lib/ssm_env/fetcher.rb
103
104
  - lib/ssm_env/version.rb
104
105
  - ssm_env.gemspec
105
- homepage:
106
- licenses: []
106
+ homepage:
107
+ licenses:
108
+ - MIT
107
109
  metadata: {}
108
- post_install_message:
110
+ post_install_message:
109
111
  rdoc_options: []
110
112
  require_paths:
111
113
  - lib
@@ -120,9 +122,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
122
  - !ruby/object:Gem::Version
121
123
  version: '0'
122
124
  requirements: []
123
- rubyforge_project:
124
- rubygems_version: 2.6.14
125
- signing_key:
125
+ rubygems_version: 3.0.9
126
+ signing_key:
126
127
  specification_version: 4
127
128
  summary: Synchronize your AWS SSM parameters to your environment
128
129
  test_files: []