Skip to content

Commit 57b6441

Browse files
committed
Merge branch 'main' into PRMP-588
2 parents 9ce08e4 + 9f756ab commit 57b6441

39 files changed

+13554
-24
lines changed

.github/workflows/automated-sbom-repo-scan.yml renamed to .github/workflows/automated-pr-validator.yml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
name: 'Z-AUTOMATED: SBOM Repo Scan'
1+
name: "Z-AUTOMATED: PR Validator"
22

33
on:
44
pull_request:
55
types: [opened, synchronize, reopened]
66

7-
permissions:
8-
actions: read # Required for anchore/sbom-action
9-
contents: write # Required for anchore/sbom-action
10-
id-token: write # Required for requesting the JWT
11-
pull-requests: write
12-
137
jobs:
148
sbom_scan:
159
name: SBOM Repo Scan
1610
runs-on: ubuntu-latest
11+
permissions:
12+
actions: read # Required for anchore/sbom-action
13+
contents: write # Required for anchore/sbom-action
14+
id-token: write # Required for requesting the JWT
15+
pull-requests: write
1716
steps:
18-
- uses: actions/checkout@v5
17+
- name: Checkout
18+
uses: actions/checkout@v5
1919
with:
20-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
20+
fetch-depth: 0
2121

2222
- uses: anchore/sbom-action@v0
2323
with:
@@ -51,14 +51,14 @@ jobs:
5151
repo: context.repo.repo,
5252
issue_number: context.issue.number,
5353
})
54-
54+
5555
const botComment = comments.find(comment => {
5656
return comment.user.type === 'Bot' && comment.body.includes('Code security issues found')
5757
})
5858
5959
// 2. Prepare format of the comment
6060
const output = `### Code security issues found
61-
61+
6262
View full details [here](https://github.com/${{ github.repository }}/security/code-scanning?query=is%3Aopen+pr%3A${{ github.event.pull_request.number }}).`;
6363
6464
// 3. If we have a comment, update it, otherwise create a new one
@@ -70,7 +70,7 @@ jobs:
7070
body: output
7171
})
7272
}
73-
73+
7474
github.rest.issues.createComment({
7575
issue_number: context.issue.number,
7676
owner: context.repo.owner,
@@ -89,7 +89,7 @@ jobs:
8989
repo: context.repo.repo,
9090
issue_number: context.issue.number,
9191
})
92-
92+
9393
const botComment = comments.find(comment => {
9494
return comment.user.type === 'Bot' && comment.body.includes('Code security issues found')
9595
})
@@ -102,3 +102,21 @@ jobs:
102102
comment_id: botComment.id
103103
})
104104
}
105+
106+
markdown-validation:
107+
name: Markdown Validation
108+
runs-on: ubuntu-latest
109+
permissions:
110+
contents: read
111+
steps:
112+
- name: Checkout
113+
uses: actions/checkout@v6
114+
with:
115+
fetch-depth: 0
116+
117+
- name: Run Markdown Validation Script
118+
id: validate
119+
run: |
120+
BRANCH_NAME=${{ github.event.repository.default_branch }}
121+
chmod +x scripts/markdown-validator.sh
122+
scripts/markdown-validator.sh

.markdownlint.jsonc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"MD013": false,
3+
"MD033": false
4+
}

.terraform-docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ sections:
1414

1515
content: |-
1616
{{ .Requirements }}
17+
1718
{{ .Resources }}
19+
1820
{{ .Inputs }}
21+
1922
{{ .Outputs }}
2023
2124
output:

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ This repository is used to build the infrastructure the NDR. That is it's sole p
88
- [Terraform docs](https://github.com/terraform-docs/terraform-docs)
99

1010
To install terraform-docs on WSL use the following commands (e.g. for v0.20.0):
11-
```
11+
12+
```shell
1213
curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.20.0/terraform-docs-v0.20.0-$(uname)-amd64.tar.gz
1314
tar -xzf terraform-docs.tar.gz
1415
chmod +x terraform-docs
@@ -24,7 +25,7 @@ As this repository is a standalone infrastructure there is no python/node based
2425

2526
- Set this repository to get it's pre-commit hooks from .githooks
2627

27-
```
28+
```shell
2829
git config core.hooksPath .githooks
2930
```
3031

bootstrap/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Terraform Bootstrap
2+
13
## Requirements
24

35
| Name | Version |

infrastructure/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# National Document Repository - Infrastructure as Code
2+
13
## Requirements
24

35
| Name | Version |

infrastructure/api.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,15 @@ resource "aws_api_gateway_deployment" "ndr_api_deploy" {
7676
module.send-feedback-gateway,
7777
module.send-feedback-lambda,
7878
module.review_document_version_gateway,
79+
module.review_document_status_gateway,
80+
module.review-document-status-check-lambda,
7981
module.update-doc-ref-lambda,
8082
module.update-upload-state-gateway,
8183
module.update-upload-state-lambda,
8284
module.document-status-check-gateway,
8385
module.document-status-check-lambda,
8486
module.post-document-references-fhir-lambda,
87+
module.post_document_review_lambda,
8588
module.patch_document_review_lambda,
8689
module.virus_scan_result_gateway,
8790
module.virus_scan_result_lambda

infrastructure/gateway-review-document.tf

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module "review_document_gateway" {
22
source = "./modules/gateway"
33
api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
44
parent_id = aws_api_gateway_rest_api.ndr_doc_store_api.root_resource_id
5-
http_methods = ["GET"]
5+
http_methods = ["GET", "POST"]
66
authorization = "CUSTOM"
77
gateway_path = "DocumentReview"
88
authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id
@@ -32,3 +32,15 @@ module "review_document_version_gateway" {
3232
"method.request.path.version" = true
3333
}
3434
}
35+
36+
module "review_document_status_gateway" {
37+
source = "./modules/gateway"
38+
api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
39+
parent_id = module.review_document_version_gateway.gateway_resource_id
40+
gateway_path = "Status"
41+
http_methods = ["GET"]
42+
require_credentials = true
43+
authorization = "CUSTOM"
44+
authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id
45+
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
46+
}

infrastructure/iam.tf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,3 +317,41 @@ resource "aws_iam_role_policy_attachment" "get_doc_ref_presign_url" {
317317
role = aws_iam_role.get_doc_ref_presign_url_role.name
318318
policy_arn = aws_iam_policy.s3_document_data_policy_for_get_doc_ref_lambda.arn
319319
}
320+
321+
data "aws_iam_policy_document" "assume_role_policy_post_document_review_lambda" {
322+
statement {
323+
actions = ["sts:AssumeRole"]
324+
325+
principals {
326+
type = "AWS"
327+
identifiers = [module.post_document_review_lambda.lambda_execution_role_arn]
328+
}
329+
}
330+
}
331+
332+
resource "aws_iam_role" "post_document_review_presign" {
333+
name = "${terraform.workspace}_post_review_presign_url_role"
334+
assume_role_policy = data.aws_iam_policy_document.assume_role_policy_post_document_review_lambda.json
335+
}
336+
337+
resource "aws_iam_role_policy_attachment" "post_document_review" {
338+
role = aws_iam_role.post_document_review_presign.name
339+
policy_arn = aws_iam_policy.s3_document_data_policy_post_document_review_lambda.arn
340+
}
341+
342+
resource "aws_iam_policy" "s3_document_data_policy_post_document_review_lambda" {
343+
name = "${terraform.workspace}_put_document_only_policy_for_post_document_review_lambda"
344+
345+
policy = jsonencode({
346+
"Version" : "2012-10-17",
347+
"Statement" : [
348+
{
349+
"Effect" : "Allow",
350+
"Action" : [
351+
"s3:PutObject",
352+
],
353+
"Resource" : ["${module.ndr-bulk-staging-store.bucket_arn}/review/*"]
354+
}
355+
]
356+
})
357+
}

0 commit comments

Comments
 (0)