Skip to content

Commit f9e5838

Browse files
Add preview environment configuration and variables for provider and … (#95)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description Creates the required configuration option to be passed to the container in ECS pointing them to the appropiate endpoints. <!-- Describe your changes in detail. --> ## Context <!-- Why is this change required? What problem does it solve? --> This is required so the container will access the required endpoints - or mock stubs as required. ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [ ] Refactoring (non-breaking change) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have followed the code style of the project - [ ] I have added tests to cover my changes - [ ] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming - [ ] Exceptions/Exclusions to coding standards (e.g. #noqa or #NOSONAR) are included within this Pull Request. --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
2 parents a5f8b82 + 1e49f90 commit f9e5838

5 files changed

Lines changed: 119 additions & 3 deletions

File tree

.github/workflows/preview-env.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ jobs:
134134
TF_VAR_alb_rule_priority: ${{ steps.meta.outputs.alb_rule_priority }}
135135
run: |
136136
terraform apply \
137+
-var-file="preview.tfvars" \
137138
-auto-approve
138139
139140
- name: Capture preview TF outputs
@@ -213,7 +214,9 @@ jobs:
213214
TF_VAR_image_tag: ${{ steps.meta.outputs.branch_name }}
214215
TF_VAR_alb_rule_priority: ${{ steps.meta.outputs.alb_rule_priority }}
215216
run: |
216-
terraform destroy -auto-approve
217+
terraform destroy \
218+
-var-file="preview.tfvars" \
219+
-auto-approve
217220
218221
# ---------- Wait on AWS tasks and notify ----------
219222
- name: Await deployment completion
@@ -397,7 +400,7 @@ jobs:
397400
id: check-integration
398401
if: always()
399402
run: |
400-
[ -f "gateway-api/test-artefacts/integration-tests.xml" ] && echo "exists=true" >> "$GITHUB_OUTPUT" || echo "exists=false" >> "$GITHUB_OUTPUT"
403+
[ -f "gateway-api/test-artefacts/integration-tests.xml" ] && echo "exists=true" >> "$GITHUB_OUTPUT" || echo "exists=false" >> "$GITHUB_OUTPUT"
401404
402405
- name: Publish integration test results to summary
403406
if: ${{ always() && steps.check-integration.outputs.exists == 'true' }}
@@ -522,4 +525,3 @@ jobs:
522525
with:
523526
image-ref: ${{steps.meta.outputs.ecr_url}}:${{steps.meta.outputs.branch_name}}
524527
artifact-name: trivy-sbom-${{ steps.meta.outputs.branch_name }}
525-

infrastructure/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ crash.*.log
1818
*.tfvars
1919
*.tfvars.json
2020

21+
# Allow checked-in preview tfvars containing non-sensitive values and secret references only
22+
!environments/preview/preview.tfvars
23+
2124
# Ignore override files as they are usually used to override resources locally and so
2225
# are not checked in
2326
override.tf

infrastructure/environments/preview/main.tf

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,52 @@ resource "aws_ecs_task_definition" "branch" {
238238
"awslogs-stream-prefix" = local.branch_safe
239239
}
240240
}
241+
environment = [
242+
{
243+
name = "ENVIRONMENT"
244+
value = "preview"
245+
},
246+
{
247+
name = "BRANCH_NAME"
248+
value = var.branch_name
249+
},
250+
{
251+
name = "SDS_URL"
252+
value = var.sds_url
253+
},
254+
{
255+
name = "SDS_API_TOKEN"
256+
value = var.sds_api_token
257+
},
258+
{
259+
name = "PDS_URL"
260+
value = var.pds_url
261+
},
262+
{
263+
name = "PDS_API_TOKEN"
264+
value = var.pds_api_token
265+
},
266+
{
267+
name = "PDS_API_SECRET"
268+
value = var.pds_api_secret
269+
},
270+
{
271+
name = "PDS_API_KID"
272+
value = var.pds_api_kid
273+
},
274+
{
275+
name = "PROVIDER_URL"
276+
value = var.provider_url
277+
},
278+
{
279+
name = "PROVIDER_MTLS_CERT"
280+
value = var.provider_mtls_cert
281+
},
282+
{
283+
name = "PROVIDER_MTLS_KEY"
284+
value = var.provider_mtls_key
285+
}
286+
]
241287
}
242288
])
243289

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
provider_url = "stub"
2+
provider_mtls_cert = "stub"
3+
provider_mtls_key = "stub"
4+
5+
sds_url = "stub"
6+
sds_api_token = "stub"
7+
8+
pds_url = "stub"
9+
pds_api_token = "stub"
10+
pds_api_secret = "stub"
11+
pds_api_kid = "stub"

infrastructure/environments/preview/variables.tf

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,57 @@ variable "log_kms_key_id" {
5555
type = string
5656
default = null
5757
}
58+
59+
variable "provider_url" {
60+
description = "The URL of the provider service to connect to."
61+
type = string
62+
default = "https://provider.dev.endpoints.clinical-data-gateway.national.nhs.uk"
63+
}
64+
65+
variable "provider_mtls_cert" {
66+
description = "Name of the secret containing the client certificate for mTLS authentication with the provider."
67+
type = string
68+
default = null
69+
}
70+
71+
variable "provider_mtls_key" {
72+
description = "Name of the secret containing the private key for mTLS authentication with the provider."
73+
type = string
74+
default = null
75+
}
76+
77+
variable "sds_url" {
78+
description = "The URL of the SDS service to connect to."
79+
type = string
80+
default = null
81+
}
82+
83+
variable "sds_api_token" {
84+
description = "API token used to authenticate with SDS."
85+
type = string
86+
default = null
87+
}
88+
89+
variable "pds_url" {
90+
description = "The URL of the PDS service to connect to."
91+
type = string
92+
default = null
93+
}
94+
95+
variable "pds_api_token" {
96+
description = "API token used to authenticate with PDS."
97+
type = string
98+
default = null
99+
}
100+
101+
variable "pds_api_secret" {
102+
description = "API secret key used to authenticate with PDS."
103+
type = string
104+
default = null
105+
}
106+
107+
variable "pds_api_kid" {
108+
description = "API key ID used to authenticate with PDS."
109+
type = string
110+
default = null
111+
}

0 commit comments

Comments
 (0)