Please check details in KOK
The required version of terraform is ~>1.1.2 Code is tested against terraform is 1.1.6 - please use it
This project follows Main-module approach
Please keep in mind the official format of the code. Or just go to main directory of the repo and run
terraform fmt -recursive
There is no hook to do it right now so you need to perform this manually.
Requirements:
gcloud
CLI: https://cloud.google.com/sdk/docs/install
Go to env/dev and perform:
gcloud auth application-default login
terraform init
(only for the first run, or after dependency updates)terraform plan
terraform apply
to init terraform and apply the code
For dev environment there is no pipeline to upload things. Do it manually. For prod - to be defined
Files that are named *.enc.
are encrypted using GCP KMS via https://github.com/mozilla/sops
To create/edit them:
- Follow the sops installation steps from their GitHub README.
gcloud auth application-default login
- To encrypt a file:
- dev:
sops -e -i --gcp-kms projects/salamlab-development/locations/global/keyRings/terraform-sops-keyring/cryptoKeys/terraform-sops-key <path>
- prod (not setup yet):
sops -e -i --gcp-kms projects/salamlab-production/locations/global/keyRings/terraform-sops-keyring/cryptoKeys/terraform-sops-key <path>
- dev:
- To edit an encrypted file with
$EDITOR
:sops <path>
In general this should not be needed regularly. If you have a use case for manually connecting to the db please ping the devops team in the #general-tech channel on discord.
Requirements:
gcloud
CLI: https://cloud.google.com/sdk/docs/installsops
: https://github.com/mozilla/sopscloud_sql_proxy
: https://cloud.google.com/sql/docs/postgres/connect-admin-proxy#installvim
,vi
,nano
,emacs
editor configured withEDITOR
environment variable.
Steps:
- Make sure you have all the requirements installed
gcloud auth login
, select your kok account- Start the proxy:
- Dev:
cloud_sql_proxy -instances=salamlab-development:europe-central2:main-v2=tcp:127.0.0.1:5432
- Prod:
cloud_sql_proxy -instances=salamlab-production:europe-central2:main-v2=tcp:127.0.0.1:5432
- Dev:
gcloud auth application-default login
, select your kok accountsops env/dev/apartments-db-creds.enc.json
– this will print the username and password- Connect your db browser (psql/jetbrains/dbeaver/…) to
127.0.0.1:5432
and use the creds from step 4.
Unfortunately there's a mess of dependencies between resources that are not expressed in terraform, and not always can.
To work around that we could look into adding stages to the deployment, you'd set stage to 0, apply, set stage to 1, apply etc. See #52.
Check cloud run instance logs for PERMISSION_DENIED:Calling Google Service Control API failed with: 403 and body
.
If you see that, you need to enable the Service Control API
. See #51.