# python-auth0-sync-env

Sync specified users from `SOURCE` env to `TARGET` env.

## Env vars

Most of the configs live in secrets manager, except for the list of users to sync.

```
prod/auth0-sync-users/target-tenant-name = qa-orchard
prod/auth0-sync-users/target-machine-client-id = wRWdgVjevPBt0biegcOP52Th3cc0nTCd
prod/auth0-sync-users/target-machine-client-secret = 
prod/auth0-sync-users/target-connection = art-relations
prod/auth0-sync-users/source-tenant-name = workstation
prod/auth0-sync-users/source-machine-client-id = 3lVJWpLcb3jww6cAnoY4GWYP2W1gIjI1
prod/auth0-sync-users/source-machine-client-secret = 
prod/auth0-sync-users/source-connection = art-relations
prod/auth0-sync-users/email-template = QAORCHEmailContact+{}@theorchard.com
prod/auth0-sync-users/password = (this will be the same for all QA users)
```

### sync_users.yml

This is the list of users from the source tenant (workstation) to sync to the target tenant (qa-orchard).

#### format

```yaml
- id: 5c4f73f7f69cb715c147517d # vend_contact_id 42803
  force_delete: true
- id: 5c508c43f1b6375d929240e8 # vend_contact_id 17415
- id: 5c4a82a214f74009ce1576ad # vend_contact_id 46871
- id: 5c3fae99febc6c63c04e88fd # vend_contact_id 65804
```

By default, if the user already exists on the target tenant, it will skip the sync. However, by using the `force_delete` property, you can force the tenant user to be deleted, and the source tenant to be synced.

## Invoke the lambda

- QA: [https://scheduler.theorchard.io/job/lambda-auth0-sync-qa-invoke/](https://scheduler.theorchard.io/job/lambda-auth0-sync-qa-invoke/)
  - There are dummy values for client id and secret in QA so it will exit on fetching a machine-to-machine client. But QA deploy has to be there for the pipeline job to work.
- Prod: [https://scheduler.theorchard.io/job/lambda-auth0-sync-prod-invoke/](https://scheduler.theorchard.io/job/lambda-auth0-sync-prod-invoke/)


## Make

### env / pip_env
```bash
make env
```

### run
```bash
make run
```

## Test

### lint
```bash
make lint
```

### unit test
```bash
make test
```
