# sync-s3-assets-to-qa


Sync assets from PROD to QA S3 buckets.

### Setup

1. create `.env` file that will pass variables to container
```
$ cp .env.shadow .env
```
2. ensure [ECR access](https://www.notion.so/AWS-Access-f841b9dd815d4443a80e96a86c92cd2f?pvs=4#7a6624c58c6642abaecd804e5f25c820) is setup
3. enable AWS access to the **prod** account using [awsume](https://www.notion.so/AWS-Access-f841b9dd815d4443a80e96a86c92cd2f?pvs=4#beaec95488ad4473899a26a2b8cf603f)


#### Auth Using Browser

Shorter setup, slow to run script many times.

* In `.env`
  * set `SNOWFLAKE_AUTH_TYPE` to `externalbrowser`
  * set `SNOWFLAKE_USER` to your username (should be email)
* Log into Snowflake using your browser
* Follow prompts after running script

#### Auth Using Key Pair

Longer setup, fast to run script many times.

* Setup key pairs as described [here](https://www.notion.so/Snowflake-7c88cc17b0034e7db669a88fd2962bab?pvs=4#3aa649311d19425f8a3dd2e84eda8348)
* In `.env`
  * set `SNOWFLAKE_AUTH_TYPE` to `snowflake`
  * set `SNOWFLAKE_HOST_KEY_DIR` to directory on host containing private key
  * set `SNOWFLAKE_PRIVATE_KEY_FILE_PWD` to your private key's passphrase if configured else empty
  * set `SNOWFLAKE_USER` to your username (should be email)

### Running

```
$ docker compose run --build --rm sync-assets --upc <UPC>
```
Or
```
$ docker compose run --build --rm sync-assets --vendor_id <LabelID>
```

```
usage: -c [-h] [--upc UPC] [--vendor_id VENDOR_ID] [--workers WORKERS] [--gt-release-id GT_RELEASE_ID] [--lt-release-id LT_RELEASE_ID]

options:
  -h, --help            show this help message and exit
  --upc UPC             UPC that needs to sync assets on QA (default: 0)
  --vendor_id VENDOR_ID
                        LabelID that needs to sync all assets on QA (default: 0)
  --workers WORKERS     Number of parallel workers to download with (default: 20)
  --gt-release-id GT_RELEASE_ID
                        Filter RELEASES to rows with RELEASE_ID greater than this value (default: 0)
  --lt-release-id LT_RELEASE_ID
                        Filter RELEASES to rows with RELEASE_ID less than this value (default: 0)
```

