generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
CCM-14149: Letter Preview Placeholder #832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jamesthompson26-nhs
wants to merge
50
commits into
main
Choose a base branch
from
feature/CCM-14149_Letter_Preview_Placeholder
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+459
−129
Draft
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
d2333ff
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs dbc8abb
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 709fed1
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 277bf45
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs a0da312
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs bf7c298
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 8353e57
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs b470d2c
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs e095e52
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs ffbf635
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 87653c1
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 9e52454
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 48f09a8
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 1ded16f
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs e639309
CCM-14149: Template Management Support Container Builds
jamesthompson26-nhs db75d60
CCM-14149: Template Management Support Container Builds
jamesthompson26-nhs d54ee79
CCM-14149: Template Management Support Container Builds
jamesthompson26-nhs 4d7aa81
CCM-14149: Template Management Support Container Builds
jamesthompson26-nhs aa112d1
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs fc1e972
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 7797341
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 14a80d7
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs b072c65
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 423baec
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs c58ab93
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs a549f4f
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 9e1f13c
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 160c889
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 23b4e8f
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs c6945f2
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 39f9182
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs e413d8d
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs c1c1863
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 3770177
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 7c75363
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 910f74b
CCM-14149: Template Management Support Container Builds
jamesthompson26-nhs c90ae61
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs c3f5ff4
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs c962056
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 95c0972
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 32b1939
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs b71925b
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 9862588
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 5e2d5a3
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 885e4eb
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs a2ba852
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 9ccbb67
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 1e829d9
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 881439a
CCM-14149: Letter Preview Placeholder
jamesthompson26-nhs 9f5b224
CCM-14149: Rename Letter Renderer to Libreoffice
jamesthompson26-nhs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
infrastructure/terraform/components/app/module_letter_preview_renderer_lambda.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| module "letter_preview_renderer_lambda" { | ||
| source = "git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/lambda?ref=feature/CCM-14149_Support_Container_Based_Lambdas" | ||
|
|
||
| project = var.project | ||
| environment = var.environment | ||
| component = var.component | ||
| aws_account_id = var.aws_account_id | ||
| region = var.region | ||
| group = var.group | ||
|
|
||
| function_name = "letter-preview-renderer" | ||
| description = "Letter preview renderer Lambda" | ||
|
|
||
| kms_key_arn = module.kms.key_arn | ||
|
|
||
| package_type = "Image" | ||
| image_uri = "${var.aws_account_id}.dkr.ecr.${var.region}.amazonaws.com/${var.container_lambda_ecr_repo}:${var.project}-${var.environment}-${var.component}-letter-preview-renderer-${var.image_tag_suffix}" | ||
| image_repository_names = [var.container_lambda_ecr_repo] | ||
|
|
||
| memory = 1024 | ||
| timeout = 30 | ||
|
|
||
| log_retention_in_days = var.log_retention_in_days | ||
|
|
||
| log_destination_arn = local.log_destination_arn | ||
| log_subscription_role_arn = local.acct.log_subscription_role_arn | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| dist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| coverage | ||
| node_modules | ||
| dist | ||
| .reports |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { handler } from '../index'; | ||
| import type { Context } from 'aws-lambda'; | ||
| import { mockDeep } from 'jest-mock-extended'; | ||
|
|
||
| describe('event-logging Lambda', () => { | ||
| it('logs the input event and returns 200', async () => { | ||
| const event = { foo: 'bar' }; | ||
| const context = mockDeep<Context>(); | ||
| const callback = jest.fn(); | ||
| const result = await handler(event, context, callback); | ||
|
|
||
| expect(result).toEqual({ | ||
| statusCode: 200, | ||
| body: 'Event logged', | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| rm -rf dist | ||
|
|
||
| npx esbuild \ | ||
| --bundle \ | ||
| --minify \ | ||
| --sourcemap \ | ||
| --target=es2020 \ | ||
| --platform=node \ | ||
| --loader:.node=file \ | ||
| --entry-names=[name] \ | ||
| --outdir=dist \ | ||
| src/index.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Fail fast on errors, unset variables, and pipeline failures. | ||
| set -euo pipefail | ||
|
|
||
| # Ensure build.sh is executable and build the lambda artifacts before producing the Docker image. | ||
| chmod +x ./build.sh | ||
| ./build.sh | ||
|
|
||
| # Set Variables required for Docker Build. TF_REGION and TF_ENVIRONMENT are set in pre.sh and exported for use here. COMPONENT is passed in the reusable workflow. | ||
| BASE_IMAGE="$1" | ||
| CSI="${project}-${environment}-${component_name}" | ||
| ECR_REPO="${ECR_REPO:-nhs-notify-main-acct}" | ||
| GHCR_LOGIN_TOKEN="${GITHUB_TOKEN}" | ||
| GHCR_LOGIN_USER="${GITHUB_ACTOR}" | ||
| IMAGE_TAG_SUFFIX="${TF_VAR_image_tag_suffix}" | ||
| LAMBDA_NAME="${LAMBDA_NAME:-$(basename "$(cd "$(dirname "$0")" && pwd)")}" | ||
|
|
||
| # Ensure required AWS/ECR configuration is present. | ||
| echo "BASE_IMAGE: ${BASE_IMAGE:-<unset>}" | ||
| echo "aws_account_id: ${aws_account_id:-<unset>}" | ||
| echo "aws_region: ${region:-<unset>}" | ||
| echo "component_name: ${component_name:-<unset>}" | ||
| echo "CSI: ${CSI:-<unset>}" | ||
| echo "ECR_REPO: ${ECR_REPO:-<unset>}" | ||
| echo "environment: ${environment:-<unset>}" | ||
| echo "GHCR_LOGIN_TOKEN: ${GHCR_LOGIN_TOKEN:-<unset>}" | ||
| echo "GHCR_LOGIN_USER: ${GHCR_LOGIN_USER:-<unset>}" | ||
| echo "IMAGE_TAG_SUFFIX: ${IMAGE_TAG_SUFFIX:-<unset>}" | ||
| echo "LAMBDA_NAME: ${LAMBDA_NAME:-<unset>}" | ||
|
|
||
| # Authenticate Docker with AWS ECR using an ephemeral login token. | ||
| aws ecr get-login-password --region "${region}" | docker login --username AWS --password-stdin "${aws_account_id}".dkr.ecr."${region}".amazonaws.com | ||
|
|
||
| # Optionally authenticate to GitHub Container Registry for base images. | ||
| if [ -n "${GHCR_LOGIN_USER:-}" ] && [ -n "${GHCR_LOGIN_TOKEN:-}" ]; then | ||
| echo "Attempting GHCR login as ${GHCR_LOGIN_USER}..." | ||
| if echo "${GHCR_LOGIN_TOKEN}" | docker login ghcr.io --username "${GHCR_LOGIN_USER}" --password-stdin; then | ||
| echo "GHCR login successful." | ||
| else | ||
| echo "GHCR login failed!" >&2 | ||
| fi | ||
| fi | ||
|
|
||
| # Namespace tag by CSI and lambda name to avoid cross-environment collisions. | ||
| IMAGE_TAG="${CSI}-${LAMBDA_NAME}-${IMAGE_TAG_SUFFIX}" | ||
|
|
||
| # Compose the full ECR image references. | ||
| ECR_REPO_URI="${aws_account_id}.dkr.ecr.${region}.amazonaws.com/${ECR_REPO}" | ||
| ECR_IMAGE="${ECR_REPO_URI}:${IMAGE_TAG}" | ||
| # Use only the first input argument for BASE_IMAGE_ARG (no fallback) | ||
| BASE_IMAGE_ARG="$1" | ||
|
|
||
| # Build and tag the Docker image for the lambda. | ||
| docker buildx build \ | ||
| -f docker/lambda/Dockerfile \ | ||
| --build-arg BASE_IMAGE="${BASE_IMAGE}" \ | ||
| -t "${ECR_IMAGE}" \ | ||
| . | ||
|
|
||
| # Push the image tag to ECR on apply only. The Terraform configuration will reference this tag for the lambda image. | ||
| if [ "${PUBLISH_LAMBDA_IMAGE:-false}" = "true" ]; then | ||
| echo "PUBLISH_LAMBDA_IMAGE is set to true. Pushing Docker image to ECR: ${ECR_IMAGE}" | ||
| docker push "${ECR_IMAGE}" | ||
| else | ||
| echo "PUBLISH_LAMBDA_IMAGE is not set to true (we are most likely running in the context of a TF Plan). Skipping Docker push." | ||
| exit 0 | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ARG BASE_IMAGE=ghcr.io/nhsdigital/nhs-notify/letter-renderer-node-22:latest | ||
|
|
||
| FROM ${BASE_IMAGE} | ||
|
|
||
| # Copy the built output from the build context (docker.sh should have run build.sh already) | ||
| COPY dist/index.js ${LAMBDA_TASK_ROOT}/index.js | ||
|
|
||
| CMD [ "index.handler" ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // Replace me with the actual code for your Lambda function | ||
| import { Handler } from 'aws-lambda'; | ||
|
|
||
| export const handler: Handler = async (event) => { | ||
| console.log('Received event:', event); | ||
| return { | ||
| statusCode: 200, | ||
| body: 'Event logged', | ||
| }; | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this base image can be more generic? Its essentially the libreoffice image that we use for letter-renderer in core and letter-preview-renderer in Templates, might be used for something else in another BC?