## Adjustment File Validation

Lambda for validating adjustment file content.

## Requirements

## Running

### Set up the Environment

Copy the `.env.shadow` to a local `.env`:

```shell
cp .env.shadow .env
```

#### AWS Creds

Generate your AWS credentials using [awsume](https://www.notion.so/AWS-Access-f841b9dd815d4443a80e96a86c92cd2f?pvs=4#f11f08d09f16493a8a3e9dbf38d87164): by running `awsume prod -s`

Take your `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` values
and copy them into your `.env`

Example output from `awsume prod -s`:

```shell
export AWS_ACCESS_KEY_ID=<secret>
export AWS_SECRET_ACCESS_KEY=<secret>
export AWS_SESSION_TOKEN=<secret>
```

#### Log into ECR:

_After generating aws creds_

```shell
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 086679231553.dkr.ecr.us-east-1.amazonaws.com
```

#### Snowflake Creds

You will need to have a Snowflake SSH key pair to run this lambda.

If you do not have a Snowflake SSH key pair set up, follow these instructions:

1. Create a snowflake subdirectory: `mkdir ~/.ssh/snowflake`

2. Navigate to the new subdirectory: `cd ~/.ssh/snowflake`

3. Run the following command to create a public and private key:

```shell
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8
openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub
```

4. you will be prompted to create a **passphrase** -- **use something you will remember and/or jot it down, you will need this to decrypt your private key**
5. copy your `rsa_key.pub` (without the header/footer) and add it to [terraform](https://github.com/theorchard/terraform-infra/blob/master/prod/snowflake/orchard/users/users.auto.tfvars) ([example PR](https://github.com/theorchard/terraform-infra/pull/15503))

Make sure to fill in all the necessary snowflake environment variables in your `.env`:

- `SNOWFLAKE_USER` is your email (i.e. `dczinsky@sonymusic-pde.com`)
- `SNOWFLAKE_KEY_PASSPHRASE` is the key passphrase you used when creating your key-pair
- `SNOWFLAKE_PRIVATE_KEY_PATH` is the path to your private key on your machine -- if you followed the instructions above it should be `~/.ssh/snowflake/rsa_key.p8`

Source everything with:

```shell
source .env
```
