Skip to content

Commit 63a66ae

Browse files
VIA-614 AS Move SSM Parameters to Secrets Manager
1 parent c185a45 commit 63a66ae

File tree

16 files changed

+129
-93
lines changed

16 files changed

+129
-93
lines changed

.env.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# AWS parameter store
2-
SSM_PREFIX=/local/
1+
# AWS Secrets Manager
2+
SECRET_PREFIX=/local/
33

44
# logging
55
PINO_LOG_LEVEL=info

infrastructure/README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,36 @@ Our infrastructure sits in the Europe(London) region coded 'eu-west-2' in AWS.
44

55
## Post deployment steps
66

7-
### Setting up and using secrets
7+
### Setting up and using secrets in AWS Secrets Manager
8+
9+
Secrets need to be created in AWS Secrets Manager as follows:
10+
11+
1. Click on `Store a new secret` in Secrets Manager
12+
2. Secret Type: `Other type of secret`
13+
3. Select `Plaintext` option
14+
4. Fill in the secret value in the text area
15+
5. Encryption key: `aws/secretsmanager`, and click next
16+
6. Add a name for the secret and description
17+
7. Tags as [below](#tags)
18+
8. Click next on the screens and then store.
819

920
Update the values for the following secrets after generating them: -
1021

11-
- /vita/apim/prod-1.pem - APIM private key used to sign JWTs generated from [here](https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/user-restricted-restful-apis-nhs-login-separate-authentication-and-authorisation#step-3-generate-a-key-pair). 'prod-1' here is the key id used during generation.
22+
- /vita/apim/prod-1.pem - APIM private key used to sign JWTs to access user-restricted APIs via APIM, generated from [here](https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/user-restricted-restful-apis-nhs-login-separate-authentication-and-authorisation#step-3-generate-a-key-pair). 'prod-1' here is the key id used during generation.
1223
- /vita/apim/prod-1.json - APIM public key in JWKS format generated above
1324
- /vita/nhslogin/private_key.pem - NHS Login private key generated from [here](https://nhsconnect.github.io/nhslogin/generating-pem/)
1425
- /vita/nhslogin/public_key.pem - NHS Login public key generated above
1526
- /vita/splunk/hec/endpoint - HEC endpoint of Splunk
1627
- /vita/splunk/hec/token - HEC token of Splunk endpoint to store operational logs
1728

18-
Now fill the values used by the application below: -
29+
The following secrets need to be created and set before running the application:
1930

20-
- Go to AWS service "Systems Manager"
21-
- Click on "Parameter Store" under application tools section
22-
- Update the values as per integrations in that environment
31+
- `/vita/APIM_PRIVATE_KEY`: Same value as `/vita/apim/prod-1.pem`
32+
- `/vita/AUTH_SECRET`: A randomly generated string used to sign JWTs for authentication (NextAuth)
33+
- `/vita/CONTENT_API_KEY`: NHS UK Content API Key
34+
- `/vita/ELIGIBILITY_API_KEY`: EliD API Key
35+
- `/vita/NHS_LOGIN_CLIENT_ID`: NHS Login OIDC Client ID for VitA App
36+
- `/vita/NHS_LOGIN_PRIVATE_KEY`: Same value as `/vita/nhslogin/private_key.pem`
2337

2438
### Setting up Cloudfront error pages
2539

@@ -38,12 +52,10 @@ Manually create the following error routes.
3852

3953
### Setting default limits and settings
4054

41-
- Increase the default throughput limit of the parameter store, instructions [here](https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-throughput.html#parameter-store-throughput-increasing)
4255
- Also setup [service quotas automatic management](https://docs.aws.amazon.com/servicequotas/latest/userguide/automatic-management.html) to alert on Slack channel
4356
- Review AWS > Service Quotas
4457
- AWS Lambda > Concurrent executions: Default is 1000 counts.
45-
- AWS Systems Manager > Rate of GetParameter requests: Currently 10,000 per second. Cannot request an increase via AWS console.
46-
- AWS Key Management Service (AWS KMS) > Cryptographic operations (symmetric) request rate: Currently 20,000 per second (used by SSM and Lambda)
58+
- AWS Key Management Service (AWS KMS) > Cryptographic operations (symmetric) request rate: Currently 20,000 per second (used by Secrets Manager and Lambda)
4759
- Setup important notifications
4860
- AWS > User Notifications > Delivery Channels > Chat channels. Select the channel
4961
- Turn ON all 4 AWS managed subscriptions

infrastructure/environments/dev/locals.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ locals {
2323
splunk_log_retention_in_days = 7
2424

2525
application_environment_variables = {
26-
SSM_PREFIX = "/${local.prefix}/"
26+
SECRET_PREFIX = "/${local.project_identifier_shortcode}/"
2727

2828
PINO_LOG_LEVEL = "info"
2929
DEPLOY_ENVIRONMENT = local.environment
@@ -48,7 +48,7 @@ locals {
4848
NBS_URL = "https://f.nhswebsite-integration.nhs.uk/nbs"
4949
NBS_BOOKING_PATH = "/nhs-app/vita"
5050

51-
SSM_PARAMETER_STORE_TTL = 300
51+
SECRETS_MANAGER_TTL = 300
5252
PARAMETERS_SECRETS_EXTENSION_LOG_LEVEL = "INFO"
5353
}
5454

infrastructure/environments/dev/ssm.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# TODO: Delete this file when we cut an R2 release
2+
# The scheduled assurances will fail if SSM parameters are deleted and redeployed whilst we still have R1
13
resource "aws_ssm_parameter" "nhs_uk_content_api_key" {
24
name = "/${local.prefix}/CONTENT_API_KEY"
35
type = "SecureString"

infrastructure/environments/preprod/locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ locals {
2323
splunk_log_retention_in_days = 30
2424

2525
application_environment_variables = {
26-
SSM_PREFIX = "/${local.prefix}/"
26+
SECRET_PREFIX = "/${local.project_identifier_shortcode}/"
2727

2828
PINO_LOG_LEVEL = "info"
2929
DEPLOY_ENVIRONMENT = local.environment

infrastructure/environments/preprod/ssm.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# TODO: Delete this file when we cut an R2 release
2+
# The scheduled assurances will fail if SSM parameters are deleted and redeployed whilst we still have R1
13
resource "aws_ssm_parameter" "nhs_uk_content_api_key" {
24
name = "/${local.prefix}/CONTENT_API_KEY"
35
type = "SecureString"

infrastructure/environments/prod/locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ locals {
2323
splunk_log_retention_in_days = 90
2424

2525
application_environment_variables = {
26-
SSM_PREFIX = "/${local.prefix}/"
26+
SECRET_PREFIX = "/${local.project_identifier_shortcode}/"
2727

2828
PINO_LOG_LEVEL = "info"
2929
DEPLOY_ENVIRONMENT = local.environment

infrastructure/environments/prod/ssm.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# TODO: Delete this file when we cut an R2 release
2+
# The scheduled assurances will fail if SSM parameters are deleted and redeployed whilst we still have R1
13
resource "aws_ssm_parameter" "nhs_uk_content_api_key" {
24
name = "/${local.prefix}/CONTENT_API_KEY"
35
type = "SecureString"

infrastructure/environments/test/locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ locals {
2323
splunk_log_retention_in_days = 30
2424

2525
application_environment_variables = {
26-
SSM_PREFIX = "/${local.prefix}/"
26+
SECRET_PREFIX = "/${local.project_identifier_shortcode}/"
2727

2828
PINO_LOG_LEVEL = "debug"
2929
DEPLOY_ENVIRONMENT = local.environment

infrastructure/environments/test/ssm.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# TODO: Delete this file when we cut an R2 release
2+
# The scheduled assurances will fail if SSM parameters are deleted and redeployed whilst we still have R1
13
resource "aws_ssm_parameter" "nhs_uk_content_api_key" {
24
name = "/${local.prefix}/CONTENT_API_KEY"
35
type = "SecureString"

0 commit comments

Comments
 (0)