Skip to content

Commit 38ff858

Browse files
authored
docs: Add development and debug doc (#59)
* docs: Add development and debug doc * docs: add .env example and container debug Signed-off-by: Di Wang <[email protected]>
1 parent c71c60d commit 38ff858

File tree

3 files changed

+117
-1
lines changed

3 files changed

+117
-1
lines changed

.env.example

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
AWS_REGION=
2+
AWS_ACCESS_KEY_ID=
3+
AWS_SECRET_ACCESS_KEY=

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# this file is used by asdf to automatically select the correct tool versions
22
# but it also serves as a reference for non-asdf users
33
uv
4+
terraform 1.6.6

README.md

+113-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,117 @@ External Resources module to provision and manage RDS instances in AWS with App-
77
* Terraform CDKTF
88
* AWS provider
99
* Random provider
10-
* Python 3.11
10+
* Python 3.12
1111
* Pydantic
12+
13+
## Development
14+
15+
Ensure `uv` is installed.
16+
17+
Prepare local development environment:
18+
19+
```shell
20+
make dev
21+
```
22+
23+
This will auto create a `venv`, to activate in shell:
24+
25+
```shell
26+
source .venv/bin/activate
27+
```
28+
29+
Optional config `.env`:
30+
31+
```shell
32+
cp .env.example .env
33+
```
34+
35+
Edit `.env` file with credentials
36+
37+
```shell
38+
qontract-cli --config $CONFIG get aws-creds $ACCOUNT
39+
```
40+
41+
Export to current shell
42+
43+
```shell
44+
source .env
45+
```
46+
47+
## Debugging
48+
49+
Export `input.json` via `qontract-cli` and place it in the current project root dir.
50+
51+
```shell
52+
qontract-cli --config $CONFIG external-resources --provisioner $PROVISIONER --provider $PROVIDER --identifier $IDENTIFIER get-input > input.json
53+
```
54+
55+
### On Host
56+
57+
Ensure `cdktf` is installed
58+
59+
```shell
60+
npm install --global [email protected]
61+
```
62+
63+
Generate terraform config.
64+
65+
```shell
66+
ER_INPUT_FILE="$PWD"/input.json cdktf synth
67+
```
68+
69+
Ensure AWS credentials set in current shell, then use `terraform` to verify.
70+
71+
```shell
72+
cd cdktf.out/stakcs/CDKTF
73+
terraform init
74+
terraform plan -out=plan
75+
terraform show -json plan > plan.json
76+
```
77+
78+
Test validation logic
79+
80+
```shell
81+
cd ../../..
82+
ER_INPUT_FILE="$PWD"/input.json python hooks/validate_plan.py cdktf.out/stacks/CDKTF/plan.json
83+
```
84+
85+
### In Container
86+
87+
Build image first
88+
89+
```shell
90+
make build
91+
```
92+
93+
Start container
94+
95+
```shell
96+
docker run --rm -ti \
97+
--entrypoint /bin/bash \
98+
--mount type=bind,source=$PWD/input.json,target=/inputs/input.json \
99+
--env-file .env \
100+
er-aws-rds:prod
101+
```
102+
103+
Generate terraform config.
104+
105+
```shell
106+
cdktf synth
107+
```
108+
109+
Use `terraform` to verify.
110+
111+
```shell
112+
cd cdktf.out/stakcs/CDKTF
113+
terraform init
114+
terraform plan -out=plan
115+
terraform show -json plan > plan.json
116+
```
117+
118+
Test validation logic
119+
120+
```shell
121+
cd ../../..
122+
python hooks/validate_plan.py cdktf.out/stacks/CDKTF/plan.json
123+
```

0 commit comments

Comments
 (0)