Skip to content

Commit b43acf2

Browse files
author
Michael Kania
authored
Merge pull request #38 from trussworks/mk-cleanup-docs
Update Docs
2 parents 496c66d + 4225c0d commit b43acf2

File tree

2 files changed

+58
-56
lines changed

2 files changed

+58
-56
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2.1
22

33
references:
4-
circleci-docker-primary: &circleci-docker-primary trussworks/circleci-docker-primary:3ce332312856084283853e50c98a3e68e8241e89
4+
circleci-docker-primary: &circleci-docker-primary trussworks/circleci-docker-primary:d7f27acdab24f86297220a43f704f23f2bab667d
55

66
jobs:
77
test:
@@ -26,7 +26,7 @@ jobs:
2626
- "~/go/pkg/mod"
2727
release:
2828
docker:
29-
- image: goreleaser/goreleaser:v0.128
29+
- image: goreleaser/goreleaser:v0.130
3030
steps:
3131
- checkout
3232
- run:

README.md

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# setup-new-aws-user
22

3-
This script creates a virtual MFA device and rotates access keys for a new AWS user.
3+
This tool is used to grant programmatic access to AWS account(s) using
4+
[aws-vault](https://github.com/99designs/aws-vault). It works by taking a
5+
temporary set of AWS access keys for a new IAM user. It then generates a
6+
virtual MFA device and permanent set of access keys. Finally, it removes
7+
the temporary access keys.
48

59
## Installation
610

7-
For OSX Homebrew:
11+
For Mac OS Homebrew:
812

913
```shell
1014
brew tap trussworks/tap
@@ -13,63 +17,61 @@ brew install setup-new-aws-user
1317

1418
## Usage
1519

16-
The script accepts a number of arguments, either as environment variables or
17-
command-line flags:
18-
19-
```text
20-
Usage:
21-
main [OPTIONS]
22-
Application Options:
23-
--region= The AWS region (default: us-west-2) [$AWS_REGION]
24-
--account-id= The AWS account number [$AWS_ACCOUNT_ID]
25-
--profile= The AWS profile name [$AWS_PROFILE]
26-
--iam-user= The IAM user name
27-
--role= The user role type
28-
--output= The AWS CLI output format (default: json)
29-
Help Options:
30-
-h, --help Show this help message
20+
### Prerequisites
21+
22+
#### Dependencies
23+
24+
```shell
25+
brew cask install aws-vault
26+
```
27+
28+
Before running this tool, you will need to following pieces of information
29+
30+
* IAM role - This is the IAM Role with permissions allowing access to AWS APIs
31+
and services. This is usually something like `admin` or `engineer`.
32+
* IAM user name - This is your IAM username.
33+
* AWS profile - This is the name that populates your `~/.aws/config` profile
34+
name. It is usually the name of the aws account alias you are trying to access.
35+
* AWS account Id - This is the 12-digit account number of the AWS account you
36+
are trying to access.
37+
* Temporary AWS access keys - These should be given to you by an administrator
38+
of the AWS account you are trying to access. The tool will prompt you for
39+
the access key id and secret access key.
40+
41+
## Running the tool
42+
43+
1. Run the setup-new-user - `setup-new-aws-user --role <IAM_ROLE> --iam_user <USER> --profile=<AWS_PROFILE> --account-id=<AWS_ACCOUNT_ID>`
44+
2. Enter the access keys generated when prompted.
45+
46+
3. The script will open a window with a QR code, which you will use to configure a temporary one time password (TOTP).
47+
4. You'll then need to create a new entry in your 1Password account configure it with a TOTP field.
48+
5. Use 1Password to scan the QR code and hit save. New TOTP tokens should generate every 30 seconds.
49+
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.**
50+
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
51+
52+
```shell
53+
aws-vault exec AWS_PROFILE -- aws sts get-session
3154
```
3255

33-
For the arguments that accept either an environment variable or command-line
34-
flag, the environment variable takes precedence if both are provided due to the
35-
way go-flags works.
36-
37-
### Setup new IAM user
38-
39-
1. Have admin user run through
40-
[these instructions](https://github.com/trussworks/legendary-waddle/blob/master/docs/how-to/setup-new-user.md#existing-admin-user-does-this)
41-
in legendary-waddle repo to generate access keys.
42-
1. Set `AWS_ACCOUNT_ID` and `AWS_PROFILE` variables in one of three ways:
43-
- Save to an .envrc.local file
44-
- Set them as local environment variables on your terminal, or
45-
- Pass them through as flags when you run this script
46-
(i.e.
47-
`go run cmd/main.go --role <ROLE> --iam-user <USER> --profile=<AWS_PROFILE> --account-id=<AWS_ACCOUNT_ID>`)
48-
1. Run the setup-new-user script: `go run cmd/main.go --role <ROLE> --iam_user <USER>`
49-
1. Enter the access keys generated when prompted.
50-
1. The script will display a QR code for an MFA device at some point.
51-
Create an entry in your 1Password account with a One Time Password (OTP)
52-
field and be ready to scan it with the 1Password app.
53-
Currently works only with mobile app.
54-
55-
- **NOTE** You will be asked for your MFA (TOTP) tokens three times while
56-
validating the new virtual MFA device and rotating your access keys.
57-
**Take care not to use the same token
58-
more than once**, as this will cause the process to fail.
59-
60-
## Dev setup
61-
62-
1. First, install these packages:
63-
- `brew install pre-commit`
64-
- `brew install direnv`
65-
1. Next, clone the project repository.
66-
1. Finally, run these commands inside the local repo:
67-
- `pre-commit install --install-hooks`
68-
- `direnv allow`
69-
1. The `.envrc` will be loaded if `direnv` is installed.
56+
## Development setup
57+
58+
1. First, install these packages: `brew install pre-commit direnv go`
59+
2. Next, clone the project repository.
60+
3. Finally, run these commands inside the local repo: `direnv allow`
61+
4. The `.envrc` will be loaded if `direnv` is installed.
7062

7163
### Testing
7264

65+
#### Unit Tests
66+
67+
Run pre-commit and Go tests
68+
69+
```shell
70+
make test
71+
```
72+
73+
#### Integration / End 2 End Testing
74+
7375
For testing, create a test IAM user so as not to interfere with your primary
7476
user credentials and AWS config settings. The test user will need the
7577
`enforce-mfa` policy and permission to assume whichever role being assigned.

0 commit comments

Comments
 (0)