### Deployment Generator

Description :

This lambda is used for Deployment generator , this lambda checkouts the deployment yaml template and pushes message to SQS queue that component is ready ti be deployed , post which downstream activities are carried by EDS

Steps to use the pipeline :
1. Navigate to Jenkins-> bred-deployment-lambda
2. Click on Feature/Master branch
3. Click on "Build with Parameters"
4. Enter the config file path from bitbucket for specific Enviornment
5. Select Terraform plan from drop and click on build
6. Terraform plan will check for syntatical error , once the buld is successful 
7 ) Click on "Build with Parameters" again  Click on Terraform apply to deploy the infrastructure

URLS :
Jenkins -- https://jenkins.bre.mcd.com/job/BRED%20Projects/job/bred-deployment-lambda/
Config file path -- https://bitbucket.bre.mcd.com/projects/BRED/repos/bred-deployment-lambda/browse/terraform/configurations

## How to build a package

### Requirements
* python3.7
* zip

### Building function.zip

To build the package we can use `install_deps.sh` script. This script will install all required libraries.
Once the libraries are installed it will create a zip file with all libraries and deploymentGenerator.py file.

```sh
./install_deps.sh
```
## Lambda Layer

For this code to work in lambda, a lambda layer has to bee attached.

```arn:aws:lambda:us-east-1:553035198032:layer:git:8```

If lambda is not in `us-east-1` then the region needs to be changed

## Variables that can be overwritten using lambda env variables

| Variable       | Default Valuee                                                                                              | Description                                     |
| -------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
| gitUrlProtocol | https                                                                                                        | Protocol for git url http or https              |
| gitUrl         | https://bitbucket.bre.mcd.com/scm/bre/bre-lambda-yml-templates.git                                           | Url to git repository with lambda templates     |
| gitBranch      | master                                                                                                      | Branch that we want to use in gitUrl repository |
| smName         | github/bre-cloud-git-reconcile                                                                              | Name of Secret Manager value                    |
| queuePrefix    | -BRE-ARCH-                                                                                                  | Prefix for SQS queue                            |
| queueSuffix    | -SQS                                                                                                        | Suffix for SQS queue                            |
| assetsUrl      | https://asset-service.bre.mcd.com/restaurant_assets                                             | Url to assets service                           |
| Name      | US-EAST-DEV-BRE-ARCH-BRE-DEPLOYMENTGENERATOR                                                                                                      | Name of the lambda
 | Environment         | US-EAST-DEV-BRE-ARCH                                                                                            | Enviroment the lambda lives in
 | GBL         | 195500432366                                                                                            | GBL Number 
 | ApplicationID         | APP1238134                                                                                            | Application Number 
 | Market         | US                                                                                            | Market lambda will live in 
 | Owner         | zainab.tajmahal@us.mcd.com.com                                                                                            | Owner of lambda
 | Workload         | DEV                                                                                            | Workload environment
 | cpm backup         | mcds_us_weekly_1_non_prod                                                                                            | backup for lambda



## Running lambda locally

We need to install `python-lambda-local` library using `pip3`
Once that is installed we can run lambda locally for testing

```sh
pip3 install python-lambda-local
python-lambda-local -f lambda_handler deploymentGenerator.py event.json
```
