Skip to content

Commit a67e373

Browse files
CCM-10283: Add e2e test
1 parent 07d6e45 commit a67e373

File tree

14 files changed

+171
-25
lines changed

14 files changed

+171
-25
lines changed

infrastructure/terraform/components/sandbox/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
## Requirements
66

7-
No requirements.
7+
| Name | Version |
8+
|------|---------|
9+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.9.0 |
10+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.50 |
811
## Inputs
912

1013
| Name | Description | Type | Default | Required |
@@ -15,7 +18,7 @@ No requirements.
1518
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
1619
| <a name="input_group"></a> [group](#input\_group) | The group variables are being inherited from (often synonymous with account short-name) | `string` | n/a | yes |
1720
| <a name="input_kms_deletion_window"></a> [kms\_deletion\_window](#input\_kms\_deletion\_window) | When a kms key is deleted, how long should it wait in the pending deletion state? | `string` | `"30"` | no |
18-
| <a name="input_letter_suppliers"></a> [letter\_suppliers](#input\_letter\_suppliers) | Letter suppliers enabled in the environment | <pre>map(object({<br/> email_addresses = list(string)<br/> enable_polling = bool<br/> default_supplier = optional(bool)<br/> }))</pre> | <pre>{<br/> "WTMMOCK": {<br/> "default_supplier": true,<br/> "email_addresses": [<br/> "template-submitted-recipient@sandbox.templates.dev.nhsnotify.national.nhs.uk"<br/> ],<br/> "enable_polling": true<br/> }<br/>}</pre> | no |
21+
| <a name="input_letter_suppliers"></a> [letter\_suppliers](#input\_letter\_suppliers) | Letter suppliers enabled in the environment | <pre>map(object({<br/> email_addresses = list(string)<br/> enable_polling = bool<br/> default_supplier = optional(bool)<br/> }))</pre> | <pre>{<br/> "WTMMOCK": {<br/> "default_supplier": true,<br/> "email_addresses": [],<br/> "enable_polling": true<br/> }<br/>}</pre> | no |
1922
| <a name="input_log_retention_in_days"></a> [log\_retention\_in\_days](#input\_log\_retention\_in\_days) | The retention period in days for the Cloudwatch Logs events to be retained, default of 0 is indefinite | `number` | `0` | no |
2023
| <a name="input_parent_acct_environment"></a> [parent\_acct\_environment](#input\_parent\_acct\_environment) | Name of the environment responsible for the acct resources used, affects things like DNS zone. Useful for named dev environments | `string` | `"main"` | no |
2124
| <a name="input_project"></a> [project](#input\_project) | The name of the tfscaffold project | `string` | n/a | yes |
@@ -40,6 +43,8 @@ No requirements.
4043
| <a name="output_sftp_mock_credential_path"></a> [sftp\_mock\_credential\_path](#output\_sftp\_mock\_credential\_path) | n/a |
4144
| <a name="output_sftp_poll_lambda_name"></a> [sftp\_poll\_lambda\_name](#output\_sftp\_poll\_lambda\_name) | n/a |
4245
| <a name="output_templates_table_name"></a> [templates\_table\_name](#output\_templates\_table\_name) | n/a |
46+
| <a name="output_test_email_bucket_name"></a> [test\_email\_bucket\_name](#output\_test\_email\_bucket\_name) | n/a |
47+
| <a name="output_test_email_prefix"></a> [test\_email\_prefix](#output\_test\_email\_prefix) | n/a |
4348
<!-- vale on -->
4449
<!-- markdownlint-enable -->
4550
<!-- END_TF_DOCS -->

infrastructure/terraform/components/sandbox/locals.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,15 @@ locals {
22
mock_letter_supplier_name = "WTMMOCK"
33

44
use_sftp_letter_supplier_mock = lookup(var.letter_suppliers, local.mock_letter_supplier_name, null) != null
5+
6+
sandbox_letter_supplier_mock_recipient = "template-submitted-recipient-${var.environment}@sandbox.${local.acct.dns_zone["name"]}"
7+
8+
letter_suppliers = local.use_sftp_letter_supplier_mock ? merge(
9+
var.letter_suppliers,
10+
{ WTMMOCK = {
11+
email_addresses = concat(var.letter_suppliers.WTMMOCK.email_addresses, [local.sandbox_letter_supplier_mock_recipient])
12+
enable_polling = true
13+
default_supplier = true
14+
}}
15+
) : var.letter_suppliers
516
}

infrastructure/terraform/components/sandbox/locals_tfscaffold.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,26 @@ locals {
2727
Name = local.csi
2828
},
2929
)
30+
31+
acct_csi = replace(
32+
format(
33+
"%s-%s-acct",
34+
var.project,
35+
var.parent_acct_environment,
36+
),
37+
"_",
38+
"",
39+
)
40+
41+
acct_global_csi = replace(
42+
format(
43+
"%s-%s-%s-%s-acct",
44+
var.project,
45+
var.aws_account_id,
46+
var.region,
47+
var.parent_acct_environment,
48+
),
49+
"_",
50+
"",
51+
)
3052
}

infrastructure/terraform/components/sandbox/module_backend_api.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module "backend_api" {
1818
}
1919

2020
enable_proofing = true
21-
letter_suppliers = var.letter_suppliers
21+
letter_suppliers = local.letter_suppliers
2222

2323
kms_key_arn = data.aws_kms_key.sandbox.arn
2424

@@ -29,5 +29,5 @@ module "backend_api" {
2929
email_domain = "sandbox.${local.acct.dns_zone["name"]}"
3030

3131
mock_letter_supplier_name = local.mock_letter_supplier_name
32-
use_sftp_letter_supplier_mock = lookup(var.letter_suppliers, local.mock_letter_supplier_name, null) != null
32+
use_sftp_letter_supplier_mock = local.use_sftp_letter_supplier_mock
3333
}

infrastructure/terraform/components/sandbox/outputs.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,10 @@ output "quarantine_bucket_name" {
4242
value = module.backend_api.quarantine_bucket_name
4343
}
4444

45+
output "test_email_bucket_name" {
46+
value = "${local.acct_global_csi}-ses"
47+
}
48+
49+
output "test_email_prefix" {
50+
value = "emails-${var.environment}"
51+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "aws_ses_receipt_rule" "main" {
2+
name = "${local.csi}-store-email-sandbox"
3+
rule_set_name = local.acct_csi
4+
recipients = [local.sandbox_letter_supplier_mock_recipient]
5+
enabled = true
6+
scan_enabled = true
7+
tls_policy = "Optional"
8+
9+
s3_action {
10+
position = 1
11+
bucket_name = "${local.acct_global_csi}-ses"
12+
object_key_prefix = "emails-${var.environment}/"
13+
iam_role_arn = "arn:aws:iam::${var.aws_account_id}:role/${local.acct_csi}-ses-receipts"
14+
}
15+
}

infrastructure/terraform/components/sandbox/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ variable "letter_suppliers" {
7272

7373
default = {
7474
"WTMMOCK" = {
75-
email_addresses = ["template-submitted-recipient@sandbox.templates.dev.nhsnotify.national.nhs.uk"]
75+
email_addresses = []
7676
enable_polling = true
7777
default_supplier = true
7878
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = "~> 5.50"
6+
}
7+
}
8+
9+
required_version = ">= 1.9.0"
10+
}

infrastructure/terraform/modules/ses/ses_receipt_rule_set.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ resource "aws_ses_receipt_rule" "store_email" {
99

1010
name = "${local.csi}-store-email"
1111
rule_set_name = aws_ses_receipt_rule_set.main.0.rule_set_name
12-
recipients = [aws_ses_domain_identity.main.domain]
12+
recipients = ["template-submitted-recipient@${aws_ses_domain_identity.main.domain}"]
1313
enabled = true
1414
scan_enabled = true
1515
tls_policy = "Optional"

lambdas/backend-api/src/templates/infra/email-template.html

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,6 @@
33
<head>
44
<meta charset="UTF-8" />
55
<title>Letter Proof Approval</title>
6-
7-
@media all {
8-
@font-face {
9-
font-display: swap;
10-
font-family: "Frutiger W01";
11-
font-style: normal;
12-
font-weight: 400;
13-
src: url(https://assets.nhs.uk/fonts/FrutigerLTW01-55Roman.eot?#iefix);
14-
src: url(https://assets.nhs.uk/fonts/FrutigerLTW01-55Roman.eot?#iefix) format("eot"),
15-
url(https://assets.nhs.uk/fonts/FrutigerLTW01-55Roman.woff2) format("woff2"),
16-
url(https://assets.nhs.uk/fonts/FrutigerLTW01-55Roman.woff) format("woff"),
17-
url(https://assets.nhs.uk/fonts/FrutigerLTW01-55Roman.ttf) format("truetype"),
18-
url(https://assets.nhs.uk/fonts/FrutigerLTW01-55Roman.svg#7def0e34-f28d-434f-b2ec-472bde847115) format("svg")
19-
}
20-
}
216
</head>
227
<body style="font-family: Frutiger W01, sans-serif; font-size: 14px">
238
<p>For the attention of {{supplier}}.</p>

0 commit comments

Comments
 (0)