chambermaid 0.4.0 → 1.0.1

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
  SHA256:
3
- metadata.gz: 7205cca8ffd4e9f7b2e20eb02239fd42be4f9dcdbd7c85eafb2e74c000d39be6
4
- data.tar.gz: a1b394c7dd79578e738defb6657276aa6988185d432153f900dab3b2bfeda97d
3
+ metadata.gz: db11b6ed46ebe0bec94edbdfc616b67dcbfd22e280ee5d2ef04c870ff27ea44d
4
+ data.tar.gz: ab097d0efc95e0e51d1fce0e51b771591c408d683f230716199cc880a3f813ec
5
5
  SHA512:
6
- metadata.gz: 4ef58ed041bd944a89d06a72c4b4f71dfe7695ef86aa4c2a28edf6d32d6a8b46122c1bfe7b1f6461cf9199dfbe73cfcf9fadd7ee101b54f0e86be5d36cd76c9d
7
- data.tar.gz: 9cb1b2f1781b2903a9af7121e7720a8c2f875a28472f8d0ded8b455560262917f2fec5e0cb8584886257de8141fabc90ca7d244d86435004b9c1377a121d4ee2
6
+ metadata.gz: 35e8d6217d1e90d8e4c24ebea8df5549cf514b82f54e59eec5ae986a84677175d57c1d6074f3b8ec9fa43f6d20e43180f53cba80294b002959bcea6bba676dfe
7
+ data.tar.gz: 2dd4f31782acc1fbd3ecf314d8462040cf7b1edff7df76d6ee9df46d794ce42b6e0d1796056f80e38092c59a1ebe52aed50db7039f44643f1669e9906d3eaa9d
@@ -0,0 +1,16 @@
1
+ name: commitlint
2
+ on:
3
+ - pull_request
4
+
5
+ jobs:
6
+ lint:
7
+ runs-on: ubuntu-latest
8
+ env:
9
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ with:
13
+ fetch-depth: 0
14
+ - uses: wagoid/commitlint-github-action@v1
15
+ with:
16
+ failOnWarnings: true
@@ -0,0 +1,56 @@
1
+ name: release
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+
7
+ jobs:
8
+ create-release:
9
+ runs-on: ubuntu-latest
10
+ env:
11
+ GITHUB_TOKEN: ${{ secrets.GHUB_PAT }}
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ with:
15
+ fetch-depth: 0
16
+ - uses: ridedott/release-me-action@master
17
+ id: get-version-number
18
+ with:
19
+ dry-run: true
20
+ release-rules: |
21
+ [
22
+ { "type": "release", "scope": "major", "release": "major" },
23
+ { "type": "refactor", "release": "patch" }
24
+ ]
25
+ - uses: actions/setup-ruby@v1
26
+ with:
27
+ ruby-version: "2.6"
28
+ - run: gem install bundler -v 2.1.2
29
+ - name: Set version.rb and Gemfile.lock
30
+ run: |
31
+ printf "module Chambermaid\n VERSION = \"$NEW_VERSION\"\nend" > lib/chambermaid/version.rb
32
+ bundle install
33
+ env:
34
+ NEW_VERSION: ${{ steps.get-version-number.outputs.version }}
35
+ - run: bundle exec rake build
36
+ - uses: ridedott/release-me-action@master
37
+ with:
38
+ commit-assets: |
39
+ ./lib/chambermaid/version.rb
40
+ ./Gemfile.lock
41
+ release-assets: |
42
+ ./pkg/*.gem
43
+ release-rules: |
44
+ [
45
+ { "type": "release", "scope": "major", "release": "major" },
46
+ { "type": "refactor", "release": "patch" }
47
+ ]
48
+ - name: publish to rubygems
49
+ run: |
50
+ mkdir -p ~/.gem
51
+ printf -- "---\n:rubygems_api_key: $GEM_HOST_API_KEY" > ~/.gem/credentials
52
+ chmod 0600 ~/.gem/credentials
53
+ gem push pkg/chambermaid-$NEW_VERSION.gem
54
+ env:
55
+ GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
56
+ NEW_VERSION: ${{ steps.get-version-number.outputs.version }}
@@ -0,0 +1,51 @@
1
+ ## [1.0.1](https://github.com/mileszim/chambermaid/compare/v1.0.0...v1.0.1) (2020-08-03)
2
+
3
+ ### Code Refactoring
4
+
5
+ - load dependencies specific to each module ([f52aa00](https://github.com/mileszim/chambermaid/commit/f52aa00410f6abc63263403d6180b463eca4c0bf))
6
+
7
+ # [1.0.0](https://github.com/mileszim/chambermaid/compare/v0.5.5...v1.0.0) (2020-08-03)
8
+
9
+ ### Documentation
10
+
11
+ - **README:** update README with authentication instructions ([fd2a826](https://github.com/mileszim/chambermaid/commit/fd2a826066a7507ecb97b68a8fbbaad2146da764))
12
+
13
+ ### Other
14
+
15
+ - **major:** release version 1 ([eb2f11c](https://github.com/mileszim/chambermaid/commit/eb2f11cb7d963c27aba467643d46f52eddce2e7e))
16
+
17
+ ## [0.5.5](https://github.com/mileszim/chambermaid/compare/v0.5.4...v0.5.5) (2020-08-03)
18
+
19
+ ### Documentation
20
+
21
+ - add links to documentation and more info for rdoc ([3f7ec6d](https://github.com/mileszim/chambermaid/commit/3f7ec6ddb07478ceefef83403c1e5b9de447509a))
22
+
23
+ ## [0.5.4](https://github.com/mileszim/chambermaid/compare/v0.5.3...v0.5.4) (2020-08-03)
24
+
25
+ ### Bug Fixes
26
+
27
+ - **release:** chmod 0600 ~/.gem/credentials after generating ([ed85d5b](https://github.com/mileszim/chambermaid/commit/ed85d5b1d9b76762bcc50734c806a6e1cd224ad5))
28
+
29
+ ## [0.5.3](https://github.com/mileszim/chambermaid/compare/v0.5.2...v0.5.3) (2020-08-03)
30
+
31
+ ### Bug Fixes
32
+
33
+ - **release:** use bash end of args with printf ([fbc0ae2](https://github.com/mileszim/chambermaid/commit/fbc0ae28961c40f984e6685e5feb33799934f510))
34
+
35
+ ## [0.5.2](https://github.com/mileszim/chambermaid/compare/v0.5.1...v0.5.2) (2020-08-03)
36
+
37
+ ### Bug Fixes
38
+
39
+ - **release:** set rubygem api key into ~/.gem/credentials ([7faef58](https://github.com/mileszim/chambermaid/commit/7faef587631284c3bb89c22572b8bce9c31172d0))
40
+
41
+ ## [0.5.1](https://github.com/mileszim/chambermaid/compare/v0.5.0...v0.5.1) (2020-08-03)
42
+
43
+ ### Bug Fixes
44
+
45
+ - **release:** publish to rubygems on successful release ([e019c7d](https://github.com/mileszim/chambermaid/commit/e019c7df3f43c251a5542374cc9c869fc4b00d92))
46
+
47
+ # [0.5.0](https://github.com/mileszim/chambermaid/compare/v0.4.1...v0.5.0) (2020-08-03)
48
+
49
+ ### Features
50
+
51
+ - add commitlint and release workflow (#2) ([1159e69](https://github.com/mileszim/chambermaid/commit/1159e69e95701e4763fdbe08430d579c2a2a8440)), closes [#2](https://github.com/mileszim/chambermaid/issues/2)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chambermaid (0.4.0)
4
+ chambermaid (1.0.1)
5
5
  aws-sdk-ssm (~> 1.85)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -4,6 +4,8 @@ Companion RubyGem for [chamber](https://github.com/segmentio/chamber).
4
4
 
5
5
  Chambermaid injects AWS SSM params into your ENV. Plays nice with other ENV gems like dotenv.
6
6
 
7
+ - [RubyDocs](https://rubydoc.info/gems/chambermaid)
8
+
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
@@ -46,8 +48,10 @@ Chambermaid.configure do |config|
46
48
  config.add_namespace("/my/important/namespace", overload: true)
47
49
  end
48
50
 
49
- # Load after configuration
50
- Chambermaid.load!
51
+ # If this is standalone ruby (not a Rails environment),
52
+ # call `Chambermaid.load!` after the configuration block
53
+ #
54
+ # Chambermaid.load!
51
55
  ```
52
56
 
53
57
  **Reload SSM into ENV**
@@ -79,6 +83,62 @@ Chambermaid.log_level = :warn
79
83
 
80
84
  _Note: Chambermaid.logger is set to Rails.logger automatically if including inside a rails app_
81
85
 
86
+ ### AWS Authentication
87
+
88
+ Chambermaid expects your AWS credential configuration to live inside ENV on application load.
89
+
90
+ > **Note:** `AWS_DEFAULT_REGION` or `AWS_REGION` is **required**
91
+
92
+ You can use either:
93
+ * `AWS_ACCESS_KEY_ID`
94
+ * `AWS_SECRET_ACCESS_KEY`
95
+
96
+ or STS grants:
97
+ ```bash
98
+ $ aws-vault exec my-user -- bundle exec rails server
99
+ ```
100
+ > *See [aws-vault](https://github.com/99designs/aws-vault/blob/master/USAGE.md) docs for more info*
101
+
102
+ or a metadata endpoint grant:
103
+ * Available in attached Task or EC2 instance. *See [AWS Docs](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-metadata-endpoint.html) for more info.*
104
+ * Through aws-vault: `aws-vault exec -s my-user`
105
+
106
+ #### IAM Permissions Required
107
+
108
+ Since this is meant to work out of the box as a complement to [chamber cli](https://github.com/segmentio/chamber), it needs similar IAM permissions.
109
+
110
+ In this case, however, we can grant read-only to the namespace(s).
111
+ ```json
112
+ {
113
+ "Version": "2012-10-17",
114
+ "Statement": [
115
+ {
116
+ "Sid": "",
117
+ "Effect": "Allow",
118
+ "Action": "ssm:DescribeParameters",
119
+ "Resource": "*"
120
+ },
121
+ {
122
+ "Sid": "",
123
+ "Effect": "Allow",
124
+ "Action": [
125
+ "ssm:GetParametersByPath",
126
+ "ssm:GetParameters",
127
+ "ssm:GetParameter",
128
+ "kms:Decrypt"
129
+ ],
130
+ "Resource": [
131
+ "arn:aws:ssm:us-east-1:1234567890:parameter/my-chamber-service",
132
+ "arn:aws:kms:us-east-1:1234567890:key/258574a1-cfce-4530-9e3c-d4b07cd04115"
133
+ ]
134
+ }
135
+ ]
136
+ }
137
+ ```
138
+ > **Note:** `Resource` array MUST include the full ARN of the key id used for chamber cli
139
+ > *(Default alias is `parameter_store_key`)*
140
+
141
+
82
142
  ## Development
83
143
 
84
144
  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.
@@ -16,6 +16,8 @@ Gem::Specification.new do |spec|
16
16
  spec.metadata["homepage_uri"] = spec.homepage
17
17
  spec.metadata["source_code_uri"] = "https://github.com/mileszim/chambermaid"
18
18
  spec.metadata["changelog_uri"] = "https://github.com/mileszim/chambermaid/blob/master/CHANGELOG.md"
19
+ spec.metadata["documentation_uri"] = "https://rubydoc.info/gems/chambermaid"
20
+ spec.metadata["bug_tracker_uri"] = "https://github.com/mileszim/chambermaid/issues"
19
21
 
20
22
  # Specify which files should be added to the gem when it is released.
21
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -1,8 +1,5 @@
1
1
  require "logger"
2
-
3
- require "chambermaid/environment"
4
2
  require "chambermaid/namespace"
5
- require "chambermaid/parameter_store"
6
3
 
7
4
  module Chambermaid
8
5
  module Base
@@ -1,4 +1,9 @@
1
1
  module Chambermaid
2
+ # Environment keeps a set of params available to load into ENV. It also
3
+ # maintains a copy of ENV at the time of its initialization, in order to
4
+ # restore it.
5
+ #
6
+ # @attr_reader [Hash] params
2
7
  class Environment < Hash
3
8
  attr_reader :params
4
9
 
@@ -35,16 +40,22 @@ module Chambermaid
35
40
  end
36
41
 
37
42
  # Inject into ENV without overwriting duplicates
43
+ #
44
+ # @return [Hash]
38
45
  def load!
39
46
  each { |k, v| ENV[k] ||= v }
40
47
  end
41
48
 
42
49
  # Inject into ENV and overwrite duplicates
50
+ #
51
+ # @return [Hash]
43
52
  def overload!
44
53
  each { |k, v| ENV[k] = v }
45
54
  end
46
55
 
47
56
  # Restore to original ENV
57
+ #
58
+ # @return [ENV]
48
59
  def unload!
49
60
  ENV.replace(@_original_env)
50
61
  end
@@ -1,4 +1,9 @@
1
+ require "chambermaid/environment"
2
+ require "chambermaid/parameter_store"
3
+
1
4
  module Chambermaid
5
+ # Namespaces each contain a ParameterStore and Environment instance,
6
+ # along with the overload flag
2
7
  class Namespace
3
8
  # @param [String] path
4
9
  # @param [Boolean] overload
@@ -10,23 +15,45 @@ module Chambermaid
10
15
  @env = Environment.new({})
11
16
  end
12
17
 
18
+ # Create a namespace and immediately fetch and inject params to ENV
19
+ #
20
+ # @see Chambermaid::Namespace.load!
21
+ #
22
+ # @param [String] path
23
+ # @param [Boolean] overload
24
+ #
25
+ # @return [Chambermaid::Namespace]
13
26
  def self.load!(path:, overload: false)
14
27
  namespace = new(path: path, overload: overload)
15
28
  namespace.load!
16
29
  namespace
17
30
  end
18
31
 
32
+ # Load ParameterStore and inject into ENV
33
+ #
34
+ # @see Chambermaid::ParameterStore#load!
35
+ # @see Chambermaid::Environment#load!
36
+ # @see Chambermaid::Environment#overload!
19
37
  def load!
20
38
  @store.load!
21
39
  load_env!
22
40
  end
23
41
 
42
+ # Unload params from ENV, reload ParameterStore, and inject into ENV
43
+ #
44
+ # @see Chambermaid::Environment#unload!
45
+ # @see Chambermaid::ParameterStore#reload!
46
+ # @see Chambermaid::Environment#load!
47
+ # @see Chambermaid::Environment#overload!
24
48
  def reload!
25
49
  @env.unload!
26
50
  @store.reload!
27
51
  load_env!
28
52
  end
29
53
 
54
+ # Unload params from ENV
55
+ #
56
+ # @see Chambermaid::Environment#unload!
30
57
  def unload!
31
58
  @env.unload!
32
59
  Chambermaid.logger.info("unloaded #{@env.size} params from ENV")
@@ -1,30 +1,52 @@
1
1
  require "aws-sdk-ssm"
2
2
 
3
3
  module Chambermaid
4
+ # ParameterStore instances fetch all parameters under a namespace/path
5
+ # from AWS SSM
6
+ #
7
+ # @note AWS authentication requires configuration via ENV (IAM credentials/STS)
4
8
  class ParameterStore
9
+ # @param [String] path
5
10
  def initialize(path:)
6
11
  @path = path
7
12
  end
8
13
 
14
+ # Fetch and decrypt all parameters selected by a namespace/path string
15
+ #
16
+ # @return [Boolean]
9
17
  def load!
10
18
  fetch_ssm_params!
11
19
  end
12
20
 
21
+ # Clear cached parameters and re-fetch parameters from AWS SSM
22
+ #
23
+ # @return [Boolean]
13
24
  def reload!
14
25
  clear_params!
15
26
  fetch_ssm_params!
16
27
  end
17
28
 
29
+ # Returns true if parameters have been fetched from AWS SSM
30
+ #
31
+ # @return [Boolean]
18
32
  def loaded?
19
33
  !@params_list.empty?
20
34
  end
21
35
 
36
+ # Create a ParameterStore and fetch from AWS SSM immediately
37
+ #
38
+ # @see Chambermaid::ParameterStore#load!
39
+ #
40
+ # @return [Chambermaid::ParameterStore]
22
41
  def self.load!(path:)
23
42
  store = new(path: path)
24
43
  store.load!
25
44
  store
26
45
  end
27
46
 
47
+ # ENV formatted Hash of parameters loaded from AWS SSM
48
+ #
49
+ # @return [Hash]
28
50
  def params
29
51
  @params ||= @param_list.map { |p|
30
52
  [p.name.split("/").last.upcase, p.value]
@@ -1,6 +1,6 @@
1
1
  module Chambermaid
2
2
  class Railtie < Rails::Railtie
3
- config.before_configuration do
3
+ config.after_initialize do
4
4
  Chambermaid.logger = Rails.logger
5
5
  Chambermaid.load!
6
6
  end
@@ -1,3 +1,3 @@
1
1
  module Chambermaid
2
- VERSION = "0.4.0"
3
- end
2
+ VERSION = "1.0.1"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chambermaid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Zimmerman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-02 00:00:00.000000000 Z
11
+ date: 2020-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-ssm
@@ -59,9 +59,12 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".github/workflows/commitlint.yml"
63
+ - ".github/workflows/release.yml"
62
64
  - ".gitignore"
63
65
  - ".rspec"
64
66
  - ".travis.yml"
67
+ - CHANGELOG.md
65
68
  - CODE_OF_CONDUCT.md
66
69
  - Gemfile
67
70
  - Gemfile.lock
@@ -85,6 +88,8 @@ metadata:
85
88
  homepage_uri: https://github.com/mileszim/chambermaid
86
89
  source_code_uri: https://github.com/mileszim/chambermaid
87
90
  changelog_uri: https://github.com/mileszim/chambermaid/blob/master/CHANGELOG.md
91
+ documentation_uri: https://rubydoc.info/gems/chambermaid
92
+ bug_tracker_uri: https://github.com/mileszim/chambermaid/issues
88
93
  post_install_message:
89
94
  rdoc_options: []
90
95
  require_paths: