aws-sesocio-secrets 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Aws::Sesocio::Secrets
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/aws/sesocio/secrets`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'aws-sesocio-secrets'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install aws-sesocio-secrets
22
+
23
+ ## Usage
24
+
25
+ Configuration steps:
26
+
27
+ First of all you need to create a config/initalizers/secrets.rb file with the following lines
28
+
29
+
30
+ ```ruby
31
+ Aws::Sesocio::Secrets.setup do |config|
32
+ config.key = <Your AWS_ACCESS_KEY_ID>
33
+ config.secret = <Your AWS_SECRET_ACCESS_KEY>
34
+ config.environment = <staging | development | production | test>
35
+ config.repo_name = < core | coupons | assitance ...>
36
+ end
37
+ ```
38
+
39
+ After that, you need to put the next line in application.rb
40
+
41
+
42
+ ```ruby
43
+ Aws::Sesocio::Secret.populate_env
44
+ ```
45
+
46
+ And that's all!
47
+
48
+ ## Development
49
+
50
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
51
+
52
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
53
+
54
+ ## Contributing
55
+
56
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/aws-sesocio-secrets.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ #require "lib/aws/sesocio/secrets/version"
4
+ require_relative "lib/aws/sesocio/secrets"
5
+ require_relative "lib/aws/sesocio/version"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "aws-sesocio-secrets"
8
+ spec.version = Aws::Sesocio::VERSION
9
+ spec.authors = ["Facundo Díaz Martínez"]
10
+ spec.email = ["facundo.martinez@sesocio.com"]
11
+
12
+ spec.summary = "Sesocio internal gem to manage secrets and params"
13
+ spec.description = "Makea aws integration cross sesocio apis and services"
14
+ spec.homepage = "https://github.com/it_sesocio/aws-sesocio-secrets"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
16
+
17
+ #spec.metadata["allowed_push_host"] = "https://rubygems.com"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ #spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
21
+ #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ spec.add_dependency "aws-sdk"
34
+
35
+ # For more information and examples about making a new gem, checkout our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "aws/sesocio/secrets"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ #require "version"
4
+ require 'aws-sdk'
5
+ require 'base64'
6
+ require 'json'
7
+
8
+ module Aws
9
+ module Sesocio
10
+ module Secrets
11
+
12
+ class << self
13
+ attr_accessor :key, :secret, :environment, :repo_name
14
+ end
15
+
16
+ def self.setup(&block)
17
+ yield self
18
+ end
19
+
20
+ def self.get_parameters
21
+ response = JSON.parse(`aws ssm get-parameters --names '#{environment}-#{repo_name}'`)
22
+ response["Parameters"].each do |parameter|
23
+ JSON.parse(parameter["Value"]).each do |key, value|
24
+ ENV[key] = value
25
+ end
26
+ end
27
+ rescue
28
+ "Permission problem: che the configuration before continue."
29
+ end
30
+
31
+ def self.get_secrets
32
+ secret_name = "#{self.environment}-#{self.repo_name}-secret"
33
+ region_name = "us-east-1"
34
+ client = Aws::SecretsManager::Client.new(region: region_name)
35
+ begin
36
+ get_secret_value_response = client.get_secret_value(secret_id: secret_name)
37
+ rescue Aws::SecretsManager::Errors::DecryptionFailure => e
38
+ raise
39
+ rescue Aws::SecretsManager::Errors::InternalServiceError => e
40
+ raise
41
+ rescue Aws::SecretsManager::Errors::InvalidParameterException => e
42
+ raise
43
+ rescue Aws::SecretsManager::Errors::InvalidRequestException => e
44
+ raise
45
+ rescue Aws::SecretsManager::Errors::ResourceNotFoundException => e
46
+ raise
47
+ else
48
+ if get_secret_value_response.secret_string
49
+ JSON.parse(get_secret_value_response.secret_string).each do |key, value|
50
+ ENV[key.to_s] = value
51
+ end
52
+ else
53
+ ENV.merge!(Base64.decode64(get_secret_value_response.secret_binary))
54
+ end
55
+ end
56
+
57
+ end
58
+
59
+ def self.populate_env
60
+ get_parameters
61
+ get_secrets
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module Sesocio
5
+ VERSION = "0.1.13"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aws-sesocio-secrets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.13
5
+ platform: ruby
6
+ authors:
7
+ - Facundo Díaz Martínez
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-08-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Makea aws integration cross sesocio apis and services
28
+ email:
29
+ - facundo.martinez@sesocio.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - README.md
39
+ - Rakefile
40
+ - aws-sesocio-secrets.gemspec
41
+ - bin/console
42
+ - bin/setup
43
+ - lib/aws/sesocio/secrets.rb
44
+ - lib/aws/sesocio/version.rb
45
+ homepage: https://github.com/it_sesocio/aws-sesocio-secrets
46
+ licenses: []
47
+ metadata:
48
+ homepage_uri: https://github.com/it_sesocio/aws-sesocio-secrets
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 2.4.0
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubygems_version: 3.0.9
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: Sesocio internal gem to manage secrets and params
68
+ test_files: []