aws_assume_role 0.0.3 → 0.1.0
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 +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +31 -11
- data/Gemfile +7 -13
- data/LICENSE.md +201 -19
- data/README.md +176 -145
- data/aws_assume_role.gemspec +35 -21
- data/bin/aws-assume-role +1 -83
- data/i18n/en.yml +106 -0
- data/lib/aws_assume_role.rb +2 -3
- data/lib/aws_assume_role/cli.rb +15 -0
- data/lib/aws_assume_role/cli/actions/abstract_action.rb +53 -0
- data/lib/aws_assume_role/cli/actions/configure_profile.rb +21 -0
- data/lib/aws_assume_role/cli/actions/configure_role_assumption.rb +19 -0
- data/lib/aws_assume_role/cli/actions/console.rb +68 -0
- data/lib/aws_assume_role/cli/actions/delete_profile.rb +20 -0
- data/lib/aws_assume_role/cli/actions/includes.rb +18 -0
- data/lib/aws_assume_role/cli/actions/list_profiles.rb +10 -0
- data/lib/aws_assume_role/cli/actions/migrate_profile.rb +18 -0
- data/lib/aws_assume_role/cli/actions/reset_environment.rb +48 -0
- data/lib/aws_assume_role/cli/actions/run.rb +34 -0
- data/lib/aws_assume_role/cli/actions/set_environment.rb +60 -0
- data/lib/aws_assume_role/cli/actions/test.rb +31 -0
- data/lib/aws_assume_role/cli/commands/configure.rb +29 -0
- data/lib/aws_assume_role/cli/commands/console.rb +17 -0
- data/lib/aws_assume_role/cli/commands/delete.rb +11 -0
- data/lib/aws_assume_role/cli/commands/environment.rb +32 -0
- data/lib/aws_assume_role/cli/commands/list.rb +10 -0
- data/lib/aws_assume_role/cli/commands/migrate.rb +11 -0
- data/lib/aws_assume_role/cli/commands/run.rb +17 -0
- data/lib/aws_assume_role/cli/commands/test.rb +18 -0
- data/lib/aws_assume_role/configuration.rb +19 -0
- data/lib/aws_assume_role/core_ext/aws-sdk/credential_provider_chain.rb +2 -0
- data/lib/aws_assume_role/core_ext/aws-sdk/includes.rb +7 -0
- data/lib/aws_assume_role/credentials/factories.rb +9 -0
- data/lib/aws_assume_role/credentials/factories/abstract_factory.rb +31 -0
- data/lib/aws_assume_role/credentials/factories/assume_role.rb +38 -0
- data/lib/aws_assume_role/credentials/factories/default_chain_provider.rb +101 -0
- data/lib/aws_assume_role/credentials/factories/environment.rb +24 -0
- data/lib/aws_assume_role/credentials/factories/includes.rb +17 -0
- data/lib/aws_assume_role/credentials/factories/instance_profile.rb +17 -0
- data/lib/aws_assume_role/credentials/factories/repository.rb +35 -0
- data/lib/aws_assume_role/credentials/factories/shared.rb +15 -0
- data/lib/aws_assume_role/credentials/factories/shared_keyring.rb +16 -0
- data/lib/aws_assume_role/credentials/factories/static.rb +16 -0
- data/lib/aws_assume_role/credentials/providers/assume_role_credentials.rb +58 -0
- data/lib/aws_assume_role/credentials/providers/includes.rb +9 -0
- data/lib/aws_assume_role/credentials/providers/mfa_session_credentials.rb +102 -0
- data/lib/aws_assume_role/credentials/providers/shared_keyring_credentials.rb +22 -0
- data/lib/aws_assume_role/includes.rb +30 -0
- data/lib/aws_assume_role/logging.rb +16 -28
- data/lib/aws_assume_role/profile_configuration.rb +71 -0
- data/lib/aws_assume_role/runner.rb +39 -0
- data/lib/aws_assume_role/store/includes.rb +16 -0
- data/lib/aws_assume_role/store/keyring.rb +59 -0
- data/lib/aws_assume_role/store/serialization.rb +18 -0
- data/lib/aws_assume_role/store/shared_config_with_keyring.rb +175 -0
- data/lib/aws_assume_role/types.rb +30 -0
- data/lib/aws_assume_role/ui.rb +55 -0
- data/lib/aws_assume_role/vendored/aws.rb +4 -0
- data/lib/aws_assume_role/vendored/aws/README.md +2 -0
- data/lib/aws_assume_role/vendored/aws/assume_role_credentials.rb +68 -0
- data/lib/aws_assume_role/vendored/aws/includes.rb +9 -0
- data/lib/aws_assume_role/vendored/aws/refreshing_credentials.rb +60 -0
- data/lib/aws_assume_role/vendored/aws/shared_config.rb +220 -0
- data/lib/aws_assume_role/version.rb +3 -0
- metadata +264 -20
- data/.rspec +0 -2
- data/Rakefile +0 -2
- data/bin/test.rb +0 -39
- data/lib/aws_assume_role/credentials.rb +0 -92
- data/lib/aws_assume_role/profile.rb +0 -203
- data/lib/aws_assume_role/profile/assume_role.rb +0 -127
- data/lib/aws_assume_role/profile/basic.rb +0 -152
- data/lib/aws_assume_role/profile/list.rb +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 044bfb046234522a01fe4c334e9ba5c9d66a876b
|
4
|
+
data.tar.gz: cec5203ee0ab08fb4a8327e50acfdef5bca0caf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dc82bd2a95bc854c7578389d36693bb1d4a5b3cbe677376172bc6043543495605bb069c230ece0c40b7221903ce46e553761e4a2afed991dbc34ff97589f3f9
|
7
|
+
data.tar.gz: b238ee97ccc78c24a68b58fa75190892550653a777119507ea8534a2d199b9f9f9f3c88b615a57e764783d0c7cf9e4b9fef995888af893d8e61b70d4cc0a06e3
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,37 +1,57 @@
|
|
1
1
|
---
|
2
|
+
#require: rubocop-rspec
|
2
3
|
AllCops:
|
3
4
|
DisplayCopNames: true
|
5
|
+
Exclude:
|
6
|
+
- 'lib/aws_assume_role/vendored/**/*.rb'
|
4
7
|
|
5
8
|
Metrics/MethodLength:
|
6
9
|
Enabled: false
|
7
10
|
|
11
|
+
Metrics/AbcSize:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Metrics/BlockLength:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Metrics/ClassLength:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
Metrics/CyclomaticComplexity:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
Metrics/PerceivedComplexity:
|
24
|
+
Enabled: false
|
25
|
+
|
8
26
|
Style/IndentationWidth:
|
9
27
|
Width: 4
|
10
28
|
|
29
|
+
RSpec/ExampleLength:
|
30
|
+
Enabled: false
|
31
|
+
|
11
32
|
Style/TrailingCommaInArguments:
|
12
33
|
EnforcedStyleForMultiline: comma
|
13
34
|
|
14
35
|
Style/TrailingCommaInLiteral:
|
15
36
|
EnforcedStyleForMultiline: comma
|
16
37
|
|
17
|
-
Style/
|
18
|
-
EnforcedStyle: empty_lines
|
19
|
-
|
20
|
-
Style/EmptyLinesAroundClassBody:
|
21
|
-
EnforcedStyle: empty_lines
|
22
|
-
|
23
|
-
Style/EmptyLinesAroundMethodBody:
|
38
|
+
Style/ClassAndModuleChildren:
|
24
39
|
Enabled: false
|
25
40
|
|
26
|
-
Style/
|
41
|
+
Style/Documentation:
|
27
42
|
Enabled: false
|
28
43
|
|
29
|
-
|
44
|
+
Style/VariableName:
|
30
45
|
Enabled: false
|
31
46
|
|
32
|
-
|
47
|
+
Style/StringLiterals:
|
48
|
+
EnforcedStyle: double_quotes
|
49
|
+
|
50
|
+
Style/MethodMissing:
|
33
51
|
Enabled: false
|
34
52
|
|
35
|
-
|
53
|
+
Style/TrivialAccessors:
|
36
54
|
Enabled: false
|
37
55
|
|
56
|
+
Metrics/LineLength:
|
57
|
+
Max: 140
|
data/Gemfile
CHANGED
@@ -1,18 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
source
|
2
|
+
source "https://rubygems.org"
|
3
3
|
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
gem
|
9
|
-
|
10
|
-
gem
|
6
|
+
group :development do
|
7
|
+
gem "pry", "~> 0.10"
|
8
|
+
gem "pry-byebug"
|
9
|
+
gem "pry-rescue", "~> 1.4"
|
10
|
+
gem "pry-stack_explorer", "~> 0.4"
|
11
|
+
gem "pry-state"
|
11
12
|
end
|
12
|
-
|
13
|
-
# Development dependencies - didn't seem to get installed when
|
14
|
-
# referenced in the gemspec, find out why.
|
15
|
-
gem 'bundler'
|
16
|
-
gem 'rake'
|
17
|
-
gem 'rspec'
|
18
|
-
gem 'rubocop', require: false
|
data/LICENSE.md
CHANGED
@@ -1,19 +1,201 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.md
CHANGED
@@ -1,205 +1,236 @@
|
|
1
|
-
|
1
|
+
aws-assume-role
|
2
|
+
---------------
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
the fetched credentials in Gnome Keyring or OSX Keychain so they are not
|
6
|
-
readable from disk.
|
4
|
+
aws-assume-role is a utility intended for developer and operator environments
|
5
|
+
who need to use 2FA and role assumption to access AWS services.
|
7
6
|
|
8
|
-
|
7
|
+
aws-assume-role can store both AWS access keys and ephemeral session tokens in
|
8
|
+
OS credential vaults - Keychain on OSX and Seahorse on Gnome.
|
9
9
|
|
10
|
-
|
10
|
+
Why?
|
11
|
+
---
|
12
|
+
|
13
|
+
This keeps your credentials safe in the keystore, and exist as
|
11
14
|
environment variables for the duration and context of the executing command.
|
12
15
|
This helps prevent credential leaking and theft, and means they aren't stored on
|
13
16
|
disk as unencrypted files.
|
14
17
|
|
15
|
-
It allows easy credential management and
|
16
|
-
|
17
|
-
For security and account management purposes we don't want to be managing users
|
18
|
-
in multiple accounts, just centrally then allowing them to assume roles in
|
19
|
-
other accounts.
|
18
|
+
It allows easy credential management and role assumption with a 2FA/MFA device.
|
20
19
|
|
21
|
-
|
20
|
+
For more information on role assumption, see the AWS documentation.
|
22
21
|
|
23
|
-
|
22
|
+
Requirements
|
23
|
+
------------
|
24
|
+
* Ruby ≥ 2.1
|
25
|
+
* OS X KeyChain or GNOME Keyring
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
- You then assume a role in another account.
|
27
|
+
Install
|
28
|
+
-------
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
users/access keys for each account.
|
33
|
-
|
34
|
-
## Install
|
35
|
-
|
36
|
-
`gem install aws_assume_role`
|
30
|
+
```sh
|
31
|
+
gem install aws_assume_role
|
32
|
+
```
|
37
33
|
|
38
34
|
### Platform notes
|
39
35
|
|
40
36
|
Gnome Keyring uses the [GirFFI](https://github.com/mvz/gir_ffi) bindings, which
|
41
|
-
|
42
|
-
`apt-get install gnome-keyring libgirepository1.0-dev` for Debian/Ubuntu.
|
37
|
+
require introspection bindings as well as Gnone Keyring, by installing one of the following packages:
|
43
38
|
|
44
|
-
|
39
|
+
``` sh
|
40
|
+
# Debian/Ubuntu
|
41
|
+
apt-get install gnome-keyring libgirepository1.0-dev
|
45
42
|
|
46
|
-
|
47
|
-
|
48
|
-
```yaml
|
49
|
-
---
|
50
|
-
default:
|
51
|
-
set_environment: false
|
52
|
-
# credentials come from .aws/credentials default profile or environment
|
53
|
-
|
54
|
-
scalefactory:
|
55
|
-
# if this profile is passed don't set the environment credentials
|
56
|
-
set_environment: false
|
57
|
-
# load credentials from sf_sso profile in .aws/credentials
|
58
|
-
profile: sf_sso
|
43
|
+
# Fedora
|
44
|
+
dnf install gobject-introspection-devel
|
59
45
|
|
46
|
+
# CentOS
|
47
|
+
yum install gobject-introspection-devel
|
48
|
+
```
|
49
|
+
Setup
|
50
|
+
-----
|
51
|
+
aws-assume-role works best if you also store permanent credentials in your keystore:
|
52
|
+
|
53
|
+
``` sh
|
54
|
+
> aws-assume-role configure
|
55
|
+
Enter the profile name to save into configuration
|
56
|
+
company-sso
|
57
|
+
Enter the AWS region you would like to default to:
|
58
|
+
eu-west-1
|
59
|
+
Enter the AWS Access Key ID to use for this profile:
|
60
|
+
1234567890010
|
61
|
+
Enter the AWS Secret Access Key to use for this profile:
|
62
|
+
abcdefghijklmnopqrstuvwzyx1
|
63
|
+
Profile `company-sso` saved to '/home/growthsmith/.aws/config'
|
64
|
+
```
|
60
65
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
set_environment: true
|
65
|
-
type: assume_role
|
66
|
-
region: eu-west-1
|
67
|
-
role_arn: arn:aws:iam::123456789012:role/RoleNameHere
|
66
|
+
### Configuring roles
|
67
|
+
Now that you've set up permanent credentials in your OS credential store, you can now
|
68
|
+
set up a role that you will assume in every day use:
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
``` sh
|
71
|
+
> aws-assume-role configure role -p company-dev --source-profile company-sso \
|
72
|
+
--role-arn=arn:aws:iam::000000000001:role/ViewEC2 --role-session-name=growthsmith \
|
73
|
+
--mfa-serial automatic
|
74
|
+
```
|
75
|
+
`--mfa-serial automatic` will look up your default attached multi-factor device, but you can specify a specific ARN.
|
74
76
|
|
75
|
-
|
76
|
-
|
77
|
-
set_environment: true
|
78
|
-
list:
|
79
|
-
- name: xx_test
|
80
|
-
env_prefix: TEST_
|
81
|
-
- name: xx_mgmt
|
82
|
-
env_prefix: MGMT_
|
77
|
+
More options are available in the application help.
|
78
|
+
Use `> aws-assume-role --help ` for help at any time.
|
83
79
|
|
80
|
+
Running applications
|
81
|
+
--------------------
|
84
82
|
|
85
|
-
|
86
|
-
yy_mgmt:
|
87
|
-
set_environment: true
|
88
|
-
type: assume_role
|
89
|
-
role_arn: arn:aws:iam::123456789012:role/RoleNameHere
|
83
|
+
You can run another application using
|
90
84
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
85
|
+
``` sh
|
86
|
+
aws-assume-role run -p company-dev -- aws ec2 describe-instances --query \
|
87
|
+
"Reservations[*].Instances[*].PrivateIpAddress" --output=text
|
88
|
+
10.254.4.20
|
89
|
+
10.254.4.15
|
90
|
+
10.254.0.10
|
91
|
+
10.254.4.5
|
92
|
+
```
|
95
93
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
env_prefix: TEST_
|
102
|
-
- name: xx_mgmt
|
103
|
-
env_prefix: MGMT_
|
94
|
+
Because we've enabled MFA, aws-assume-role will ask for your MFA token:
|
95
|
+
```
|
96
|
+
Please provide an MFA token
|
97
|
+
000000
|
98
|
+
```
|
104
99
|
|
105
100
|
|
101
|
+
Deleting a profile
|
102
|
+
------------------
|
103
|
+
If a set of credentials key needs revoking, or the profile isn't relevant anymore:
|
104
|
+
``` sh
|
105
|
+
> aws-assume-role delete -p company-sso
|
106
|
+
Please type the name of the profile, i.e. company-sso , to continue deletion.
|
107
|
+
company-sso
|
108
|
+
Profile company-sso deleted
|
106
109
|
```
|
107
110
|
|
111
|
+
Migrating AWS CLI profiles
|
112
|
+
------------------
|
113
|
+
It's better to revoke the existing keys and generate new ones. We try to overwrite the plaintext configuration
|
114
|
+
file with random data, but this does not take care of ~/.aws/credentials and does not account for SSD wear
|
115
|
+
levelling or copy-on-write snapshots.
|
116
|
+
```
|
117
|
+
aws-assume-role migrate -p company-sso
|
118
|
+
Profile 'company-sso' migrated to keyring.
|
119
|
+
```
|
108
120
|
|
121
|
+
Exporting environment variables
|
122
|
+
-------------------------------
|
123
|
+
You can use a session token in your shell any supported application without using
|
124
|
+
`aws-assume-role`.
|
109
125
|
|
126
|
+
You can also remove environment variables after finishing using the reset command.
|
110
127
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
128
|
+
#### Bourne Shell and friends
|
129
|
+
``` sh
|
130
|
+
> eval `./bin/aws-assume-role environment set -p company-dev`
|
131
|
+
> eval `./bin/aws-assume-role environment reset`
|
132
|
+
```
|
115
133
|
|
116
|
-
|
117
|
-
|
118
|
-
|
134
|
+
#### fish
|
135
|
+
``` fish
|
136
|
+
> set creds (bin/aws-assume-role environment set -s fish -p company-dev); eval $creds; set -e creds
|
137
|
+
> set creds (bin/aws-assume-role environment reset -s fish); eval $creds; set -e creds
|
138
|
+
```
|
119
139
|
|
120
|
-
|
140
|
+
#### PowerShell
|
141
|
+
``` powershell
|
142
|
+
> aws-assume-role environment set -s powershell -p company-dev | invoke-expression
|
143
|
+
> aws-assume-role environment reset -s powershell | invoke-expression
|
144
|
+
```
|
121
145
|
|
122
|
-
|
123
|
-
|
146
|
+
Launch the AWS console
|
147
|
+
---------------------
|
148
|
+
Given that `aws-assume-role` has knowledge of your role ARNs via AWS CLI profiles, you can
|
149
|
+
get to the AWS console for that role/account using
|
124
150
|
|
125
|
-
|
151
|
+
``` sh
|
152
|
+
> aws-assume-role console -p company-sso
|
153
|
+
```
|
126
154
|
|
127
|
-
|
128
|
-
|
129
|
-
Enter your AWS_ACCESS_KEY_ID:
|
130
|
-
1234567890010
|
131
|
-
Enter your AWS_SECRET_ACCESS_KEY:
|
132
|
-
abcdefghijklmnopqrstuvwzyx1
|
133
|
-
Enter a AWS Region:
|
134
|
-
eu-west-1
|
155
|
+
`aws-assume-role` will first attempt to log in and get a federated UI link, and
|
156
|
+
otherwise fall back to the "switch role" page.
|
135
157
|
|
158
|
+
Using inside Ruby
|
159
|
+
-----------------
|
160
|
+
To get a set of credentials via the OS credential store, or using console-based MFA, use
|
161
|
+
the following:
|
136
162
|
```
|
163
|
+
require "aws_assume_role"
|
137
164
|
|
138
|
-
|
139
|
-
|
165
|
+
AwsAssumeRole::DefaultProvider.new(options).resolve
|
140
166
|
```
|
141
|
-
|
142
|
-
|
143
|
-
|
167
|
+
where options is a hash with the following symbol keys:
|
168
|
+
* `access_key_id`
|
169
|
+
* `secret_access_key`
|
170
|
+
* `session_token`
|
171
|
+
* `persist_session`
|
172
|
+
* `duration_seconds`
|
173
|
+
* `role_arn`
|
174
|
+
* `role_session_name`
|
175
|
+
* `serial_number`
|
176
|
+
* `source_profile`
|
177
|
+
* `region`
|
178
|
+
|
179
|
+
`aws_assume_role` resolves credentials in almost the same way as the AWS SDK, i.e.:
|
180
|
+
|
181
|
+
```no-highlight
|
182
|
+
static credentials ⟶ environment variables ⟶ configured profiles
|
144
183
|
```
|
145
184
|
|
146
|
-
|
185
|
+
Any of the above may get chained to do MFA or role assumption, or both,
|
186
|
+
in the following order:
|
147
187
|
|
148
|
-
|
188
|
+
```no-highlight
|
189
|
+
second factor ⟶ role assumption (look up source profile and check for 2FA) ⟶ ecs/instance profile
|
190
|
+
```
|
149
191
|
|
150
|
-
|
192
|
+
These are the same as the AWS SDK equivalents whereever possible. The command line help will give an explanation of the rest.
|
151
193
|
|
194
|
+
### Monkeypatching the AWS SDK
|
195
|
+
You can also override the standard AWS SDK credential resolution system by including the following:
|
152
196
|
```
|
153
|
-
|
154
|
-
aws_access_key_id = 1234567890010
|
155
|
-
aws_secret_access_key = abcdefghijklmnopqrstuvwzyx1
|
156
|
-
region = eu-west-1
|
197
|
+
require "aws_assume_role/core_ext/aws-sdk/credential_provider_chain"
|
157
198
|
```
|
158
199
|
|
159
|
-
|
200
|
+
Using any standard AWS SDK for Ruby v2 client will then use aws_assume_role for credential resolution.
|
160
201
|
|
161
|
-
If `region` is defined for an `assume_role` type the environment variable
|
162
|
-
`AWS_DEFAULT_REGION` will be set with that value, otherwise it will be left
|
163
|
-
blank.
|
164
202
|
|
165
|
-
|
166
|
-
be set.
|
203
|
+
Please do not use this in production systems.
|
167
204
|
|
168
|
-
|
169
|
-
|
205
|
+
Other keyring backends
|
206
|
+
----------------------
|
207
|
+
`aws-assume-role` uses the Keyring gem for secure secret storage. By default, this will use OS X keycain
|
208
|
+
or GNOME Keyring. To load alternatives, set the following environment variables:
|
170
209
|
|
171
|
-
|
172
|
-
|
173
|
-
MGMT_AWS_DEFAULT_REGION=eu-west-1
|
174
|
-
MGMT_AWS_SECRET_ACCESS_KEY=+4324234234235454353535353535
|
175
|
-
MGMT_AWS_SESSION_TOKEN=F353453535345345345345345353534
|
176
|
-
TEST_AWS_ACCESS_KEY_ID=53454353453453453534
|
177
|
-
TEST_AWS_SECRET_ACCESS_KEY=3534534534534534534534
|
178
|
-
TEST_AWS_SESSION_TOKEN=5435345353453
|
179
|
-
```
|
210
|
+
* `AWS_ASSUME_ROLE_KEYRING_BACKEND`: Which backend to use, as the name of the Ruby class.
|
211
|
+
* `AWS_ASSUME_ROLE_KEYRING_PLUGIN` : Name of a gem to load.
|
180
212
|
|
181
|
-
|
182
|
-
|
213
|
+
These are also available in Ruby as the `AwsAssumeRole.Config.backend_plugin` and
|
214
|
+
`AwsAssumeRole.Config.backend_plugin` attributes.
|
183
215
|
|
184
|
-
|
216
|
+
License
|
217
|
+
-------
|
185
218
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
```
|
190
|
-
aws-assume-role --profile yy_mgmt -- aws ec2 describe-instances --query "Reservations[*].Instances[*].PrivateIpAddress" --output=text
|
191
|
-
10.254.4.20
|
192
|
-
10.254.4.15
|
193
|
-
10.254.0.10
|
194
|
-
10.254.4.5
|
195
|
-
```
|
219
|
+
This library and program is distributed under the
|
220
|
+
[Apache License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
|
196
221
|
|
222
|
+
```no-highlight
|
223
|
+
Copyright 2017. The Scale Factory Ltd. All Rights Reserved.
|
224
|
+
Portions Copyright 2013. Amazon Web Services, Inc. All Rights Reserved.
|
197
225
|
|
198
|
-
|
226
|
+
licensed under the apache license, version 2.0 (the "license");
|
227
|
+
you may not use this file except in compliance with the license.
|
228
|
+
you may obtain a copy of the license at
|
199
229
|
|
200
|
-
|
230
|
+
http://www.apache.org/licenses/license-2.0
|
201
231
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
232
|
+
unless required by applicable law or agreed to in writing, software
|
233
|
+
distributed under the license is distributed on an "as is" basis,
|
234
|
+
without warranties or conditions of any kind, either express or implied.
|
235
|
+
see the license for the specific language governing permissions and
|
236
|
+
limitations under the license.
|