Skip to content

Commit af6a693

Browse files
committed
Merge branch 'main' into feature/CCM-11192_test_data
2 parents 19f3540 + f7c03eb commit af6a693

File tree

38 files changed

+1005
-147
lines changed

38 files changed

+1005
-147
lines changed

.github/actions/build-proxies/action.yml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: "Build Proxies"
22
description: "Build Proxies"
3+
34
inputs:
45
version:
56
description: "Version number"
67
required: true
8+
79
runs:
810
using: composite
911

@@ -19,7 +21,6 @@ runs:
1921
run: npm ci
2022
shell: bash
2123

22-
2324
- name: Setup Proxy Name and target
2425
shell: bash
2526
run: |
@@ -35,10 +36,8 @@ runs:
3536
echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
3637
echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
3738
echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
38-
3939
fi
4040
41-
4241
- name: Install Proxygen client
4342
shell: bash
4443
run: |
@@ -54,29 +53,6 @@ runs:
5453
envsubst < ./.github/proxygen-settings.yaml > ${HOME}/.proxygen/settings.yaml
5554
envsubst < ./.github/proxygen-settings.yaml | cat
5655
57-
58-
- name: Build internal dev oas
59-
working-directory: .
60-
shell: bash
61-
run: |
62-
if [ -z $PR_NUMBER ]
63-
then
64-
make build-json-oas-spec APIM_ENV=internal-dev
65-
else
66-
make build-json-oas-spec APIM_ENV=internal-dev-pr
67-
fi
68-
69-
- name: Set target and cert
70-
shell: bash
71-
run: |
72-
jq --arg newurl "$TARGET" '.["x-nhsd-apim"].target.url = $newurl' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json
73-
jq --arg newmtls "$MTLS_NAME" '.["x-nhsd-apim"].target.security.secret = $newmtls' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json
74-
75-
- name: Deploy to Internal Dev
76-
shell: bash
77-
run: |
78-
proxygen instance deploy internal-dev $INSTANCE build/notify-supplier.json --no-confirm
79-
8056
- name: Build sandbox oas
8157
working-directory: .
8258
shell: bash
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Deploy proxy to internal-dev
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
deploy-internal-dev:
11+
runs-on: ubuntu-latest
12+
name: Deploy to Internal Dev
13+
env:
14+
PROXYGEN_PRIVATE_KEY: ${{ secrets.PROXYGEN_ENCODED_NOTIFY_SUPPLIER_PRIVATE_KEY }}
15+
PROXYGEN_KID: notify-supplier-key-1
16+
PROXYGEN_CLIENT_ID: nhs-notify-supplier-client
17+
PROXYGEN_API_NAME: nhs-notify-supplier
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: 24
25+
26+
- name: Npm install
27+
working-directory: .
28+
run: npm ci
29+
shell: bash
30+
31+
- name: "Check if pull request exists for this branch"
32+
id: pr_exists
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
run: |
36+
branch_name=${GITHUB_HEAD_REF:-$(echo $GITHUB_REF | sed 's#refs/heads/##')}
37+
echo "Current branch is '$branch_name'"
38+
39+
pr_json=$(gh pr list --head "$branch_name" --state open --json number --limit 1)
40+
pr_number=$(echo "$pr_json" | jq -r '.[0].number // empty')
41+
42+
if [[ -n "$pr_number" ]]; then
43+
echo "Pull request exists: #$pr_number"
44+
echo "does_pull_request_exist=true" >> $GITHUB_OUTPUT
45+
echo "pr_number=$pr_number" >> $GITHUB_OUTPUT
46+
else
47+
echo "Pull request doesn't exist"
48+
echo "does_pull_request_exist=false" >> $GITHUB_OUTPUT
49+
echo "pr_number=" >> $GITHUB_OUTPUT
50+
fi
51+
52+
- name: Setup Proxy Name and target
53+
shell: bash
54+
env:
55+
PR_NUMBER: ${{ steps.pr_exists.outputs.pr_number }}
56+
run: |
57+
if [ -z $PR_NUMBER ]
58+
then
59+
echo "INSTANCE=$PROXYGEN_API_NAME" >> $GITHUB_ENV
60+
echo "TARGET=https://main.suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
61+
echo "SANDBOX_TAG=latest" >> $GITHUB_ENV
62+
echo "MTLS_NAME=notify-supplier-mtls" >> $GITHUB_ENV
63+
else
64+
echo "TARGET=https://pr$PR_NUMBER.suppliers.dev.nhsnotify.national.nhs.uk" >> $GITHUB_ENV
65+
echo "INSTANCE=$PROXYGEN_API_NAME-PR-$PR_NUMBER" >> $GITHUB_ENV
66+
echo "SANDBOX_TAG=pr$PR_NUMBER" >> $GITHUB_ENV
67+
echo "MTLS_NAME=notify-supplier-mtls-pr$PR_NUMBER" >> $GITHUB_ENV
68+
fi
69+
70+
- name: Install Proxygen client
71+
shell: bash
72+
run: |
73+
# Install proxygen cli
74+
pip install pipx
75+
pipx install proxygen-cli
76+
77+
# Setup proxygen auth and settings
78+
mkdir -p ${HOME}/.proxygen
79+
echo -n $PROXYGEN_PRIVATE_KEY | base64 --decode > ${HOME}/.proxygen/key
80+
envsubst < ./.github/proxygen-credentials-template.yaml > ${HOME}/.proxygen/credentials.yaml
81+
envsubst < ./.github/proxygen-credentials-template.yaml | cat
82+
envsubst < ./.github/proxygen-settings.yaml > ${HOME}/.proxygen/settings.yaml
83+
envsubst < ./.github/proxygen-settings.yaml | cat
84+
85+
- name: Build internal dev oas
86+
working-directory: .
87+
shell: bash
88+
env:
89+
PR_NUMBER: ${{ steps.pr_exists.outputs.pr_number }}
90+
run: |
91+
if [ -z $PR_NUMBER ]
92+
then
93+
make build-json-oas-spec APIM_ENV=internal-dev
94+
else
95+
make build-json-oas-spec APIM_ENV=internal-dev-pr
96+
fi
97+
98+
- name: Set target and cert
99+
shell: bash
100+
run: |
101+
jq --arg newurl "$TARGET" '.["x-nhsd-apim"].target.url = $newurl' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json
102+
jq --arg newmtls "$MTLS_NAME" '.["x-nhsd-apim"].target.security.secret = $newmtls' build/notify-supplier.json > build/notify-supplier_target.json && mv build/notify-supplier_target.json build/notify-supplier.json
103+
104+
- name: Deploy to Internal Dev
105+
shell: bash
106+
run: |
107+
proxygen instance deploy internal-dev $INSTANCE build/notify-supplier.json --no-confirm

.github/workflows/stage-1-commit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ jobs:
149149
trivy:
150150
name: "Trivy Scan"
151151
runs-on: ubuntu-latest
152-
timeout-minutes: 5
152+
timeout-minutes: 10
153153
needs: detect-terraform-changes
154154
if: needs.detect-terraform-changes.outputs.terraform_changed == 'true'
155155
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ version.json
1212

1313
# Please, add your custom content below!
1414
.idea
15+
.env
1516

1617
# dependencies
1718
node_modules

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
//".devcontainer": true,
1212
".github": false,
1313
".vscode": false
14-
}
14+
},
1515
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ If packages are unavailable the latest SDKs can be downloaded directly from:
6868

6969
### Examples
7070

71-
TODO: Links to example clients.
71+
TODO:CCM-11209 Links to example clients.
7272

7373
## API Developers
7474

@@ -106,7 +106,7 @@ should understand the below.
106106
##### Servers
107107

108108
- Servers folder is being built at build time from OAS specs.
109-
- TODO: Build actual servers
109+
- TODO:CCM-12139 Build actual servers
110110

111111
##### Libs
112112

infrastructure/terraform/components/api/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ No requirements.
1919
| <a name="input_force_lambda_code_deploy"></a> [force\_lambda\_code\_deploy](#input\_force\_lambda\_code\_deploy) | If the lambda package in s3 has the same commit id tag as the terraform build branch, the lambda will not update automatically. Set to True if making changes to Lambda code from on the same commit for example during development | `bool` | `false` | no |
2020
| <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 |
2121
| <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 |
22+
| <a name="input_letter_table_ttl_hours"></a> [letter\_table\_ttl\_hours](#input\_letter\_table\_ttl\_hours) | Number of hours to set as TTL on letters table | `number` | `24` | no |
2223
| <a name="input_log_level"></a> [log\_level](#input\_log\_level) | The log level to be used in lambda functions within the component. Any log with a lower severity than the configured value will not be logged: https://docs.python.org/3/library/logging.html#levels | `string` | `"INFO"` | no |
2324
| <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 |
2425
| <a name="input_manually_configure_mtls_truststore"></a> [manually\_configure\_mtls\_truststore](#input\_manually\_configure\_mtls\_truststore) | Manually manage the truststore used for API Gateway mTLS (e.g. for prod environment) | `bool` | `false` | no |
26+
| <a name="input_max_get_limit"></a> [max\_get\_limit](#input\_max\_get\_limit) | Default limit to apply to GET requests that support pagination | `number` | `2500` | no |
2527
| <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 |
2628
| <a name="input_project"></a> [project](#input\_project) | The name of the tfscaffold project | `string` | n/a | yes |
2729
| <a name="input_region"></a> [region](#input\_region) | The AWS Region | `string` | n/a | yes |

infrastructure/terraform/components/api/ddb_table_letters.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ resource "aws_dynamodb_table" "letters" {
1313
global_secondary_index {
1414
name = "supplierStatus-index"
1515
hash_key = "supplierStatus"
16-
range_key = "id"
16+
range_key = "supplierStatusSk"
1717
projection_type = "ALL"
1818
}
1919

@@ -32,6 +32,11 @@ resource "aws_dynamodb_table" "letters" {
3232
type = "S"
3333
}
3434

35+
attribute {
36+
name = "supplierStatusSk"
37+
type = "S"
38+
}
39+
3540
point_in_time_recovery {
3641
enabled = true
3742
}

infrastructure/terraform/components/api/module_lambda_get_letters.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ module "get_letters" {
3737

3838
lambda_env_vars = {
3939
LETTERS_TABLE_NAME = aws_dynamodb_table.letters.name,
40-
LETTER_TTL_HOURS = 24
40+
LETTER_TTL_HOURS = var.letter_table_ttl_hours,
41+
MAX_LIMIT = var.max_get_limit,
4142
}
4243
}
4344

@@ -69,6 +70,7 @@ data "aws_iam_policy_document" "get_letters_lambda" {
6970

7071
resources = [
7172
aws_dynamodb_table.letters.arn,
73+
"${aws_dynamodb_table.letters.arn}/index/supplierStatus-index"
7274
]
7375
}
7476
}

infrastructure/terraform/components/api/variables.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ variable "enable_backups" {
9999
default = false
100100
}
101101

102-
103102
variable "ca_pem_filename" {
104103
type = string
105104
description = "Filename for the CA truststore file within the s3 bucket"
@@ -111,3 +110,15 @@ variable "force_destroy" {
111110
description = "Flag to force deletion of S3 buckets"
112111
default = false
113112
}
113+
114+
variable "letter_table_ttl_hours" {
115+
type = number
116+
description = "Number of hours to set as TTL on letters table"
117+
default = 24
118+
}
119+
120+
variable "max_get_limit" {
121+
type = number
122+
description = "Default limit to apply to GET requests that support pagination"
123+
default = 2500
124+
}

0 commit comments

Comments
 (0)