awsecrets 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -0
- data/README.md +11 -1
- data/lib/awsecrets/version.rb +1 -1
- data/lib/awsecrets.rb +63 -20
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8c263296a3ce4e2f9fb5a69662b5ddc3a3b741f
|
4
|
+
data.tar.gz: 75c2f9275a2c2cf08b4ba70a91515edef7d74912
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9cbebe3ea145b2835b20cdda2a4326f602e1b8dee814538fbecf9d5bbd5b2145b384ee0e177a2f04aa278e47224a9bdc63e31891081c086dc72c20370c8655d
|
7
|
+
data.tar.gz: e68e024855b51cd54d33dc94660ab148019695bb724cd4dd797e96b2cae6c1c58630dad036158ee54f8aaa06dba52ba59447ad57d64c73b9cde239adf4199a47
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.1
|
3
|
+
|
1
4
|
Lint/Eval:
|
2
5
|
Enabled: false
|
3
6
|
|
@@ -25,6 +28,12 @@ Metrics/MethodLength:
|
|
25
28
|
Metrics/PerceivedComplexity:
|
26
29
|
Max: 15
|
27
30
|
|
31
|
+
Performance/StringReplacement:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Style/Alias:
|
35
|
+
Enabled: false
|
36
|
+
|
28
37
|
Style/BarePercentLiterals:
|
29
38
|
Enabled: false
|
30
39
|
|
@@ -34,6 +43,12 @@ Style/ClassAndModuleChildren:
|
|
34
43
|
Style/Documentation:
|
35
44
|
Enabled: false
|
36
45
|
|
46
|
+
Style/MutableConstant:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Style/MultilineOperationIndentation:
|
50
|
+
Enabled: false
|
51
|
+
|
37
52
|
Style/StabbyLambdaParentheses:
|
38
53
|
Enabled: false
|
39
54
|
|
data/README.md
CHANGED
@@ -1,7 +1,17 @@
|
|
1
|
-
# awsecrets
|
1
|
+
# awsecrets [![Gem](https://img.shields.io/gem/v/awsecrets.svg)](https://rubygems.org/gems/awsecrets) [![Travis](https://img.shields.io/travis/k1LoW/awsecrets.svg)](https://travis-ci.org/k1LoW/awsecrets)
|
2
2
|
|
3
3
|
AWS credentials loader
|
4
4
|
|
5
|
+
## awsecrets config precedence
|
6
|
+
|
7
|
+
1. Command Line Options
|
8
|
+
2. Environment Variables
|
9
|
+
3. YAML file (secrets.yml)
|
10
|
+
4. The AWS credentials file
|
11
|
+
5. The CLI configuration file
|
12
|
+
|
13
|
+
(See http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#config-settings-and-precedence)
|
14
|
+
|
5
15
|
## Installation
|
6
16
|
|
7
17
|
Add this line to your application's Gemfile:
|
data/lib/awsecrets/version.rb
CHANGED
data/lib/awsecrets.rb
CHANGED
@@ -4,26 +4,69 @@ require 'aws_config'
|
|
4
4
|
require 'yaml'
|
5
5
|
|
6
6
|
module Awsecrets
|
7
|
-
def self.load(profile: nil, secrets_path: 'secrets.yml')
|
8
|
-
profile =
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
7
|
+
def self.load(profile: nil, region: nil, secrets_path: 'secrets.yml')
|
8
|
+
@profile = profile
|
9
|
+
@secrets_path = secrets_path
|
10
|
+
@region = region
|
11
|
+
@credentials = nil
|
12
|
+
|
13
|
+
# 1. Command Line Options
|
14
|
+
load_command
|
15
|
+
# 2. Environment Variables
|
16
|
+
load_env
|
17
|
+
# 3. YAML file (secrets.yml)
|
18
|
+
load_yaml
|
19
|
+
# 4. The AWS credentials file
|
20
|
+
load_creds
|
21
|
+
# 5. The CLI configuration file
|
22
|
+
load_config
|
23
|
+
|
24
|
+
Aws.config[:region] = @region
|
25
|
+
Aws.config[:credentials] = @credentials
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.load_command
|
29
|
+
return unless @profile
|
30
|
+
aws_config = AWSConfig.profiles[@profile]
|
31
|
+
@region = aws_config.config_hash[:region] if aws_config
|
32
|
+
@credentials = Aws::SharedCredentials.new(profile_name: @profile)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.load_env
|
36
|
+
@region = ENV['AWS_REGION'] unless @region
|
37
|
+
@region = ENV['AWS_DEFAULT_REGION'] unless @region
|
38
|
+
if @credentials.nil? && ENV['AWS_PROFILE']
|
39
|
+
@credentials = Aws::SharedCredentials.new(profile_name: ENV['AWS_PROFILE'])
|
40
|
+
@profile = ENV['AWS_PROFILE']
|
27
41
|
end
|
42
|
+
if @credentials.nil? && ENV['AWS_ACCESS_KEY_ID'] && ENV['AWS_SECRET_ACCESS_KEY']
|
43
|
+
@credentials = @credentials = Aws::Credentials.new(
|
44
|
+
ENV['AWS_ACCESS_KEY_ID'],
|
45
|
+
ENV['AWS_SECRET_ACCESS_KEY'])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.load_yaml
|
50
|
+
creds = YAML.load_file(@secrets_path) if File.exist?(@secrets_path)
|
51
|
+
if @region.nil? && creds
|
52
|
+
@region = creds['region'] if creds.include?('region')
|
53
|
+
end
|
54
|
+
if @credentials.nil? && creds && creds.include?('aws_access_key_id') && creds.include?('aws_secret_access_key')
|
55
|
+
@credentials = Aws::Credentials.new(
|
56
|
+
creds['aws_access_key_id'],
|
57
|
+
creds['aws_secret_access_key'])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.load_creds
|
62
|
+
return unless @credentials.nil?
|
63
|
+
@credentials = Aws::SharedCredentials.new(profile_name: nil)
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.load_config
|
67
|
+
return unless @region.nil?
|
68
|
+
aws_config = AWSConfig.profiles[@profile]
|
69
|
+
aws_config = AWSConfig.profiles['default'] unless aws_config
|
70
|
+
@region = aws_config.config_hash[:region] if aws_config
|
28
71
|
end
|
29
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awsecrets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
version: '0'
|
163
163
|
requirements: []
|
164
164
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.4.5.1
|
166
166
|
signing_key:
|
167
167
|
specification_version: 4
|
168
168
|
summary: AWS credentials loader
|