Skip to content

Commit 02f6117

Browse files
Merge remote-tracking branch 'origin/main' into PRMP-386
2 parents 18e6288 + 8828eeb commit 02f6117

File tree

6 files changed

+231
-9
lines changed

6 files changed

+231
-9
lines changed

.github/workflows/automated-deploy-dev.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,68 @@ jobs:
220220
uses: NHSDigital/national-document-repository/.github/workflows/ui-dev-to-main-ci.yml@main
221221
secrets:
222222
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}
223+
224+
notify-slack:
225+
runs-on: ubuntu-latest
226+
needs: [terraform_plan_apply, deploy_lambdas, deploy_ui]
227+
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/main'
228+
steps:
229+
- name: Configure AWS Credentials
230+
uses: aws-actions/configure-aws-credentials@v5
231+
with:
232+
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }}
233+
aws-region: ${{ vars.AWS_REGION }}
234+
235+
- name: Get slack bot token from SSM parameter store
236+
run: |
237+
slack_bot_token=$(aws ssm get-parameter --name "/ndr/alerting/slack/bot_token" --with-decryption --query "Parameter.Value" --output text)
238+
echo "::add-mask::$slack_bot_token"
239+
echo "SLACK_BOT_TOKEN=$slack_bot_token" >> $GITHUB_ENV
240+
241+
- name: Send Slack Notification
242+
uses: slackapi/[email protected]
243+
with:
244+
method: chat.postMessage
245+
token: ${{ env.SLACK_BOT_TOKEN }}
246+
payload: |
247+
{
248+
"channel": "${{ vars.ALERTS_SLACK_CHANNEL_ID }}",
249+
"attachments": [
250+
{
251+
"color": "#ff0000",
252+
"blocks": [
253+
{
254+
"type": "header",
255+
"text": {
256+
"type": "plain_text",
257+
"text": "❌ Workflow `${{ github.workflow }}` failed"
258+
}
259+
},
260+
{
261+
"type": "section",
262+
"text": {
263+
"type": "mrkdwn",
264+
"text": "*Triggered by:* `${{ github.actor }}`\n*Branch:* `${{ github.ref_name }}`\n*Workflow:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>"
265+
}
266+
},
267+
{
268+
"type": "divider"
269+
},
270+
{
271+
"type": "section",
272+
"fields": [
273+
{ "type": "mrkdwn", "text": "*terraform_plan_apply:* ${{ needs.terraform_plan_apply.result == 'success' && ':white_check_mark:' || ':x:' }}" },
274+
{ "type": "mrkdwn", "text": "*deploy_lambdas:* ${{ needs.deploy_lambdas.result == 'success' && ':white_check_mark:' || ':x:' }}" },
275+
{ "type": "mrkdwn", "text": "*deploy_ui:* ${{ needs.deploy_ui.result == 'success' && ':white_check_mark:' || ':x:' }}" }
276+
]
277+
},
278+
{
279+
"type": "context",
280+
"elements": [
281+
{ "type": "mrkdwn", "text": "Environment: `development` | Sandbox: `ndr-dev`" }
282+
]
283+
}
284+
]
285+
}
286+
]
287+
}

.github/workflows/automated-sonarqube-cloud-analysis.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,60 @@ jobs:
2626
env:
2727
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
2828
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
29+
30+
notify-slack:
31+
runs-on: ubuntu-latest
32+
needs: [sonarqube_cloud]
33+
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/main'
34+
steps:
35+
- name: Configure AWS Credentials
36+
uses: aws-actions/configure-aws-credentials@v5
37+
with:
38+
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }}
39+
aws-region: ${{ vars.AWS_REGION }}
40+
41+
- name: Get slack bot token from SSM parameter store
42+
run: |
43+
slack_bot_token=$(aws ssm get-parameter --name "/ndr/alerting/slack/bot_token" --with-decryption --query "Parameter.Value" --output text)
44+
echo "::add-mask::$slack_bot_token"
45+
echo "SLACK_BOT_TOKEN=$slack_bot_token" >> $GITHUB_ENV
46+
47+
- name: Send Slack Notification
48+
uses: slackapi/[email protected]
49+
with:
50+
method: chat.postMessage
51+
token: ${{ env.SLACK_BOT_TOKEN }}
52+
payload: |
53+
{
54+
"channel": "${{ vars.ALERTS_SLACK_CHANNEL_ID }}",
55+
"attachments": [
56+
{
57+
"color": "#ff0000",
58+
"blocks": [
59+
{
60+
"type": "header",
61+
"text": {
62+
"type": "plain_text",
63+
"text": "❌ Workflow `${{ github.workflow }}` failed"
64+
}
65+
},
66+
{
67+
"type": "section",
68+
"text": {
69+
"type": "mrkdwn",
70+
"text": "*Triggered by:* `${{ github.actor }}`\n*Branch:* `${{ github.ref_name }}`\n*Workflow:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>"
71+
}
72+
},
73+
{
74+
"type": "divider"
75+
},
76+
{
77+
"type": "section",
78+
"fields": [
79+
{ "type": "mrkdwn", "text": "*sonarqube_cloud:* ${{ needs.sonarqube_cloud.result == 'success' && ':white_check_mark:' || ':x:' }}" }
80+
]
81+
}
82+
]
83+
}
84+
]
85+
}

.github/workflows/cron-daily-health-check.yml

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ jobs:
160160
environment: development
161161
python_version: "3.11"
162162
secrets:
163-
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}
163+
AWS_ASSUME_ROLE: ${{ secrets.AWS_ASSUME_ROLE }}
164164

165165
deploy_lambdas:
166166
name: Deploy Lambdas
@@ -196,3 +196,72 @@ jobs:
196196
sandbox_name: ${{ needs.set_workspace.outputs.workspace }}
197197
environment: development
198198
secrets: inherit
199+
200+
notify-slack:
201+
runs-on: ubuntu-latest
202+
needs: [terraform_plan_apply, run_lambda_unit_tests, run_ui_unit_tests, run_cypress_tests, publish_lambda_layers, deploy_lambdas, deploy_ui]
203+
if: failure()
204+
steps:
205+
- name: Configure AWS Credentials
206+
uses: aws-actions/configure-aws-credentials@v5
207+
with:
208+
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }}
209+
aws-region: ${{ vars.AWS_REGION }}
210+
211+
- name: Get slack bot token from SSM parameter store
212+
run: |
213+
slack_bot_token=$(aws ssm get-parameter --name "/ndr/alerting/slack/bot_token" --with-decryption --query "Parameter.Value" --output text)
214+
echo "::add-mask::$slack_bot_token"
215+
echo "SLACK_BOT_TOKEN=$slack_bot_token" >> $GITHUB_ENV
216+
217+
- name: Send Slack Notification
218+
uses: slackapi/[email protected]
219+
with:
220+
method: chat.postMessage
221+
token: ${{ env.SLACK_BOT_TOKEN }}
222+
payload: |
223+
{
224+
"channel": "${{ vars.ALERTS_SLACK_CHANNEL_ID }}",
225+
"attachments": [
226+
{
227+
"color": "#ff0000",
228+
"blocks": [
229+
{
230+
"type": "header",
231+
"text": {
232+
"type": "plain_text",
233+
"text": "❌ Workflow `${{ github.workflow }}` failed"
234+
}
235+
},
236+
{
237+
"type": "section",
238+
"text": {
239+
"type": "mrkdwn",
240+
"text": "*Triggered by:* `Scheduled Job`\n*Workflow:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>"
241+
}
242+
},
243+
{
244+
"type": "divider"
245+
},
246+
{
247+
"type": "section",
248+
"fields": [
249+
{ "type": "mrkdwn", "text": "*terraform_plan_apply:* ${{ needs.terraform_plan_apply.result == 'success' && ':white_check_mark:' || ':x:' }}" },
250+
{ "type": "mrkdwn", "text": "*run_lambda_unit_tests:* ${{ needs.run_lambda_unit_tests.result == 'success' && ':white_check_mark:' || ':x:' }}" },
251+
{ "type": "mrkdwn", "text": "*run_ui_unit_tests:* ${{ needs.run_ui_unit_tests.result == 'success' && ':white_check_mark:' || ':x:' }}" },
252+
{ "type": "mrkdwn", "text": "*run_cypress_tests:* ${{ needs.run_cypress_tests.result == 'success' && ':white_check_mark:' || ':x:' }}" },
253+
{ "type": "mrkdwn", "text": "*publish_lambda_layers:* ${{ needs.publish_lambda_layers.result == 'success' && ':white_check_mark:' || ':x:' }}" },
254+
{ "type": "mrkdwn", "text": "*deploy_lambdas:* ${{ needs.deploy_lambdas.result == 'success' && ':white_check_mark:' || ':x:' }}" },
255+
{ "type": "mrkdwn", "text": "*deploy_ui:* ${{ needs.deploy_ui.result == 'success' && ':white_check_mark:' || ':x:' }}" }
256+
]
257+
},
258+
{
259+
"type": "context",
260+
"elements": [
261+
{ "type": "mrkdwn", "text": "Environment: `development` | Sandbox: `${{ needs.set_workspace.outputs.workspace }}`" }
262+
]
263+
}
264+
]
265+
}
266+
]
267+
}

infrastructure/lambda-bulk-upload.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module "bulk-upload-lambda" {
1717
module.sqs-lg-bulk-upload-metadata-queue.sqs_write_policy_document,
1818
module.sqs-lg-bulk-upload-invalid-queue.sqs_read_policy_document,
1919
module.sqs-lg-bulk-upload-invalid-queue.sqs_write_policy_document,
20+
module.lg-bulk-upload-expedite-metadata-queue.sqs_write_policy_document,
21+
module.lg-bulk-upload-expedite-metadata-queue.sqs_read_policy_document,
2022
aws_iam_policy.ssm_access_policy.policy,
2123
module.ndr-app-config.app_config_policy
2224
]
@@ -53,6 +55,7 @@ module "bulk-upload-lambda" {
5355
module.lloyd_george_reference_dynamodb_table,
5456
module.bulk_upload_report_dynamodb_table,
5557
aws_iam_policy.ssm_access_policy,
58+
module.lg-bulk-upload-expedite-metadata-queue,
5659
]
5760
}
5861

@@ -71,6 +74,18 @@ resource "aws_lambda_event_source_mapping" "bulk_upload_lambda" {
7174
]
7275
}
7376

77+
resource "aws_lambda_event_source_mapping" "bulk_upload_lambda_expedite_trigger" {
78+
event_source_arn = module.lg-bulk-upload-expedite-metadata-queue.sqs_arn
79+
function_name = module.bulk-upload-lambda.lambda_arn
80+
batch_size = 10
81+
enabled = true
82+
83+
depends_on = [
84+
module.bulk-upload-lambda,
85+
module.lg-bulk-upload-expedite-metadata-queue
86+
]
87+
}
88+
7489
module "bulk-upload-alarm" {
7590
source = "./modules/lambda_alarms"
7691
lambda_function_name = module.bulk-upload-lambda.function_name

infrastructure/sqs-expedite.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module "lg-bulk-upload-expedite-metadata-queue" {
2+
source = "./modules/sqs"
3+
name = "lg-bulk-upload-expedite-metadata-queue.fifo"
4+
max_size_message = 256 * 1024 # allow message size up to 256 KB
5+
message_retention = 60 * 60 * 24 * 14 # 14 days
6+
environment = var.environment
7+
owner = var.owner
8+
max_visibility = 1020
9+
enable_fifo = true
10+
enable_deduplication = true
11+
delay = 60
12+
enable_dlq = true
13+
dlq_message_retention = 1209600 # 14 days
14+
}

infrastructure/sqs_alarms.tf

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
locals {
22
monitored_queues = {
33
# main queues
4-
"nrl_main" = module.sqs-nrl-queue.sqs_name
5-
"stitching_main" = module.sqs-stitching-queue.sqs_name
6-
"lg_bulk_main" = module.sqs-lg-bulk-upload-metadata-queue.sqs_name
7-
"lg_inv_main" = module.sqs-lg-bulk-upload-invalid-queue.sqs_name
8-
"mns_main" = module.sqs-mns-notification-queue[0].sqs_name
4+
"nrl_main" = module.sqs-nrl-queue.sqs_name
5+
"stitching_main" = module.sqs-stitching-queue.sqs_name
6+
"lg_bulk_main" = module.sqs-lg-bulk-upload-metadata-queue.sqs_name
7+
"lg_inv_main" = module.sqs-lg-bulk-upload-invalid-queue.sqs_name
8+
"mns_main" = module.sqs-mns-notification-queue[0].sqs_name
9+
"lg_bulk_expedite_main" = module.lg-bulk-upload-expedite-metadata-queue.sqs_name
910
# dead-letter queues
10-
"nrl_dlq" = module.sqs-nrl-queue.dlq_name
11-
"stitching_dlq" = module.sqs-stitching-queue.dlq_name
12-
"mns_dlq" = module.sqs-mns-notification-queue[0].dlq_name
11+
"nrl_dlq" = module.sqs-nrl-queue.dlq_name
12+
"stitching_dlq" = module.sqs-stitching-queue.dlq_name
13+
"mns_dlq" = module.sqs-mns-notification-queue[0].dlq_name
14+
"lg_bulk_expedite_dlq" = module.lg-bulk-upload-expedite-metadata-queue.dlq_name
1315
}
1416

1517

0 commit comments

Comments
 (0)