Skip to content

Commit fb6dd76

Browse files
Merge remote-tracking branch 'origin/main' into feature/eli-418_performance-test-github-action-api-gateway-update
2 parents edc6eca + dd5d3b3 commit fb6dd76

22 files changed

Lines changed: 320 additions & 181 deletions

.github/workflows/base-deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ jobs:
125125
terraform_version: ${{ needs.metadata.outputs.terraform_version }}
126126

127127
- name: "Configure AWS Credentials"
128-
uses: aws-actions/configure-aws-credentials@v5
128+
uses: aws-actions/configure-aws-credentials@v6
129129
with:
130130
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
131131
aws-region: eu-west-2
@@ -188,7 +188,7 @@ jobs:
188188
path: ./dist
189189

190190
- name: "Configure AWS Credentials"
191-
uses: aws-actions/configure-aws-credentials@v5
191+
uses: aws-actions/configure-aws-credentials@v6
192192
with:
193193
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
194194
aws-region: eu-west-2

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ jobs:
8888
path: dist/lambda.zip
8989

9090
- name: "Configure AWS Credentials"
91-
uses: aws-actions/configure-aws-credentials@v5
91+
uses: aws-actions/configure-aws-credentials@v6
9292
with:
9393
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
9494
aws-region: eu-west-2

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
terraform_version: ${{ needs.metadata.outputs.terraform_version }}
6868

6969
- name: "Configure AWS Credentials"
70-
uses: aws-actions/configure-aws-credentials@v5
70+
uses: aws-actions/configure-aws-credentials@v6
7171
with:
7272
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
7373
aws-region: eu-west-2
@@ -130,3 +130,4 @@ jobs:
130130
ENVIRONMENT: "test"
131131
VERSION_NUMBER: "main"
132132
secrets: inherit
133+

.github/workflows/cicd-4-preprod-deploy.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
this_sha: ${{ steps.resolver.outputs.this_sha }}
3737
latest_sha: ${{ steps.resolver.outputs.latest_test_sha }}
3838
release_type: ${{ steps.release_type.outputs.release_type }}
39-
39+
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
4040
env:
4141
TEST_WORKFLOW_ID: "190123511" # this will need updating if the workflow is recreated
4242
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -97,3 +97,4 @@ jobs:
9797
ref: ${{ needs.metadata.outputs.ref }}
9898
release_type: ${{ needs.metadata.outputs.release_type }}
9999
secrets: inherit
100+
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}

.github/workflows/monthly-capacity-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
python-version: "3.11"
4343

4444
- name: Configure AWS Credentials (${{ matrix.env_config.name }})
45-
uses: aws-actions/configure-aws-credentials@v5
45+
uses: aws-actions/configure-aws-credentials@v6
4646
with:
4747
role-to-assume: arn:aws:iam::${{ secrets[matrix.env_config.account_secret] }}:role/service-roles/github-actions-api-deployment-role
4848
aws-region: eu-west-2

.github/workflows/release-candidate.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
terraform_version: $(grep '^terraform' .tool-versions | cut -f2 -d' ')
9696

9797
- name: "Configure AWS Credentials (dev)"
98-
uses: aws-actions/configure-aws-credentials@v5
98+
uses: aws-actions/configure-aws-credentials@v6
9999
with:
100100
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
101101
aws-region: eu-west-2
@@ -170,7 +170,7 @@ jobs:
170170
make build
171171
172172
- name: "Configure AWS Credentials"
173-
uses: aws-actions/configure-aws-credentials@v5
173+
uses: aws-actions/configure-aws-credentials@v6
174174
with:
175175
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
176176
aws-region: eu-west-2
@@ -222,7 +222,7 @@ jobs:
222222
path: dist
223223

224224
- name: "Configure AWS Credentials (test)"
225-
uses: aws-actions/configure-aws-credentials@v5
225+
uses: aws-actions/configure-aws-credentials@v6
226226
with:
227227
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
228228
aws-region: eu-west-2
@@ -323,7 +323,7 @@ jobs:
323323
path: dist
324324

325325
- name: "Configure AWS Credentials (preprod)"
326-
uses: aws-actions/configure-aws-credentials@v5
326+
uses: aws-actions/configure-aws-credentials@v6
327327
with:
328328
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/service-roles/github-actions-api-deployment-role
329329
aws-region: eu-west-2

infrastructure/modules/bootstrap/tfstate/s3.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ resource "aws_s3_bucket_lifecycle_configuration" "tfstate_bucket" {
8080
}
8181

8282
expiration {
83-
days = 90
83+
days = 1200
8484
}
8585

8686
noncurrent_version_transition {

infrastructure/modules/s3/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ variable "bucket_name" {
44
}
55

66
variable "bucket_expiration_days" {
7-
default = 90
7+
default = 1200
88
description = "How long to keep bucket contents before expiring"
99
type = number
1010
}

infrastructure/stacks/api-layer/api_gateway.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ resource "aws_api_gateway_stage" "eligibility-signposting-api" {
5656
# A subscription filter (see csoc_log_forwarding.tf) forwards these logs to CSOC
5757
access_log_settings {
5858
destination_arn = module.eligibility_signposting_api_gateway.cloudwatch_destination_arn
59-
format = "{ \"requestId\":\"$context.requestId\", \"ip\": \"$context.identity.sourceIp\", \"caller\":\"$context.identity.caller\", \"user\":\"$context.identity.user\", \"requestTime\":\"$context.requestTime\", \"httpMethod\":\"$context.httpMethod\", \"resourcePath\":\"$context.resourcePath\", \"status\":\"$context.status\", \"protocol\":\"$context.protocol\", \"responseLength\":\"$context.responseLength\", \"accountId\":\"$context.accountId\", \"apiId\":\"$context.apiId\", \"stage\":\"$context.stage\", \"api_key\":\"$context.identity.apiKey\", \"responseLatency\":\"$context.responseLatency\", \"integrationLatency\":\"$context.integrationLatency\" }"
59+
format = "{ \"requestId\":\"$context.requestId\", \"ip\": \"$context.identity.sourceIp\", \"caller\":\"$context.identity.caller\", \"user\":\"$context.identity.user\", \"requestTime\":\"$context.requestTime\", \"httpMethod\":\"$context.httpMethod\", \"resourcePath\":\"$context.resourcePath\", \"status\":\"$context.status\", \"protocol\":\"$context.protocol\", \"responseLength\":\"$context.responseLength\", \"accountId\":\"$context.accountId\", \"apiId\":\"$context.apiId\", \"stage\":\"$context.stage\", \"api_key\":\"$context.identity.apiKey\" }"
60+
6061
}
6162

6263
depends_on = [

infrastructure/stacks/api-layer/iam_policies.tf

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ data "aws_iam_policy_document" "s3_audit_bucket_policy" {
273273
}
274274
}
275275

276-
# Attach s3 write policy to external write role
276+
# Attach s3 write policy to lambda write role - rename below to lambda_s3_audit_write_policy
277277
resource "aws_iam_role_policy" "external_s3_write_policy" {
278278
name = "S3WriteAccess"
279279
role = aws_iam_role.eligibility_lambda_role.id
@@ -351,6 +351,7 @@ resource "aws_kms_key_policy" "s3_rules_kms_key" {
351351
policy = data.aws_iam_policy_document.s3_rules_kms_key_policy.json
352352
}
353353

354+
# KMS key policy for consumer mapping file
354355
data "aws_iam_policy_document" "s3_consumer_mapping_kms_key_policy" {
355356
#checkov:skip=CKV_AWS_111: Root user needs full KMS key management
356357
#checkov:skip=CKV_AWS_356: Root user needs full KMS key management
@@ -755,3 +756,60 @@ resource "aws_iam_role_policy_attachment" "attach_rotation_sfn" {
755756
role = aws_iam_role.rotation_sfn_role.name
756757
policy_arn = aws_iam_policy.rotation_sfn_policy.arn
757758
}
759+
760+
#DQ policies
761+
# Policy doc for S3 DQ bucket
762+
data "aws_iam_policy_document" "s3_dq_bucket_policy" {
763+
statement {
764+
sid = "AllowSSLRequestsOnly"
765+
actions = [
766+
"s3:ListBucket",
767+
"s3:GetBucketLocation",
768+
"s3:GetObject",
769+
"s3:PutObject",
770+
"s3:DeleteObject", // Critical for Spark staging/committing
771+
"s3:AbortMultipartUpload" // Important for large dataframes if job fails
772+
]
773+
resources = [
774+
module.s3_dq_metrics_bucket.storage_bucket_arn,
775+
"${module.s3_dq_metrics_bucket.storage_bucket_arn}/*",
776+
]
777+
condition {
778+
test = "Bool"
779+
values = ["true"]
780+
variable = "aws:SecureTransport"
781+
}
782+
}
783+
}
784+
785+
# Attach DQ s3 write policy to external write role
786+
resource "aws_iam_role_policy" "external_dq_s3_write_policy" {
787+
count = length(aws_iam_role.write_access_role)
788+
name = "S3DQWriteAccess"
789+
role = aws_iam_role.write_access_role[count.index].id
790+
policy = data.aws_iam_policy_document.s3_dq_bucket_policy.json
791+
}
792+
793+
# KMS access policy for S3 DQ bucket to external write role
794+
data "aws_iam_policy_document" "s3_dq_kms_access_policy" {
795+
statement {
796+
actions = [
797+
"kms:Encrypt",
798+
"kms:Decrypt",
799+
"kms:ReEncrypt*",
800+
"kms:GenerateDataKey*",
801+
"kms:DescribeKey"
802+
]
803+
resources = [
804+
module.s3_dq_metrics_bucket.storage_bucket_kms_key_arn
805+
]
806+
}
807+
}
808+
809+
# Attach KMS policy to external write role
810+
resource "aws_iam_role_policy" "external_s3_kms_access_policy" {
811+
count = length(aws_iam_role.write_access_role)
812+
name = "KMSAccessForS3DQ"
813+
role = aws_iam_role.write_access_role[count.index].id
814+
policy = data.aws_iam_policy_document.s3_dq_kms_access_policy.json
815+
}

0 commit comments

Comments
 (0)