This app was created with a cdk init --language=typescript
and modified from there.
You can run the lambda by configuring env variables, then running the docker container.
-
Create a
.env
file inside of/quote-service/infra/quote
. Follow the.env.example
and 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 access
before getting to the GUI.
-
Install Docker
-
Build & Run the docker container
- Example:
cd /quote-service/infra/quote
docker 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.
If you make infrastructure changes, run cdk synth
to test them.
These commands from the CDK init boilerplate
-
npm run build
compile typescript to js -
npm run watch
watch for changes and compile -
npm run test
perform the jest unit tests -
cdk deploy
deploy this stack to your default AWS account/region -
cdk diff
compare deployed stack with current state -
cdk synth
emits the synthesized CloudFormation template
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.
Get solar quote data (pricing).
POST /quote-service/quote
type body = {
address: string;
offset: Array<number>;
provider: string;
battery: number;
kwhr?: number;
lmbill?: number;
};
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;
}
];
}
];
};
};
Environment | URL |
---|---|
Production | prd-Quote-Dashboard |
Staging | majstg-Quote-Dashboard |
Development | devmaj-Quote-Dashboard |
N/A (These are cloudfront functions)
Please read the disaster recovery plan.
Can be found in the infrastructure package. devmaj-alarm-board
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.
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
}
]
}
}
}' \
--compressed