Skip to content

Commit da73549

Browse files
authored
docs: new dev doc for terraform (#105)
Signed-off-by: Di Wang <[email protected]>
1 parent 7885b55 commit da73549

File tree

5 files changed

+14
-36
lines changed

5 files changed

+14
-36
lines changed

.dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ module/.terraform/
33
module/.terraform*
44
module/*.tftest.hcl
55
module/backend.tf
6-
module/tfvars.json
6+
module/terraform.tfvars.json
77
module/plan
88
module/plan.json

.env.example

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
AWS_SHARED_CREDENTIALS_FILE=
2-
ER_INPUT_FILE=
1+
AWS_SHARED_CREDENTIALS_FILE=credentials
2+
INPUT_FILE=input.json
3+
PLAN_FILE_JSON=module/plan.json

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ cython_debug/
166166
# MacOS
167167
.DS_Store
168168

169-
cdktf.out
170169
input.json
171170
credentials
172171
tmp/
@@ -176,6 +175,6 @@ tmp/
176175
module/.terraform/
177176
module/.terraform.*
178177
module/backend.tf
179-
module/tfvars.json
178+
module/terraform.tfvars.json
180179
module/plan
181180
module/plan.json

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ COPY tests ./tests
4444
RUN make test
4545

4646
FROM base AS prod
47-
# get cdktf providers
47+
# get terraform providers
4848
COPY --from=builder ${TF_PLUGIN_CACHE_DIR} ${TF_PLUGIN_CACHE_DIR}
4949
# get our app with the dependencies
5050
COPY --from=builder ${APP} ${APP}

README.md

+8-30
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ External Resources module to provision and manage RDS instances in AWS with App-
44

55
## Tech stack
66

7-
* Terraform CDKTF
7+
* Terraform
88
* AWS provider
99
* Random provider
1010
* Python 3.12
@@ -56,32 +56,25 @@ export $(cat .env | xargs)
5656

5757
### On Host
5858

59-
Ensure `cdktf` is installed
60-
61-
```shell
62-
npm install --global [email protected]
63-
```
64-
6559
Generate terraform config.
6660

6761
```shell
68-
ER_INPUT_FILE="$PWD"/input.json cdktf synth
62+
generate-tf-config
6963
```
7064

7165
Ensure AWS credentials set in current shell, then use `terraform` to verify.
7266

7367
```shell
74-
cd cdktf.out/stakcs/CDKTF
68+
cd module
7569
terraform init
7670
terraform plan -out=plan
7771
terraform show -json plan > plan.json
7872
```
7973

80-
Test validation logic
74+
Test hooks
8175

8276
```shell
83-
cd ../../..
84-
ER_INPUT_FILE="$PWD"/input.json python hooks/validate_plan.py cdktf.out/stacks/CDKTF/plan.json
77+
hooks/post_plan.py
8578
```
8679

8780
### In Container
@@ -100,27 +93,12 @@ docker run --rm -ti \
10093
-v $PWD/input.json:/inputs/input.json:Z \
10194
-v $PWD/credentials:/credentials:Z \
10295
-e AWS_SHARED_CREDENTIALS_FILE=/credentials \
96+
-e WORK=/tmp/work \
10397
er-aws-rds:prod
10498
```
10599

106-
Generate terraform config.
107-
108-
```shell
109-
cdktf synth
110-
```
111-
112-
Use `terraform` to verify.
113-
114-
```shell
115-
cd cdktf.out/stakcs/CDKTF
116-
terraform init
117-
terraform plan -out=plan
118-
terraform show -json plan > plan.json
119-
```
120-
121-
Test validation logic
100+
Run the whole process
122101

123102
```shell
124-
cd ../../..
125-
python hooks/validate_plan.py cdktf.out/stacks/CDKTF/plan.json
103+
./entrypoint.sh
126104
```

0 commit comments

Comments
 (0)