Skip to content

Commit 432a894

Browse files
authored
VED-491 Move mesh to own folder (#680)
1 parent 305ef80 commit 432a894

File tree

14 files changed

+212
-78
lines changed

14 files changed

+212
-78
lines changed

infra/.env-default

Lines changed: 0 additions & 5 deletions
This file was deleted.

infra/.terraform.lock.hcl

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

infra/README.MD

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ You can use the commands defined in the Makefile to interact with the infrastruc
44

55
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.
66

7-
## Steps
7+
## Running terraform
88
The general procedures are:
9-
1. Configure your environment by copying and updating `.env` based on the `.env-default` file.
9+
1. Set up your environment by creating a .env file with the following values. Note: some values may require customisation based on your specific setup.
10+
```dotenv
11+
ENVIRONMENT=(select subfolder from environments)
12+
AWS_PROFILE=your-profile
13+
BUCKET_NAME=(find bucket name in aws)
14+
TF_VAR_key=state
15+
```
1016
2. Run `make init` to initialize the Terraform project.
1117
3. Run `make plan` to review the proposed infrastructure changes.
12-
1318
4. Once you're confident in the plan and understand its impact, execute `make apply` to apply the changes.

infra/environments/int/variables.tfvars

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@ dspp_admin_role = "root"
77
environment = "int"
88
parent_route53_zone_name = "int.vds.platform.nhs.uk"
99
child_route53_zone_name = "imms.int.vds.platform.nhs.uk"
10-
mesh_mailbox_id = "X26OT303"
11-
mesh_dlq_mailbox_id = "X26OT304"

infra/environments/non-prod/variables.tfvars

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,3 @@ dspp_admin_role = "root"
77
environment = "dev"
88
parent_route53_zone_name = "dev.vds.platform.nhs.uk"
99
child_route53_zone_name = "imms.dev.vds.platform.nhs.uk"
10-
# TODO - null these out once we're using the int account
11-
# mesh_mailbox_id = null
12-
# mesh_dlq_mailbox_id = null
13-
mesh_mailbox_id = "X26OT303"
14-
mesh_dlq_mailbox_id = "X26OT304"

infra/mesh.tf

Lines changed: 0 additions & 15 deletions
This file was deleted.

infra/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,3 @@ variable "build_agent_account_id" {
1616
variable "environment" {
1717
default = "non-prod"
1818
}
19-
variable "mesh_mailbox_id" {
20-
default = null
21-
}
22-
variable "mesh_dlq_mailbox_id" {
23-
default = null
24-
}

mesh_infra/.terraform.lock.hcl

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

mesh_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) $*

mesh_infra/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Important
2+
The Mesh module is not idempotent, which is why it is kept separate from the main infrastructure folder. Each time the module is applied, it triggers the recreation of various AWS resources related to the Mesh configuration.
3+
There is 1 mesh mailbox for int that currently resides in the dev AWS account. This should be moved to the new INT AWS account once it becomes active.
4+
5+
## Running terraform
6+
The general procedures are:
7+
1. Set up your environment by creating a .env file with the following values. Note: some values may require customisation based on your specific setup.
8+
```dotenv
9+
ENVIRONMENT=int or prod
10+
AWS_PROFILE=your-profile
11+
BUCKET_NAME=(find mesh bucket name in aws s3)
12+
TF_VAR_key=state
13+
```
14+
2. Run `make init` to initialize the Terraform project.
15+
3. Run `make plan` to review the proposed infrastructure changes.
16+
4. Once you're confident in the plan and understand its impact, execute `make apply` to apply the changes.

0 commit comments

Comments
 (0)