solar-quote-service v1.28.3
Solar Quote/Pricing Service (BFF - Backend for Frontend)
This app was created with a cdk init --language=typescript and modified from there.
Running locally
You can run the lambda by configuring env variables, then running the docker container.
Create a
.envfile inside of/quote-service/infra/quote. Follow the.env.exampleand fill out the appropriate secrets.- Some will need to be looked up via AWS Secrets Manager
- The
AWS_*credential data is obtained by SSO'ing into AWS and using the values fromCommand line or programmatic accessbefore getting to the GUI.
Install Docker
- Build & Run the docker container
- Example:
cd /quote-service/infra/quotedocker build -t quote .docker run -p 80:80 -it quote- curl http://localhost:80 (see curl at very bottom of this README.MD))
- make a code change, stop the container, build & run again.
Testing
If you make infrastructure changes, run cdk synth to test them.
Useful commands
These commands from the CDK init boilerplate
npm run buildcompile typescript to jsnpm run watchwatch for changes and compilenpm run testperform the jest unit testscdk deploydeploy this stack to your default AWS account/regioncdk diffcompare deployed stack with current statecdk synthemits the synthesized CloudFormation template
Deploying
This package runs within the Lerna-controlled monorepo, and is deployed by using GitHub Actions from the root directory of the repository (../.github/workflows). You can also deploy to develop and staging temporarily using the deploy quote service [env] label.
Service Endpoint details
Get Solar Quote
Get solar quote data (pricing).
Request
POST /quote-service/quotetype body = {
address: string;
offset: Array<number>;
provider: string;
battery: number;
kwhr?: number;
lmbill?: number;
};Response
type response = {
[index: string]: {
battery: [
{
address: string;
offset: number;
target: number;
panels: number;
kwh_estimate: number;
batteries: number;
local_utility_rate: number;
location: {
lat: number;
lng: number;
};
pricing: [
{
type?: string;
kWh_rate?: number;
monthly_cost?: number;
escalator?: number;
}
];
}
];
};
};AWS Resources
Dashboard
| Environment | URL |
|---|---|
| Production | prd-Quote-Dashboard |
| Staging | majstg-Quote-Dashboard |
| Development | devmaj-Quote-Dashboard |
Lambdas
N/A (These are cloudfront functions)
Disaster Recovery
Please read the disaster recovery plan.
Monitoring
Can be found in the infrastructure package. devmaj-alarm-board
Notes
Triggering New Image Deployment
When we use ecs.ContainerImage.fromAsset('./infra/quote') instead of ecs.ContainerImage.fromDockerImageAsset, the CDK will only build and push a new image if the files within the ./infra/quote directory have changed. If no change is detected, CDK doesn't see the need to push a new image.
Example curl for docker
curl 'http://localhost:80/' \
-H 'Accept: application/json' \
-H 'Accept-Language: en-US,en;q=0.9' \
-H 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhZGRyZXNzIjoiMTgwMCBXYXplZSBTdCwgRGVudmVyLCBDTyA4MDIwMiIsImlhdCI6MTcwNDIxNzUzNX0.CDh6AJQmT_JzaQ6pRovuSn9af8V9N22GVERP1n0t3N8' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Origin: https://devmaj-www.sunrundev.com' \
-H 'Referer: https://devmaj-www.sunrundev.com/' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: same-site' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' \
-H 'sec-ch-ua: "Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "macOS"' \
--data-raw $'{
"address": "1077 E Granvia Valmonte, Palm Springs, CA 92262, USA",
"battery": 1,
"lmbill": 100,
"offset": [1],
"provider": "SCE",
"marketType": "SHIFT_CA",
"equipment": {
"SHIFT_CA": {
"battery": [
{
"model": "RESU 10H Prime",
"manufacturer": "LG",
"tier": "Standard",
"max_count": 1,
"productOfferings": ["SOLAR", "RAD"],
"usableCapacity": {
"unitPrefix": "k",
"value": 8.1
}
}
],
"panel": [{
"model": "LR4-60HPH-365M",
"manufacturer": "LONGi Green Energy Technology Co Ltd",
"tier": "Standard",
"cecmodelid": "LONGi_Green_Energy_Technology_Co___Ltd__LR6_72BP_365M",
"output": 365
}],
"inverter": [
{
"model": "E4_BDI",
"manufacturer": "Delta Electronics",
"tier": "Standard",
"cecmodelid": "Delta_Electronics__M8_TL_US__240V_",
"battery_count": 1
},
{
"model": "E4_BDI",
"manufacturer": "Delta Electronics",
"tier": "Standard",
"cecmodelid": "Delta_Electronics__M8_TL_US__240V_",
"battery_count": 2
},
{
"model": "E4_BDI",
"manufacturer": "Delta Electronics",
"tier": "Standard",
"cecmodelid": "Delta_Electronics__M8_TL_US__240V_",
"battery_count": 3
}
]
}
}
}' \
--compressed2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago