@@ -15,54 +15,65 @@ brew tap trussworks/tap
15
15
brew install setup-new-aws-user
16
16
```
17
17
18
- ## Usage
19
-
20
- ### Prerequisites
18
+ ### Dependencies
21
19
22
- #### Dependencies
20
+ This tool requires aws-vault be installed. You can install via homebrew:
23
21
24
22
``` shell
25
23
brew cask install aws-vault
26
24
```
27
25
26
+ ## Usage
27
+
28
+ This tool has several subcommands. Read each section to learn more.
29
+
30
+ ### setup-new-aws-user setup
31
+
28
32
Before running this tool, you will need to following pieces of information
29
33
34
+ * IAM user name - This is your IAM username. Use the flag ` --iam-user ` with this value.
30
35
* IAM role name - This is the IAM Role with permissions allowing access to AWS APIs
31
36
and services. This is usually something like ` admin ` or ` engineer ` . Use the flag
32
37
` --iam-role ` with this value.
33
- * IAM user name - This is your IAM username. Use the flag ` --iam-user ` with this value.
34
- * AWS profile - This is the name that populates your ` ~/.aws/config ` profile
35
- name. It is usually the name of the aws account alias you are trying to access.
36
- Use the flag name ` --aws-profile ` with this value.
37
- * AWS account Id - This is the 12-digit account number of the AWS account you
38
- are trying to access. Use the flag ` --aws-account-id ` with this value.
38
+ * AWS Profiles and Account IDs - This is the set of aws profile names you wish to
39
+ add along with the corresponding AWS account ID. They are referenced as
40
+ ` <AWS_PROFILE>:<AWS_ACCOUNT_ID> ` . Use the flag name ` --aws-profile-account `
41
+ with each set you wish to add.
39
42
* Temporary AWS access keys - These should be given to you by an administrator
40
43
of the AWS account you are trying to access. The tool will prompt you for
41
44
the access key id and secret access key.
42
45
43
- ## Running the tool
46
+ 1 . Run the setup-new-user script
47
+
48
+ ``` sh
49
+ setup-new-aws-user setup \
50
+ --iam-user < USER> \
51
+ --iam-role < ROLE> \
52
+ --aws-profile-account < AWS_PROFILE1> :< AWS_ACCOUNT_ID1> \
53
+ --aws-profile-account < AWS_PROFILE2> :< AWS_ACCOUNT_ID2>
54
+ ```
44
55
45
- 1 . Run the setup-new-user script - ` setup-new-aws-user setup --iam-role <IAM_ROLE> --iam-user <USER> --aws-profile=<AWS_PROFILE> --aws-account-id=<AWS_ACCOUNT_ID> `
46
56
2. Enter the access keys generated when prompted.
47
57
3. The script will open a window with a QR code, which you will use to configure a temporary one time password (TOTP).
48
58
4. You' ll then need to create a new entry in your 1Password account configure it with a TOTP field.
49
59
5. Use 1Password to scan the QR code and hit save. New TOTP tokens should generate every 30 seconds.
50
60
6. From here the tool will prompt you for 3 unique TOTP tokens. **NOTE Take care not to use the same token more than once, as this will cause the process to fail.**
51
- 7 . Once the tool has completed, you should be able to access the AWS account. You can run the following command filling in the AWS_PROFILE value
61
+ 7. Once the tool has completed, you should be able to access the AWS account. You can run the following command filling in the ` AWS_PROFILE` value
52
62
53
- ``` shell
54
- aws-vault exec $AWS_PROFILE -- aws sts get-session
55
- ```
63
+ ```sh
64
+ aws-vault exec $AWS_PROFILE -- aws sts get-session
65
+ ```
56
66
57
- ## How this tool modifies your ~ /.aws/config
67
+ #### How `setup` modifies your ~/.aws/config
58
68
59
69
While your AWS access keys are stored in a password protected keychain managed by `aws-vault`, the configuration for
60
- how you should access AWS accounts lives in ~ /.aws/config. The setup-new-aws-user tool creates two profiles your
70
+ how you should access AWS accounts lives in ~/.aws/config. The ` setup-new-aws-user setup` tool creates new profiles in
61
71
`~/.aws/config`. The first is the base profile containing your long lived AWS Access Keys and is tied to your IAM user
62
72
and MFA device. Since these keys are long lived, you should be rotating them regularly with `aws-vault rotate`.
63
73
The second profile is the IAM role granting you elevated access to the AWS account. Typically these IAM roles are
64
74
named `admin` or `engineer` and only uses temporary credentials leveraging AWS' s Security Token Service (STS).
65
- Below is an example config generated from this tool.
75
+ Below is an example config generated from this tool. Additional profiles will be similarly added and reference the
76
+ base profile.
66
77
67
78
` ` ` ini
68
79
[profile corp-id-base]
@@ -78,7 +89,7 @@ region=us-west-2
78
89
output=json
79
90
` ` `
80
91
81
- ### MFA Management
92
+ # ### MFA Management
82
93
83
94
This tool will help create and enable a virtual MFA device. The interface for the MFA device is a QR code
84
95
which will be shown to the user during setup. This QR code can be used with a password manager to provide the
@@ -88,6 +99,68 @@ In the case where the user has a virtual MFA device already set up they can choo
88
99
This is done by issuing the ` --no-mfa` flag on the command line in conjunction with the regular command from
89
100
above.
90
101
102
+ ### setup-new-aws-user add-profile
103
+
104
+ Before running this tool, you will need to following pieces of information
105
+
106
+ * IAM role name - This is the IAM Role with permissions allowing access to AWS APIs
107
+ and services. This is usually something like ` admin` or ` engineer` . Use the flag
108
+ ` --iam-role` with this value.
109
+ * AWS profile - This is the name of the profile in your ` ~/.aws/config` profile
110
+ that you wish to use as the basis for adding new profiles. The ` source_profile`
111
+ and ` mfa_serial` is pulled from this profile.
112
+ Use the flag name ` --aws-profile` with this value.
113
+ * AWS Profiles and Account IDs - This is the set of aws profile names you wish to
114
+ add along with the corresponding AWS account ID. They are referenced as
115
+ ` < AWS_PROFILE> :< AWS_ACCOUNT_ID> ` . Use the flag name ` --aws-profile-account`
116
+ with each set you wish to add.
117
+
118
+ 1. Run the setup-new-user script -
119
+
120
+ ` ` ` sh
121
+ setup-new-aws-user add-profile \
122
+ --aws-profile < AWS_PROFILE> \
123
+ --iam-role < IAM_ROLE> \
124
+ --aws-profile-account < AWS_PROFILE1> :< AWS_ACCOUNT_ID1> \
125
+ --aws-profile-account < AWS_PROFILE2> :< AWS_ACCOUNT_ID2>
126
+ ` ` `
127
+
128
+ 2. Once the tool has completed, you should be able to access the AWS account. You can run the following command filling in the ` AWS_PROFILE` value
129
+
130
+ ` ` ` sh
131
+ aws-vault exec $AWS_PROFILE -- aws sts get-session
132
+ ` ` `
133
+
134
+ #### How ` add-profile` modifies your ~ /.aws/config
135
+
136
+ While your AWS access keys are stored in a password protected keychain managed by ` aws-vault` , the configuration for
137
+ how you should access AWS accounts lives in ~ /.aws/config. The ` setup-new-aws-user add-profile` tool creates new profiles in
138
+ ` ~/.aws/config` . New profiles reference the ` source_profile` and ` mfa_serial` of the ` --aws-profile` used in
139
+ the command and uses the IAM role granting you elevated access to the AWS account. Typically these IAM roles are
140
+ named ` admin` or ` engineer` and only uses temporary credentials leveraging AWS' s Security Token Service (STS).
141
+ Below is an example config generated from this tool. Additional profiles will be similarly added and reference the
142
+ base profile.
143
+
144
+ ```ini
145
+ [profile corp-new]
146
+ source_profile=corp-id-base
147
+ mfa_serial=arn:aws:iam::123456789012:mfa/alice
148
+ role_arn=arn:aws:iam::123456789012:role/engineer
149
+ region=us-west-2
150
+ output=json
151
+ ```
152
+
153
+ ### setup-new-aws-user version
154
+
155
+ To get the version of the tool run:
156
+
157
+ ```sh
158
+ setup-new-aws-user version
159
+ ```
160
+
161
+ In development mode you may see the word `development` returned. Otherwise you should see the version of the tool
162
+ as it was built by the release pipeline.
163
+
91
164
## Development setup
92
165
93
166
1. First, install these packages: `brew install pre-commit direnv go`
@@ -119,7 +192,7 @@ use the real AWS account ID.
119
192
Example:
120
193
121
194
` ` ` shell
122
- go run ./cmd setup --iam-role engineer --iam-user testuser --aws-profile test-profile-name --aws-account-id 123456789012
195
+ go run ./cmd setup --iam-role engineer --iam-user testuser --aws-profile-account test-profile-name: 123456789012
123
196
` ` `
124
197
125
198
After running the script, try a command to ensure the new profile works as
0 commit comments