awsprofiles 0.0.1
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.
- checksums.yaml +7 -0
- data/lib/awsprofiles.rb +66 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5557f75c7f94191dbfe72954fc291067dfb018d8
|
4
|
+
data.tar.gz: d4ea70c72f03b04a212a737a275692eef0fdd8e3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 801895747d71a65d105ec7e758ae963282695b006a15fdc16301c48c01d254ea3f105c7b54c5101a0aa4c8db4c9cde34f5921b51a8d1544a247efa52177ba295
|
7
|
+
data.tar.gz: 605d9f2fc8b6eed5b052b269ac46a9f93d35f462473d8cfd5b3a735e430254a73228c6bcaed56c40ff34953fdaf7e1d4d42073164a5040a87899534bd6fa7386
|
data/lib/awsprofiles.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require 'inifile'
|
3
|
+
|
4
|
+
show_details = ARGV.include? '-d'
|
5
|
+
filter = ARGV.select { |a| not a.start_with?('-') }
|
6
|
+
filter = '.*' if filter.empty?
|
7
|
+
ini = IniFile.load('/Users/igor/.aws/config')
|
8
|
+
output = []
|
9
|
+
|
10
|
+
def random_colors
|
11
|
+
skip_colors = [:black, :light_black, :blue, :light_blue, :default]
|
12
|
+
return String.colors.shuffle.select { |c| not skip_colors.include? c}
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_account(arn)
|
16
|
+
return arn.scan(/arn:aws:.*:(.*):.*/).last.first
|
17
|
+
end
|
18
|
+
|
19
|
+
def color_params(ini)
|
20
|
+
colors = random_colors
|
21
|
+
src = { }
|
22
|
+
|
23
|
+
ini.each do |s,k,v|
|
24
|
+
case k
|
25
|
+
when 'source_profile' then src[v] = v.colorize(colors[src.length])
|
26
|
+
when 'role_arn' then
|
27
|
+
acct = get_account(v)
|
28
|
+
src[acct] = acct.colorize(colors[src.length % colors.length])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
return src
|
32
|
+
end
|
33
|
+
|
34
|
+
def color_profiles(ini)
|
35
|
+
colors = random_colors
|
36
|
+
tar = { }
|
37
|
+
|
38
|
+
ini.each_section do |s|
|
39
|
+
prof = s.gsub(/^profile /, '')
|
40
|
+
tar[prof] = prof.colorize(colors[tar.length % colors.length])
|
41
|
+
end
|
42
|
+
return tar
|
43
|
+
end
|
44
|
+
|
45
|
+
profiles = color_profiles(ini)
|
46
|
+
params = color_params(ini)
|
47
|
+
|
48
|
+
sections = ini.sections.select { |s| s =~ /#{filter}/ }
|
49
|
+
sections.each do |s|
|
50
|
+
prof = s.gsub(/^profile /, '')
|
51
|
+
output << "Profile #{profiles[prof]}"
|
52
|
+
|
53
|
+
if show_details
|
54
|
+
if ini[s].has_key?('source_profile')
|
55
|
+
p = ini[s]['source_profile']
|
56
|
+
output << " Source Profile: #{params[p]}"
|
57
|
+
end
|
58
|
+
|
59
|
+
if ini[s].has_key?('role_arn')
|
60
|
+
p = ini[s]['role_arn']
|
61
|
+
output << " Account: #{params[get_account(p)]}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
output.each { |s| puts s }
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: awsprofiles
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Igor Gentil
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: inifile
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: clamp
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.1'
|
55
|
+
description: A simple script to list and search your AWS profiles configured at ~/.aws/
|
56
|
+
email: igor@devops.cool
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- lib/awsprofiles.rb
|
62
|
+
homepage: https://github.com/igorlg/gem-awsprofiles
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.6.12
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: List your AWS CLI Profiles
|
86
|
+
test_files: []
|