
# User Creation Script


## Overview
This script provides functionality to create users and set base permissions for the following:
  - AWS dev
  - AWS prod
  - MySQL (prod/qa/dev art_relations & direct_delivery)
  - Snowflake


## Requirements

This script expects `.aws/(config|credentials)` and `.my.cnf` files to be configured for the user running this script.


### AWS
AWS config files should specify **dev** and **prod** profiles

Examples:

`~/.aws/credentials`:
```
[dev]
aws_access_key_id = AKIA************XHCP
aws_secret_access_key = Sd8z********************************8qV9
[prod]
aws_access_key_id = AKIA************YRVD
aws_secret_access_key = fo4z*******************************TTzXg
```

`~/.aws/config`:
```
[dev]
region = us-east-1
output = json
[prod]
region = us-east-1
output = json
```


### MySQL

`.my.cnf` files should follow the following syntax, with one entry per host
in which **$DBHOSTNAME** is replaced by each of the MySQL hosts specified below:

Syntax: 

&nbsp;&nbsp;&nbsp;&nbsp;**[mysql{$DBHOSTNAME}]**  
&nbsp;&nbsp;&nbsp;&nbsp;**user=user**  
&nbsp;&nbsp;&nbsp;&nbsp;**password="password"**  

Example:
```
 [mysqlprodserver.theorchard.com]
  user=orchardproduser
  password="prodpassword123"
 [mysqlqaserver.qaorch.com]
  user=orchardqauser
  password="qapassword123"
```


The default path for `.my.cnf` is in your home directory or `~/`. Fill in the following variable in `.env.shadow` to change the path of where `.my.cnf` is located.
```
* DOT_MYCNF_FILE_PATH
```


### Snowflake

Environment variables are used for Snowflake credentials, and should be filled in the following variables in `.env.shadow`:
```
* SNOWFLAKE_USER
* SNOWFLAKE_PASSWORD
```


## Command-Line Arguments
```
* -u (user): (required) name of user being created
* -a (dev-iam-user): (optional) - Dev AWS account
* -b (prod-iam-user): (optional) - Prod AWS account
* -c (reports-ar): (optional) - ReportsAR db account
* -d (reports-dd): (optional) - ReportsDD db account
* -e (qa-ar-db): (optional) - QA art_relations db account
* -f (qa-dd-db): (optional) - QA direct_delivery db account
* -g (dev-ar-db): (optional) - Dev art_relations db account
* -s (snowflake): (optional) - Snowflake account
```


## Usage

```
python3 -m venv env
source env/bin/activate
python -m pip install -r requirements.txt
python user_creation.py -u jerrcarr -a -b -c -d -e -f -g -s
```
