psenv 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +100 -0
- data/LICENSE.txt +21 -0
- data/README.md +78 -0
- data/Rakefile +24 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/psenv-rails.rb +20 -0
- data/lib/psenv.rb +23 -0
- data/lib/psenv/version.rb +3 -0
- data/psenv-rails.gemspec +27 -0
- data/psenv.gemspec +28 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 591d97b58e03c096568edec93a85a77de2146fa3
|
4
|
+
data.tar.gz: 6d1d3a96f477c5bc49e367a924bc1f30b78d4338
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a66dd9102879c4dc24b514d6699f3497bbf629d4126f5641540df7ab7abba43be6ee685e6b7abfe9cfad70b33a50204d87d4b2c69b25c0dc3b617778a2d657ae
|
7
|
+
data.tar.gz: f6f737d73f2e0ee158e06e6db28eeb7e72b0d8df04642d21fc6ccc5f155f3a47bacc6eb03a761ba6a4a04867a6800b54d51d1cc77cc9c04d7913da4a1298e228
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
psenv (0.0.1)
|
5
|
+
aws-sdk-ssm (~> 1)
|
6
|
+
psenv-rails (0.0.1)
|
7
|
+
psenv (= 0.0.1)
|
8
|
+
railties (>= 3.2, < 5.2)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actionpack (5.1.5)
|
14
|
+
actionview (= 5.1.5)
|
15
|
+
activesupport (= 5.1.5)
|
16
|
+
rack (~> 2.0)
|
17
|
+
rack-test (>= 0.6.3)
|
18
|
+
rails-dom-testing (~> 2.0)
|
19
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
20
|
+
actionview (5.1.5)
|
21
|
+
activesupport (= 5.1.5)
|
22
|
+
builder (~> 3.1)
|
23
|
+
erubi (~> 1.4)
|
24
|
+
rails-dom-testing (~> 2.0)
|
25
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
26
|
+
activesupport (5.1.5)
|
27
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
28
|
+
i18n (~> 0.7)
|
29
|
+
minitest (~> 5.1)
|
30
|
+
tzinfo (~> 1.1)
|
31
|
+
aws-partitions (1.71.0)
|
32
|
+
aws-sdk-core (3.17.1)
|
33
|
+
aws-partitions (~> 1.0)
|
34
|
+
aws-sigv4 (~> 1.0)
|
35
|
+
jmespath (~> 1.0)
|
36
|
+
aws-sdk-ssm (1.8.0)
|
37
|
+
aws-sdk-core (~> 3)
|
38
|
+
aws-sigv4 (~> 1.0)
|
39
|
+
aws-sigv4 (1.0.2)
|
40
|
+
builder (3.2.3)
|
41
|
+
concurrent-ruby (1.0.5)
|
42
|
+
crass (1.0.3)
|
43
|
+
diff-lcs (1.3)
|
44
|
+
erubi (1.7.1)
|
45
|
+
i18n (0.9.5)
|
46
|
+
concurrent-ruby (~> 1.0)
|
47
|
+
jmespath (1.3.1)
|
48
|
+
loofah (2.2.2)
|
49
|
+
crass (~> 1.0.2)
|
50
|
+
nokogiri (>= 1.5.9)
|
51
|
+
method_source (0.9.0)
|
52
|
+
mini_portile2 (2.3.0)
|
53
|
+
minitest (5.11.3)
|
54
|
+
nokogiri (1.8.2)
|
55
|
+
mini_portile2 (~> 2.3.0)
|
56
|
+
rack (2.0.4)
|
57
|
+
rack-test (0.8.3)
|
58
|
+
rack (>= 1.0, < 3)
|
59
|
+
rails-dom-testing (2.0.3)
|
60
|
+
activesupport (>= 4.2.0)
|
61
|
+
nokogiri (>= 1.6)
|
62
|
+
rails-html-sanitizer (1.0.4)
|
63
|
+
loofah (~> 2.2, >= 2.2.2)
|
64
|
+
railties (5.1.5)
|
65
|
+
actionpack (= 5.1.5)
|
66
|
+
activesupport (= 5.1.5)
|
67
|
+
method_source
|
68
|
+
rake (>= 0.8.7)
|
69
|
+
thor (>= 0.18.1, < 2.0)
|
70
|
+
rake (10.5.0)
|
71
|
+
rspec (3.7.0)
|
72
|
+
rspec-core (~> 3.7.0)
|
73
|
+
rspec-expectations (~> 3.7.0)
|
74
|
+
rspec-mocks (~> 3.7.0)
|
75
|
+
rspec-core (3.7.1)
|
76
|
+
rspec-support (~> 3.7.0)
|
77
|
+
rspec-expectations (3.7.0)
|
78
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
79
|
+
rspec-support (~> 3.7.0)
|
80
|
+
rspec-mocks (3.7.0)
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
+
rspec-support (~> 3.7.0)
|
83
|
+
rspec-support (3.7.1)
|
84
|
+
thor (0.20.0)
|
85
|
+
thread_safe (0.3.6)
|
86
|
+
tzinfo (1.2.5)
|
87
|
+
thread_safe (~> 0.1)
|
88
|
+
|
89
|
+
PLATFORMS
|
90
|
+
ruby
|
91
|
+
|
92
|
+
DEPENDENCIES
|
93
|
+
bundler (~> 1.16)
|
94
|
+
psenv!
|
95
|
+
psenv-rails!
|
96
|
+
rake (~> 10.0)
|
97
|
+
rspec (~> 3.0)
|
98
|
+
|
99
|
+
BUNDLED WITH
|
100
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Andrew Tomaka
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Psenv
|
2
|
+
|
3
|
+
**Work in progress**
|
4
|
+
|
5
|
+
Shim to load environment variables from [AWS Systems Manager Parameter Store](https://aws.amazon.com/systems-manager/features/#Parameter_Store) into ENV.
|
6
|
+
|
7
|
+
Psenv currently heavily borrows from [Dotenv](https://github.com/bkeepers/dotenv), mainly because I use it in roughly every project so it made since for the APIs to match.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
### Rails
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'psenv-rails'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Set the `PARAMETER_STORE_PATH` environment variable with the AWS Parameter
|
24
|
+
Store path that you wish to load.
|
25
|
+
|
26
|
+
### Plain Ruby
|
27
|
+
|
28
|
+
Add this line to your application's Gemfile:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
gem 'psenv'
|
32
|
+
```
|
33
|
+
|
34
|
+
And then execute:
|
35
|
+
|
36
|
+
$ bundle
|
37
|
+
|
38
|
+
Set the `PARAMETER_STORE_PATH` environment variable with the AWS Parameter
|
39
|
+
Store path that you wish to load.
|
40
|
+
|
41
|
+
Finally, trigger the loading:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require 'psenv'
|
45
|
+
Psenv.load
|
46
|
+
```
|
47
|
+
|
48
|
+
## Usage
|
49
|
+
|
50
|
+
* Create a variable in parameter store using the AWS console or the CLI
|
51
|
+
|
52
|
+
```
|
53
|
+
aws ssm put-parameter \
|
54
|
+
--name /psenv/test/API_KEY \
|
55
|
+
--value "api_key_value" \
|
56
|
+
--type String
|
57
|
+
```
|
58
|
+
|
59
|
+
* Ensure your application has at least the following IAM permissions
|
60
|
+
* `ssm:GetParametersByPath` on resource `arn:aws:ssm:::parameter/psenv/test/*`
|
61
|
+
* Set the `PARAMETER_STORE_PATH` environment variable to `/psenv/test/`
|
62
|
+
|
63
|
+
This example will set the `API_KEY` to `api_key_value` and make it available to
|
64
|
+
your application.
|
65
|
+
|
66
|
+
## Development
|
67
|
+
|
68
|
+
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.
|
69
|
+
|
70
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/atomaka/psenv.
|
75
|
+
|
76
|
+
## License
|
77
|
+
|
78
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "bundler/gem_helper"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
namespace "psenv" do
|
5
|
+
Bundler::GemHelper.install_tasks name: "psenv"
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace "psenv-rails" do
|
9
|
+
class ParameterStoreEnvRailsGemHelper < Bundler::GemHelper
|
10
|
+
def guard_already_tagged; end # noop
|
11
|
+
|
12
|
+
def tag_version; end # noop
|
13
|
+
end
|
14
|
+
|
15
|
+
ParameterStoreEnvRailsGemHelper.install_tasks name: "psenv-rails"
|
16
|
+
end
|
17
|
+
|
18
|
+
task build: ["psenv:build", "psenv-rails:build"]
|
19
|
+
task install: ["psenv:install", "psenv-rails:install"]
|
20
|
+
task release: ["psenv:release", "psenv-rails:release"]
|
21
|
+
|
22
|
+
RSpec::Core::RakeTask.new(:spec)
|
23
|
+
|
24
|
+
task :default => :spec
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "parameter_store_loader"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/psenv-rails.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "psenv"
|
2
|
+
|
3
|
+
if defined?(Rake.application)
|
4
|
+
is_running_specs = Rake.application.top_level_tasks.grep(/^spec(:|$)/).any?
|
5
|
+
Rails.env = ENV["RAILS_ENV"] ||= "test" if is_running_specs
|
6
|
+
end
|
7
|
+
|
8
|
+
module Psenv
|
9
|
+
class Railtie < Rails::Railtie
|
10
|
+
def load
|
11
|
+
Psenv.load
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.load
|
15
|
+
instance.load
|
16
|
+
end
|
17
|
+
|
18
|
+
config.before_configuration { load }
|
19
|
+
end
|
20
|
+
end
|
data/lib/psenv.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "psenv/version"
|
2
|
+
|
3
|
+
require "aws-sdk-ssm"
|
4
|
+
|
5
|
+
module Psenv
|
6
|
+
module_function
|
7
|
+
|
8
|
+
def load
|
9
|
+
if ENV["PARAMETER_STORE_PATH"] != nil
|
10
|
+
ssm = Aws::SSM::Client.new
|
11
|
+
|
12
|
+
ssm.
|
13
|
+
get_parameters_by_path(
|
14
|
+
path: ENV["PARAMETER_STORE_PATH"],
|
15
|
+
with_decryption: true,
|
16
|
+
).
|
17
|
+
parameters.
|
18
|
+
each do |param|
|
19
|
+
ENV.store(param.name.split("/").last, param.value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/psenv-rails.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "psenv/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "psenv-rails"
|
8
|
+
spec.version = Psenv::VERSION
|
9
|
+
spec.authors = ["Andrew Tomaka"]
|
10
|
+
spec.email = ["atomaka@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Load AWS SSM Parameter Store values into your Rails environment.}
|
13
|
+
spec.homepage = "https://github.com/atomaka/psenv"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files lib | grep rails`.
|
17
|
+
split($OUTPUT_RECORD_SEPARATOR).
|
18
|
+
reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end + ["README.md", "LICENSE.txt"]
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "psenv", Psenv::VERSION
|
26
|
+
spec.add_dependency "railties", ">= 3.2", "< 5.2"
|
27
|
+
end
|
data/psenv.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "psenv/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "psenv"
|
8
|
+
spec.version = Psenv::VERSION
|
9
|
+
spec.authors = ["Andrew Tomaka"]
|
10
|
+
spec.email = ["atomaka@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Load AWS SSM Parameter Store values into your environment.}
|
13
|
+
spec.homepage = "https://github.com/atomaka/psenv"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
|
27
|
+
spec.add_dependency "aws-sdk-ssm", "~> 1"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: psenv
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Tomaka
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aws-sdk-ssm
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- atomaka@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- lib/psenv-rails.rb
|
87
|
+
- lib/psenv.rb
|
88
|
+
- lib/psenv/version.rb
|
89
|
+
- psenv-rails.gemspec
|
90
|
+
- psenv.gemspec
|
91
|
+
homepage: https://github.com/atomaka/psenv
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.6.13
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Load AWS SSM Parameter Store values into your environment.
|
115
|
+
test_files: []
|