psenv-rails 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/LICENSE.txt +21 -0
- data/README.md +78 -0
- data/lib/psenv-rails.rb +20 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5bc6ce90c99ba5be1aeed61612e8fe108d848262
|
4
|
+
data.tar.gz: bbe2b16b29cc2c1ca2c7f66f888df876b6f37338
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2c50d187c2736fbdc9390951400b56ff1192003570b14920acfa7c0a06a26d2d7288bc2b959c66c6c13874d079e7af1dc11bac5b0592b539e31d832cd3a955da
|
7
|
+
data.tar.gz: d4003a6d17862e05a8b6737060f5f75d4aa681549beb6a75de88174772a9778e58ed7546e6816b5d88837b2cff80bdfc12c828f6d156f392ac60153e4669e35e
|
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/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
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: psenv-rails
|
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: psenv
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: railties
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.2'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '5.2'
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.2'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '5.2'
|
47
|
+
description:
|
48
|
+
email:
|
49
|
+
- atomaka@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- LICENSE.txt
|
55
|
+
- README.md
|
56
|
+
- lib/psenv-rails.rb
|
57
|
+
homepage: https://github.com/atomaka/psenv
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.6.13
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Load AWS SSM Parameter Store values into your Rails environment.
|
81
|
+
test_files: []
|