Skip to content

Commit a6ff559

Browse files
committed
Merge branch 'feature/CCM-9037_internal-bucket' into feature/CCM-8572_template-security-scan
2 parents 9b3acd1 + 29575f5 commit a6ff559

24 files changed

+129
-65
lines changed

.github/actions/normalize-branch-name/action.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ name: "Normalize branch name"
22
description: "Normalize branch name"
33
outputs:
44
normalized_branch_name:
5+
description: 10 character branch identifier (0000-branch)
56
value: ${{ steps.normalize_branch_name.outputs.normalized_branch_name }}
67
runs:
78
using: "composite"
89
steps:
910
- id: normalize_branch_name
1011
shell: bash
11-
run: echo "normalized_branch_name=$(sed -e 's/[^a-zA-Z0-9-]//g' <<< $(git rev-parse --abbrev-ref HEAD) | tr '[:upper:]' '[:lower:]' | head -c 25)" >> $GITHUB_OUTPUT
12-
12+
run: |
13+
branch=$(git rev-parse --abbrev-ref HEAD)
14+
stripped=$(echo $branch | sed -e 's/[^a-zA-Z0-9-]//g' | tr '[:upper:]' '[:lower:]')
15+
starting_from_jira_ref=$(echo $stripped | sed -n 's/.*\([0-9]\{4,\}.*\)/\1/p')
16+
with_fallback=${starting_from_jira_ref:-$stripped}
17+
chopped=$(echo $with_fallback | head -c 10)
18+
echo "normalized_branch_name=$chopped" >> $GITHUB_OUTPUT

infrastructure/terraform/components/acct/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@
1818
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
1919
| <a name="input_group"></a> [group](#input\_group) | The group variables are being inherited from (often synonmous with account short-name) | `string` | n/a | yes |
2020
| <a name="input_initial_cli_secrets_provision_override"></a> [initial\_cli\_secrets\_provision\_override](#input\_initial\_cli\_secrets\_provision\_override) | A map of default value to intialise SSM secret values with. Only useful for initial setup of the account due to lifecycle rules. | `map(string)` | `{}` | no |
21+
| <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 |
2122
| <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 |
2223
| <a name="input_project"></a> [project](#input\_project) | The name of the tfscaffold project | `string` | n/a | yes |
2324
| <a name="input_region"></a> [region](#input\_region) | The AWS Region | `string` | n/a | yes |
2425
| <a name="input_root_domain_name"></a> [root\_domain\_name](#input\_root\_domain\_name) | The service's root DNS root nameespace, like nonprod.nhsnotify.national.nhs.uk | `string` | `"nonprod.nhsnotify.national.nhs.uk"` | no |
26+
| <a name="input_support_sandbox_environments"></a> [support\_sandbox\_environments](#input\_support\_sandbox\_environments) | Does this account support dev sandbox environments? | `bool` | `false` | no |
2527
## Modules
2628

2729
| Name | Source | Version |
2830
|------|--------|---------|
31+
| <a name="module_kms_sandbox"></a> [kms\_sandbox](#module\_kms\_sandbox) | git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/kms | v1.0.8 |
2932
| <a name="module_s3bucket_access_logs"></a> [s3bucket\_access\_logs](#module\_s3bucket\_access\_logs) | git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/s3bucket | v1.0.8 |
3033
| <a name="module_s3bucket_backup_reports"></a> [s3bucket\_backup\_reports](#module\_s3bucket\_backup\_reports) | git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/s3bucket | v1.0.8 |
3134
## Outputs

infrastructure/terraform/components/acct/module_s3bucket_access_logs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ data "aws_iam_policy_document" "s3bucket_access_logs" {
9292
]
9393

9494
resources = [
95-
module.s3bucket_lambda_artefacts.arn,
95+
module.s3bucket_access_logs.arn,
9696
]
9797

9898
principals {
@@ -112,7 +112,7 @@ data "aws_iam_policy_document" "s3bucket_access_logs" {
112112
]
113113

114114
resources = [
115-
"${module.s3bucket_lambda_artefacts.arn}/*",
115+
"${module.s3bucket_access_logs.arn}/*",
116116
]
117117

118118
principals {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module "kms_sandbox" {
2+
source = "git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/kms?ref=v1.0.8"
3+
4+
count = var.support_sandbox_environments ? 1 : 0
5+
6+
aws_account_id = var.aws_account_id
7+
component = var.component
8+
environment = var.environment
9+
project = var.project
10+
region = var.region
11+
12+
name = "sandbox"
13+
deletion_window = var.kms_deletion_window
14+
alias = "alias/${local.csi}-sandbox"
15+
}

infrastructure/terraform/components/acct/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,15 @@ variable "initial_cli_secrets_provision_override" {
7070
# Usage like:
7171
# ... -a apply -- -var initial_cli_secrets_provision_override={\"github_pat\":\"l0ngstr1ng"}
7272
}
73+
74+
variable "kms_deletion_window" {
75+
type = string
76+
description = "When a kms key is deleted, how long should it wait in the pending deletion state?"
77+
default = "30"
78+
}
79+
80+
variable "support_sandbox_environments" {
81+
type = bool
82+
description = "Does this account support dev sandbox environments?"
83+
default = false
84+
}

infrastructure/terraform/components/app/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
| <a name="input_event_delivery_logging_success_sample_percentage"></a> [event\_delivery\_logging\_success\_sample\_percentage](#input\_event\_delivery\_logging\_success\_sample\_percentage) | Enable caching of events to an S3 bucket | `number` | `0` | no |
3737
| <a name="input_group"></a> [group](#input\_group) | The group variables are being inherited from (often synonmous with account short-name) | `string` | n/a | yes |
3838
| <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 |
39+
| <a name="input_kms_key_arn"></a> [kms\_key\_arn](#input\_kms\_key\_arn) | ARN of KMS Key used for encrypting application data | `string` | n/a | yes |
3940
| <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 |
4041
| <a name="input_observability_account_id"></a> [observability\_account\_id](#input\_observability\_account\_id) | The Observability Account ID that needs access | `string` | n/a | yes |
4142
| <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 |

infrastructure/terraform/components/app/module_backend_api.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ module "backend_api" {
1717
enable_backup = var.destination_vault_arn != null ? true : false
1818

1919
enable_letters = var.enable_letters
20+
2021
}

infrastructure/terraform/components/sandbox/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ No requirements.
1414
| <a name="input_default_tags"></a> [default\_tags](#input\_default\_tags) | A map of default tags to apply to all taggable resources within the component | `map(string)` | `{}` | no |
1515
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
1616
| <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 |
17+
| <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 |
1718
| <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 |
1819
| <a name="input_project"></a> [project](#input\_project) | The name of the tfscaffold project | `string` | n/a | yes |
1920
| <a name="input_region"></a> [region](#input\_region) | The AWS Region | `string` | n/a | yes |
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data "aws_kms_key" "sandbox" {
2+
key_id = "alias/${var.project}-main-acct-sandbox"
3+
}

infrastructure/terraform/components/sandbox/module_backend_api.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ module "backend_api" {
66
aws_account_id = var.aws_account_id
77
region = var.region
88
group = var.group
9+
component = var.component
910
csi = local.csi
1011
log_retention_in_days = var.log_retention_in_days
11-
kms_key_arn = module.kms.key_arn
1212

1313
cognito_config = {
1414
USER_POOL_ID = aws_cognito_user_pool.sandbox.id
1515
USER_POOL_CLIENT_ID = aws_cognito_user_pool_client.sandbox.id
1616
}
1717

1818
enable_letters = true
19+
20+
kms_key_arn = data.aws_kms_key.sandbox.arn
21+
dynamodb_kms_key_arn = data.aws_kms_key.sandbox.arn
1922
}

0 commit comments

Comments
 (0)