ssm_env 0.1.8 → 0.1.9

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
2
  SHA1:
3
- metadata.gz: 97104554b9b5e31d042dd09931660e71ee90e763
4
- data.tar.gz: cbfe8f4766626b0111a42e2bf9b352bd70448ff1
3
+ metadata.gz: d96048267a0d225a6f5d2c350cd578eba8b7e939
4
+ data.tar.gz: 3bb63f00651a0944b939edc84f45dde6ad65d79c
5
5
  SHA512:
6
- metadata.gz: ed83eadf1d87c037a364b742897283c1bec87950df566d2bedfad85bfc9041e1090ef2b52ae28720278d7dc29d9db9d0d7b3e872f2ebcdb0c193834b3ddfcf74
7
- data.tar.gz: 3e8c10fae27d5e9f328c423201c283dde8a26315310a3b093929350e55b7bdc485f4c5caeb549538984a9f6a86ccc70348028c84749661f1e520521a66c9df91
6
+ metadata.gz: e38e6e4bdd1d9ad8081000872d4ee4fd99f9d8ac5037389d3195cca6c44b5561b9b0f3fd721afa017c2ba0cab32147d41927e2b091b1fe6f78a493f8735559e8
7
+ data.tar.gz: cb3e3cfdfb913f95c3fb6ca6b95d6971f9cb5930a5b78046167b73374a1c0597502cc6366a9d5f2ad759f95bfd4b009496a21dcbdd696fafe53b9fa1b97d0406
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.1.9"
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(
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.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Lane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-01 00:00:00.000000000 Z
11
+ date: 2017-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk