Skip to content

Commit 59bee59

Browse files
committed
Merge branch 'main' into feature/eja-eli-238-address-checkov-flagged-issues
2 parents 9c04c8b + 1a62f0b commit 59bee59

21 files changed

Lines changed: 57 additions & 80 deletions

.github/workflows/cicd-2-publish.yaml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
branches:
1010
- main
1111

12+
concurrency:
13+
group: terraform-dev
14+
cancel-in-progress: false
15+
1216
jobs:
1317
metadata:
1418
name: "Set CI/CD metadata"
@@ -100,10 +104,10 @@ jobs:
100104
# just planning for now for safety and until review
101105
run: |
102106
mkdir -p ./build
103-
echo "Running: make terraform env=$ENVIRONMENT workspace=$WORKSPACE stack=networking tf-command=plan"
104-
make terraform env=$ENVIRONMENT stack=networking tf-command=plan workspace=$WORKSPACE
105-
echo "Running: make terraform env=$ENVIRONMENT workspace=$WORKSPACE stack=api-layer tf-command=plan"
106-
make terraform env=$ENVIRONMENT stack=api-layer tf-command=plan workspace=$WORKSPACE
107+
echo "Running: make terraform env=$ENVIRONMENT workspace=$WORKSPACE stack=networking tf-command=apply"
108+
make terraform env=$ENVIRONMENT stack=networking tf-command=apply workspace=$WORKSPACE
109+
echo "Running: make terraform env=$ENVIRONMENT workspace=$WORKSPACE stack=api-layer tf-command=apply"
110+
make terraform env=$ENVIRONMENT stack=api-layer tf-command=apply workspace=$WORKSPACE
107111
working-directory: ./infrastructure
108112

109113
- name: "Tag the dev deployment"
@@ -136,20 +140,14 @@ jobs:
136140
# asset_path: ./build/lambda.zip
137141
# asset_name: lambda-${{ needs.metadata.outputs.version }}.zip
138142
# asset_content_type: application/zip
139-
success:
140-
name: "Success notification"
141-
runs-on: ubuntu-latest
142-
needs: [publish]
143-
steps:
144-
- name: "Check prerequisites for notification"
145-
id: check
146-
run: echo "secret_exist=${{ secrets.TEAMS_NOTIFICATION_WEBHOOK_URL != '' }}" >> $GITHUB_OUTPUT
147-
- name: "Notify on publishing packages"
148-
if: steps.check.outputs.secret_exist == 'true'
149-
uses: nhs-england-tools/notify-msteams-action@v1.0.0
143+
- name: "Notify Slack on PR merge"
144+
uses: slackapi/slack-github-action@v2.1.0
150145
with:
151-
github-token: ${{ secrets.GITHUB_TOKEN }}
152-
teams-webhook-url: ${{ secrets.TEAMS_NOTIFICATION_WEBHOOK_URL }}
153-
message-title: "Notification title"
154-
message-text: "This is a notification body"
155-
link: ${{ github.event.pull_request.html_url }}
146+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
147+
webhook-type: webhook-trigger
148+
payload: |
149+
status: "${{ job.status }}"
150+
link: "https://github.com/${{ github.repository }}/commit/${{ github.sha }}"
151+
Author: "${{ github.actor }}"
152+
title: "Pushed to main"
153+
version: "${{ needs.metadata.outputs.version }}"

.github/workflows/cicd-3-deploy.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
name: "CI/CD deploy"
55

6+
concurrency:
7+
group: terraform-deploy-${{ github.event.inputs.environment }}
8+
cancel-in-progress: false
9+
610
on:
711
workflow_dispatch:
812
inputs:

infrastructure/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ terraform-workspace-delete: guard-env guard-stack
3535

3636
# Runs a specified Terraform command (e.g., plan, apply) for the stack and environment.
3737
terraform: guard-env guard-stack guard-tf-command terraform-init terraform-workspace
38-
terraform -chdir=./stacks/$(stack) $(tf-command) $(args) $(if $(filter $(tf-command),init),,--parallelism=30)
38+
terraform -chdir=./stacks/$(stack) $(tf-command) $(args) \
39+
$(if $(filter init,$(tf-command)),,--parallelism=30) \
40+
$(if $(filter apply,$(tf-command)),-auto-approve)
3941
rm -f ./terraform_outputs_$(stack).json || true
4042
mkdir -p ./build
4143
terraform -chdir=./stacks/$(stack) output -json > ./build/terraform_outputs_$(stack).json
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../_shared/default_variables.tf

infrastructure/modules/dynamodb/dynamodb.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_dynamodb_table" "dynamodb_table" {
2-
name = "${terraform.workspace == "default" ? "" : "${terraform.workspace}-"}${var.table_name_suffix}"
2+
name = "${terraform.workspace == "default" ? "" : "${terraform.workspace}-"}${var.project_name}-${var.environment}-${var.table_name_suffix}"
33
billing_mode = "PAY_PER_REQUEST"
44
hash_key = var.partition_key
55

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
variable "workspace" {
2-
description = "Usually the developer short code or the name of the environment."
3-
type = string
4-
}
5-
6-
variable "project_name" {
7-
default = "eligibility-signposting-api"
8-
type = string
9-
}
10-
111
variable "table_name_suffix" {
122
description = "Name of the DynamoDB table"
133
type = string
@@ -34,14 +24,3 @@ variable "sort_key_type" {
3424
type = string
3525
default = null
3626
}
37-
38-
variable "tags" {
39-
description = "A map of tags to assign to resources."
40-
type = map(string)
41-
default = {}
42-
}
43-
44-
variable "environment" {
45-
description = "The purpose of the account dev/test/ref/prod or the workspace"
46-
type = string
47-
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../_shared/default_variables.tf

infrastructure/modules/s3/variables.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@ variable "bucket_name" {
33
type = string
44
}
55

6-
variable "project_name" {
7-
default = "eligibility-signposting-api"
8-
type = string
9-
}
10-
11-
variable "environment" {
12-
description = "The purpose of the account dev/test/ref/prod or the workspace"
13-
type = string
14-
}
15-
166
variable "bucket_expiration_days" {
177
default = 90
188
description = "How long to keep bucket contents before expiring"

infrastructure/stacks/_shared/locals.tf

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,9 @@ locals {
1717
workspace = lower(terraform.workspace)
1818
}
1919

20-
sso_role_patterns = {
21-
dev = "AWSReservedSSO_vdselid_dev_*"
22-
test = "AWSReservedSSO_vdselid_test_*"
23-
preprod = "AWSReservedSSO_vdselid_preprod_*"
24-
}
25-
2620
terraform_state_bucket_name = "eligibility-signposting-api-${var.environment}-tfstate"
2721
terraform_state_bucket_arn = "arn:aws:s3:::eligibility-signposting-api-${var.environment}-tfstate"
2822

29-
account_ids = {
30-
dev = "448049830832"
31-
test = "050451367081"
32-
preprod = "203918864209"
33-
# prod = "476114145616"
34-
}
35-
36-
current_account_id = lookup(local.account_ids, var.environment, data.aws_caller_identity.current.account_id)
37-
3823
role_arn_pre = "arn:aws:iam::603871901111:role/db-system-worker"
3924
role_arn_prod = "arn:aws:iam::232116723729:role/db-system-worker"
4025

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
module "eligibility_status_table" {
22
source = "../../modules/dynamodb"
33
workspace = local.workspace
4-
table_name_suffix = "eligibilty_data_store"
4+
table_name_suffix = "eligibility_datastore"
55
partition_key = "NHS_NUMBER"
66
partition_key_type = "S"
77
sort_key = "ATTRIBUTE_TYPE"
88
sort_key_type = "S"
99
tags = local.tags
10-
environment = var.environment
10+
environment = local.environment
11+
stack_name = local.stack_name
1112
}

0 commit comments

Comments
 (0)