Skip to content

Commit 31472f8

Browse files
authored
Merge branch 'master' into VED-26-add-config
2 parents ed3c27c + 2cf8f55 commit 31472f8

18 files changed

+562
-175
lines changed

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,17 @@ Once connected, you should see the path as something similar to: `/mnt/d/Source/
108108
109109
5. Configure pyenv.
110110
```
111-
pyenv install --list | grep "3.10"
112-
pyenv install 3.10.16 #current latest
111+
pyenv install --list | grep "3.11"
112+
pyenv install 3.11.13 #current latest
113113
```
114114
115-
6. Install poetry
115+
6. Install direnv if not already present, and hook it to the shell.
116+
```
117+
sudo apt-get update && sudo apt-get install direnv
118+
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
119+
```
120+
121+
7. Install poetry
116122
```
117123
pip install poetry
118124
```
@@ -125,8 +131,9 @@ For detailed instructions on running individual Lambdas, refer to the README.md
125131
Steps:
126132
1. Set the python version in the folder with the code used by lambda for example `./backend` (see [lambdas](#lambdas)) folder.
127133
```
128-
pyenv local 3.10.16 # Set version in backend (this creates a .python-version file)
134+
pyenv local 3.11.13 # Set version in backend (this creates a .python-version file)
129135
```
136+
Note: consult the lambda's `pyproject.toml` file to get the required Python version for this lambda. At the time of writing, this is `~3.10` for the batch lambdas and `~3.11` for all the others.
130137
131138
2. Configure poetry
132139
```
@@ -203,4 +210,13 @@ The root (`immunisation-fhir-api`) should point to `/mnt/d/Source/immunisation-f
203210
## Verified commits
204211
Please note that this project requires that all commits are verified using a GPG key.
205212
To set up a GPG key please follow the instructions specified here:
206-
https://docs.github.com/en/authentication/managing-commit-signature-verification
213+
https://docs.github.com/en/authentication/managing-commit-signature-verification
214+
215+
216+
## AWS configuration: Getting credentials for AWS federated user account
217+
218+
In the 'Access keys' popup menu under AWS Access Portal:
219+
220+
**NOTE** that AWS's 'Recommended' method of getting credentials **(AWS IAM Identity Center credentials)** will break mocking in unit tests; specifically any tests calling `dynamodb_client.create_table()` will fail with `botocore.errorfactory.ResourceInUseException: Table already exists`.
221+
222+
Instead, use **Option 2 (Add a profile to your AWS credentials file)**.

infra/.env-default

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ENVIRONMENT=
2+
AWS_REGION=
3+
AWS_PROFILE=
4+
BUCKET_NAME=
5+
TF_VAR_key=

infra/.terraform.lock.hcl

Lines changed: 16 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infra/Makefile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
-include .env
2+
3+
interactionId=$(ENVIRONMENT)
4+
5+
tf_cmd = AWS_PROFILE=$(AWS_PROFILE) terraform
6+
tf_state= -backend-config="bucket=$(BUCKET_NAME)"
7+
tf_vars= -var-file=environments/$(ENVIRONMENT)/variables.tfvars
8+
9+
.PHONY: lock-provider workspace init plan apply clean destroy output tf-%
10+
11+
lock-provider:
12+
# Run this only when you install a new terraform provider. This will generate sha code in lock file for all platform
13+
echo "This may take a while. Be patient!"
14+
$(tf_cmd) providers lock -platform=darwin_arm64 -platform=darwin_amd64 -platform=linux_amd64 -platform=windows_amd64
15+
16+
workspace:
17+
$(tf_cmd) workspace new $(ENVIRONMENT) || $(tf_cmd) workspace select $(ENVIRONMENT) && echo "Switched to workspace/environment: $(ENVIRONMENT)"
18+
19+
init:
20+
$(tf_cmd) init $(tf_state) -upgrade $(tf_vars)
21+
22+
init-reconfigure:
23+
$(tf_cmd) init $(tf_state) -upgrade $(tf_vars) -reconfigure
24+
25+
plan: workspace
26+
$(tf_cmd) plan $(tf_vars)
27+
28+
apply: workspace
29+
$(tf_cmd) apply $(tf_vars) -auto-approve
30+
31+
clean:
32+
rm -rf build .terraform upload-key
33+
34+
destroy: workspace
35+
$(tf_cmd) destroy $(tf_vars) -auto-approve
36+
$(tf_cmd) workspace select default
37+
$(tf_cmd) workspace delete $(ENVIRONMENT)
38+
39+
output:
40+
ifndef name
41+
$(error name variable not set. Use 'make output name=...')
42+
endif
43+
$(tf_cmd) output -raw $(name)
44+
45+
import:
46+
$(tf_cmd) import $(tf_vars) $(to) $(id)
47+
48+
tf-%:
49+
$(tf_cmd) $*

infra/README.MD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# About
2+
Use .env-default as a reference for the required environment variables.
3+
You can use the commands defined in the Makefile to interact with the infrastructure resources.
4+
5+
Currently, this process is run manually whenever we need to update the base layer of our infrastructure. These core resources remain consistent across all deployments.
6+
7+
## Steps
8+
The general procedures are:
9+
1. Configure your environment by copying and updating `.env` based on the `.env-default` file.
10+
2. Run `make init` to initialize the Terraform project.
11+
3. Run `make plan` to review the proposed infrastructure changes.
12+
13+
4. Once you're confident in the plan and understand its impact, execute `make apply` to apply the changes.

0 commit comments

Comments
 (0)