Skip to content

Commit ef0979c

Browse files
committed
Merge branch 'main' into feature/CCM-9874-dl-edge-auth
2 parents 493e9ad + 29f7743 commit ef0979c

File tree

57 files changed

+695
-811
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+695
-811
lines changed

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ vale 3.6.0
1212
# The section below is reserved for Docker image versions.
1313

1414
# TODO: Move this section - consider using a different file for the repository template dependencies.
15-
# docker/ghcr.io/anchore/grype v0.69.1@sha256:d41fcb371d0af59f311e72123dff46900ebd6d0482391b5a830853ee4f9d1a76 # SEE: https://github.com/anchore/grype/pkgs/container/grype
16-
# docker/ghcr.io/anchore/syft v0.92.0@sha256:63c60f0a21efb13e80aa1359ab243e49213b6cc2d7e0f8179da38e6913b997e0 # SEE: https://github.com/anchore/syft/pkgs/container/syft
15+
# docker/ghcr.io/anchore/grype v0.92.2@sha256:651e558f9ba84f2a790b3449c8a57cbbf4f34e004f7d3f14ae8f8cbeede4cd33 # SEE: https://github.com/anchore/grype/pkgs/container/grype
16+
# docker/ghcr.io/anchore/syft v1.26.0@sha256:de078f51704a213906970b1475edd6006b8af50aa159852e125518237487b8c6 # SEE: https://github.com/anchore/syft/pkgs/container/syft
1717
# docker/ghcr.io/gitleaks/gitleaks v8.24.0@sha256:2bcceac45179b3a91bff11a824d0fb952585b429e54fc928728b1d4d5c3e5176 # SEE: https://github.com/gitleaks/gitleaks/pkgs/container/gitleaks
1818
# docker/ghcr.io/igorshubovych/markdownlint-cli v0.37.0@sha256:fb3e79946fce78e1cde84d6798c6c2a55f2de11fc16606a40d49411e281d950d # SEE: https://github.com/igorshubovych/markdownlint-cli/pkgs/container/markdownlint-cli
1919
# docker/ghcr.io/make-ops-tools/gocloc latest@sha256:6888e62e9ae693c4ebcfed9f1d86c70fd083868acb8815fe44b561b9a73b5032 # SEE: https://github.com/make-ops-tools/gocloc/pkgs/container/gocloc

infrastructure/terraform/components/acct/module_obs_datasource.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ module "obs_datasource" {
99
environment = var.environment
1010
component = var.component
1111

12-
oam_sink_id = var.oam_sink_id
13-
observability_account_id = var.observability_account_id
12+
oam_sink_id = var.oam_sink_id
13+
observability_account_id = var.observability_account_id
1414
}

infrastructure/terraform/components/acct/module_sandbox_kms.tf

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,45 @@ module "kms_sandbox" {
1313
deletion_window = var.kms_deletion_window
1414
alias = "alias/${local.csi}-sandbox"
1515
iam_delegation = true
16+
17+
key_policy_documents = [data.aws_iam_policy_document.kms.json]
18+
}
19+
20+
data "aws_iam_policy_document" "kms" {
21+
# '*' resource scope is permitted in access policies as as the resource is itself
22+
# https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-services.html
23+
24+
statement {
25+
sid = "AllowCloudWatchEncrypt"
26+
effect = "Allow"
27+
28+
principals {
29+
type = "Service"
30+
31+
identifiers = [
32+
"logs.${var.region}.amazonaws.com",
33+
]
34+
}
35+
36+
actions = [
37+
"kms:Encrypt*",
38+
"kms:Decrypt*",
39+
"kms:ReEncrypt*",
40+
"kms:GenerateDataKey*",
41+
"kms:Describe*"
42+
]
43+
44+
resources = [
45+
"*",
46+
]
47+
48+
condition {
49+
test = "ArnLike"
50+
variable = "kms:EncryptionContext:aws:logs:arn"
51+
52+
values = [
53+
"arn:aws:logs:${var.region}:${var.aws_account_id}:log-group:*",
54+
]
55+
}
56+
}
1657
}

infrastructure/terraform/components/acct/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ output "github_pat_ssm_param_name" {
1212

1313
output "s3_buckets" {
1414
value = {
15+
access_logs = {
16+
arn = module.s3bucket_access_logs.arn
17+
bucket = module.s3bucket_access_logs.bucket
18+
id = module.s3bucket_access_logs.id
19+
}
1520
artefacts = {
1621
arn = module.s3bucket_artefacts.arn
1722
bucket = module.s3bucket_artefacts.bucket

infrastructure/terraform/components/app/module_backend_api.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ module "backend_api" {
1313
log_retention_in_days = var.log_retention_in_days
1414
kms_key_arn = module.kms.key_arn
1515
parent_acct_environment = var.parent_acct_environment
16+
function_s3_bucket = local.acct.s3_buckets["artefacts"]["id"]
1617

1718
cloudfront_distribution_arn = aws_cloudfront_distribution.main.arn
1819

1920
cognito_config = jsondecode(aws_ssm_parameter.cognito_config.value)
2021

2122
enable_backup = var.destination_vault_arn != null ? true : false
2223

23-
enable_letters = var.enable_letters
24-
enable_proofing = var.enable_proofing
25-
letter_suppliers = var.letter_suppliers
26-
log_destination_arn = "arn:aws:logs:${var.region}:${var.observability_account_id}:destination:nhs-notify-main-acct-firehose-logs"
27-
log_subscription_role_arn = local.acct.log_subscription_role_arn
24+
enable_letters = var.enable_letters
25+
enable_proofing = var.enable_proofing
26+
letter_suppliers = var.letter_suppliers
27+
log_destination_arn = "arn:aws:logs:${var.region}:${var.observability_account_id}:destination:nhs-notify-main-acct-firehose-logs"
28+
log_subscription_role_arn = local.acct.log_subscription_role_arn
2829

30+
send_to_firehose = true
2931
}

infrastructure/terraform/components/sandbox/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ No requirements.
1717
| <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 |
1818
| <a name="input_letter_suppliers"></a> [letter\_suppliers](#input\_letter\_suppliers) | Letter suppliers enabled in the environment | <pre>map(object({<br/> enable_polling = bool<br/> default_supplier = optional(bool)<br/> }))</pre> | <pre>{<br/> "WTMMOCK": {<br/> "default_supplier": true,<br/> "enable_polling": true<br/> }<br/>}</pre> | no |
1919
| <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 |
20+
| <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 |
2021
| <a name="input_project"></a> [project](#input\_project) | The name of the tfscaffold project | `string` | n/a | yes |
2122
| <a name="input_region"></a> [region](#input\_region) | The AWS Region | `string` | n/a | yes |
2223
## Modules
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
locals {
2+
acct = data.terraform_remote_state.acct.outputs
3+
}
4+
5+
data "terraform_remote_state" "acct" {
6+
backend = "s3"
7+
8+
config = {
9+
bucket = local.terraform_state_bucket
10+
11+
key = format(
12+
"%s/%s/%s/%s/acct.tfstate",
13+
var.project,
14+
var.aws_account_id,
15+
"eu-west-2",
16+
var.parent_acct_environment
17+
)
18+
19+
region = "eu-west-2"
20+
}
21+
}

infrastructure/terraform/components/sandbox/locals_tfscaffold.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
locals {
2+
terraform_state_bucket = format(
3+
"%s-tfscaffold-%s-%s",
4+
var.project,
5+
var.aws_account_id,
6+
var.region,
7+
)
8+
29
csi = replace(
310
format(
411
"%s-%s-%s",

infrastructure/terraform/components/sandbox/module_backend_api.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ module "backend_api" {
99
group = var.group
1010
csi = local.csi
1111
log_retention_in_days = var.log_retention_in_days
12-
parent_acct_environment = "main"
12+
parent_acct_environment = var.parent_acct_environment
13+
function_s3_bucket = local.acct.s3_buckets["artefacts"]["id"]
1314

1415
cognito_config = {
1516
USER_POOL_ID = aws_cognito_user_pool.sandbox.id
@@ -22,4 +23,6 @@ module "backend_api" {
2223

2324
kms_key_arn = data.aws_kms_key.sandbox.arn
2425
dynamodb_kms_key_arn = data.aws_kms_key.sandbox.arn
26+
27+
send_to_firehose = false
2528
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
if [ -z "$SKIP_SANDBOX_INSTALL" ]; then npm ci --omit=dev; fi
22

33
npm run generate-dependencies --workspaces --if-present
4+
5+
npm run lambda-build --workspaces --if-present

0 commit comments

Comments
 (0)