11# Quickstart
22
3- Let's do a quick demonstration of the application.
3+ ## Demo
44
5- ## Make sure requirements are met
6-
7- [ Terraform] ( https://developer.hashicorp.com/terraform/install ) , or [ OpenTofu] ( https://opentofu.org/docs/intro/install/ ) , must be available from the command line.
8-
9- ## Run the application and the database in containers
10-
11- === "Docker"
12-
13- ```bash
14- curl -O https://raw.githubusercontent.com/devpro/terraform-backend-mongodb/refs/heads/main/compose.yaml
15- docker compose up
16- ```
5+ This is the exhaustive list of steps to use Terraform Backend MongoDB.
176
187<!--
198TODO: add other options
@@ -28,52 +17,66 @@ TODO: add other options
2817
2918 ```bash
3019 helm upgrade --install tfbackend \
31- https://github.com/devpro/helm-charts/releases/download/terraform-backend-mongodb-0.1.0/terraform-backend-mongodb-0.1.0.tgz \
32- --create-namespace --namespace tfbackend
20+ https://github.com/devpro/helm-charts/releases/download/terraform-backend-mongodb-0.1.0/terraform-backend-mongodb-0.1.0.tgz \
21+ --create-namespace --namespace tfbackend
3322 ```
34-
3523-->
3624
37- ## Create a user to authenticate calls
25+ 1 . Make sure requirements are met:
3826
39- === "Docker"
27+ - [ Terraform ] ( https://developer.hashicorp.com/terraform/install ) , or [ OpenTofu ] ( https://opentofu.org/docs/intro/install/ ) , must be available from the command line.
4028
41- ```bash
42- curl -O https://raw.githubusercontent.com/devpro/terraform-backend-mongodb/refs/heads/main/scripts/tfbeadm
43- MONGODB_CONTAINERNAME=tfbackmdb-mongodb-1 MONGODB_CONTAINERNETWORK=tfbackmdb_default tfbeadm create-user admin admin123 dummy
44- ```
29+ 2 . Run the application and the database in containers
4530
46- ## Create Terraform files
31+ === "Docker"
4732
48- === "Docker"
33+ ```bash
34+ curl -O https://raw.githubusercontent.com/devpro/terraform-backend-mongodb/refs/heads/main/compose.yaml
35+ docker compose up
36+ ```
4937
50- ```bash
51- curl -O https://raw.githubusercontent.com/devpro/terraform-backend-mongodb/refs/heads/main/samples/local-files/main.tf
52- ```
38+
39+
40+ 3 . Create a user to authenticate calls
41+
42+ === "Docker"
5343
54- ## Initiatize Terraform
44+ ```bash
45+ curl -O https://raw.githubusercontent.com/devpro/terraform-backend-mongodb/refs/heads/main/scripts/tfbeadm
46+ MONGODB_CONTAINERNAME=tfbackmdb-mongodb-1 MONGODB_CONTAINERNETWORK=tfbackmdb_default tfbeadm create-user admin admin123 dummy
47+ ```
5548
56- ``` bash
57- terraform init
58- ```
49+ 4 . Update Terraform backend (copy of an already configured simple sample)
5950
60- ## Create the resources
51+ === "Docker"
6152
62- ``` bash
63- terraform apply
64- ```
53+ ```bash
54+ curl -O https://raw.githubusercontent.com/devpro/terraform-backend-mongodb/refs/heads/main/samples/local-files/main.tf
55+ ```
6556
66- ## Query the state database
57+ 5 . Initiatize Terraform
58+
59+ ``` bash
60+ terraform init
61+ ```
6762
68- === "Docker"
63+ 6. Apply changes
6964
7065 ` ` ` bash
71- docker run --rm --link "tfbackmdb-mongodb-1" --network "tfbackmdb_default" "mongo:8.2" \
72- bash -c "mongosh \"mongodb://mongodb:27017/terraform_backend_dev\" --eval 'db.tf_state.find().projection({tenant: 1, name: 1, createdAt: 1, \"value.version\": 1, \"value.resources.type\": 1, \"value.resources.name\": 1})'"
66+ terraform apply
7367 ` ` `
7468
75- ## Destroy the resources
69+ 7. Query the state database
7670
77- ``` bash
78- terraform destroy
79- ```
71+ === " Docker"
72+
73+ ` ` ` bash
74+ docker run --rm --link " tfbackmdb-mongodb-1" --network " tfbackmdb_default" " mongo:8.2" \
75+ bash -c " mongosh \" mongodb://mongodb:27017/terraform_backend_dev\" --eval 'db.tf_state.find().projection({tenant: 1, name: 1, createdAt: 1, \" value.version\" : 1, \" value.resources.type\" : 1, \" value.resources.name\" : 1})'"
76+ ` ` `
77+
78+ 8. Destroy the resources
79+
80+ ` ` ` bash
81+ terraform destroy
82+ ` ` `
0 commit comments