Skip to content

Commit 10fd5d0

Browse files
conditional changes for prod URL (#154)
1 parent 2b30625 commit 10fd5d0

15 files changed

+38
-36
lines changed

infrastructure/api.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ resource "aws_api_gateway_gateway_response" "unauthorised_response" {
9494
}
9595

9696
response_parameters = {
97-
"gatewayresponse.header.Access-Control-Allow-Origin" = "'https://${terraform.workspace}.${var.domain}'"
97+
"gatewayresponse.header.Access-Control-Allow-Origin" = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
9898
"gatewayresponse.header.Access-Control-Allow-Methods" = "'*'"
9999
"gatewayresponse.header.Access-Control-Allow-Headers" = "'Content-Type,X-Amz-Date,Authorization,X-Auth,X-Api-Key,X-Amz-Security-Token,X-Auth-Cookie,Accept'"
100100
"gatewayresponse.header.Access-Control-Allow-Credentials" = "'true'"
@@ -110,7 +110,7 @@ resource "aws_api_gateway_gateway_response" "bad_gateway_response" {
110110
}
111111

112112
response_parameters = {
113-
"gatewayresponse.header.Access-Control-Allow-Origin" = "'https://${terraform.workspace}.${var.domain}'"
113+
"gatewayresponse.header.Access-Control-Allow-Origin" = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
114114
"gatewayresponse.header.Access-Control-Allow-Methods" = "'*'"
115115
"gatewayresponse.header.Access-Control-Allow-Headers" = "'Content-Type,X-Amz-Date,Authorization,X-Auth,X-Api-Key,X-Amz-Security-Token,X-Auth-Cookie,Accept'"
116116
"gatewayresponse.header.Access-Control-Allow-Credentials" = "'true'"
@@ -126,4 +126,4 @@ module "api_endpoint_url_ssm_parameter" {
126126
type = "SecureString"
127127
owner = var.owner
128128
environment = var.environment
129-
}
129+
}

infrastructure/buckets.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ module "ndr-document-store" {
1111
{
1212
allowed_headers = ["*"]
1313
allowed_methods = ["POST", "DELETE"]
14-
allowed_origins = ["https://${terraform.workspace}.${var.domain}"]
14+
allowed_origins = [contains(["prod"], terraform.workspace) ? "https://${var.domain}" : "https://${terraform.workspace}.${var.domain}"]
1515
expose_headers = ["ETag"]
1616
max_age_seconds = 3000
1717
},
1818
{
1919
allowed_methods = ["GET"]
20-
allowed_origins = ["https://${terraform.workspace}.${var.domain}"]
20+
allowed_origins = [contains(["prod"], terraform.workspace) ? "https://${var.domain}" : "https://${terraform.workspace}.${var.domain}"]
2121
}
2222
]
2323
}
@@ -33,7 +33,7 @@ module "ndr-zip-request-store" {
3333
cors_rules = [
3434
{
3535
allowed_methods = ["GET"]
36-
allowed_origins = ["https://${terraform.workspace}.${var.domain}"]
36+
allowed_origins = [contains(["prod"], terraform.workspace) ? "https://${var.domain}" : "https://${terraform.workspace}.${var.domain}"]
3737
}
3838
]
3939
}
@@ -51,13 +51,13 @@ module "ndr-lloyd-george-store" {
5151
{
5252
allowed_headers = ["*"]
5353
allowed_methods = ["POST", "PUT", "DELETE"]
54-
allowed_origins = ["https://${terraform.workspace}.${var.domain}"]
54+
allowed_origins = [contains(["prod"], terraform.workspace) ? "https://${var.domain}" : "https://${terraform.workspace}.${var.domain}"]
5555
expose_headers = ["ETag"]
5656
max_age_seconds = 3000
5757
},
5858
{
5959
allowed_methods = ["GET"]
60-
allowed_origins = ["https://${terraform.workspace}.${var.domain}"]
60+
allowed_origins = [contains(["prod"], terraform.workspace) ? "https://${var.domain}" : "https://${terraform.workspace}.${var.domain}"]
6161
}
6262
]
6363
}

infrastructure/lambda-back-channel-logout.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module "back-channel-logout-gateway" {
77
authorization = "NONE"
88
gateway_path = "BackChannelLogout"
99
require_credentials = false
10-
origin = "'https://${terraform.workspace}.${var.domain}'"
10+
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
1111
# Lambda Variables
1212
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn
1313
owner = var.owner
@@ -41,7 +41,7 @@ module "back_channel_logout_lambda" {
4141
ENVIRONMENT = var.environment
4242
AUTH_DYNAMODB_NAME = "${terraform.workspace}_${var.auth_session_dynamodb_table_name}"
4343
SSM_PARAM_JWT_TOKEN_PUBLIC_KEY = "jwt_token_public_key"
44-
OIDC_CALLBACK_URL = "https://${terraform.workspace}.${var.domain}/auth-callback"
44+
OIDC_CALLBACK_URL = contains(["prod"], terraform.workspace) ? "https://${var.domain}/auth-callback" : "https://${terraform.workspace}.${var.domain}/auth-callback"
4545
}
4646
depends_on = [
4747
aws_api_gateway_rest_api.ndr_doc_store_api,

infrastructure/lambda-create-doc-ref.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module "create-doc-ref-gateway" {
88
gateway_path = "DocumentReference"
99
authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id
1010
require_credentials = true
11-
origin = "'https://${terraform.workspace}.${var.domain}'"
11+
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
1212

1313
# Lambda Variables
1414
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn

infrastructure/lambda-delete-doc-ref.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module "delete-doc-ref-gateway" {
88
gateway_path = "DocumentDelete"
99
authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id
1010
require_credentials = true
11-
origin = "'https://${terraform.workspace}.${var.domain}'"
11+
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
1212

1313
# Lambda Variables
1414
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn
@@ -92,4 +92,4 @@ module "delete-doc-ref-lambda" {
9292
module.delete-doc-ref-gateway,
9393
module.ndr-app-config
9494
]
95-
}
95+
}

infrastructure/lambda-document-manifest-by-nhs-number.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module "document-manifest-by-nhs-gateway" {
88
gateway_path = "DocumentManifest"
99
authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id
1010
require_credentials = true
11-
origin = "'https://${terraform.workspace}.${var.domain}'"
11+
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
1212

1313
# Lambda Variables
1414
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn
@@ -108,4 +108,4 @@ resource "aws_iam_role_policy_attachment" "policy_manifest_lambda" {
108108
count = local.is_sandbox ? 0 : 1
109109
role = module.document-manifest-by-nhs-number-lambda.lambda_execution_role_name
110110
policy_arn = try(aws_iam_policy.lambda_audit_splunk_sqs_queue_send_policy[0].arn, null)
111-
}
111+
}

infrastructure/lambda-lloyd-george-record-stitch.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module "lloyd-george-stitch-gateway" {
88
gateway_path = "LloydGeorgeStitch"
99
authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id
1010
require_credentials = true
11-
origin = "'https://${terraform.workspace}.${var.domain}'"
11+
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
1212

1313
# Lambda Variables
1414
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn
@@ -105,4 +105,4 @@ resource "aws_iam_role_policy_attachment" "lambda_stitch-lambda" {
105105
count = local.is_sandbox ? 0 : 1
106106
role = module.lloyd-george-stitch-lambda.lambda_execution_role_name
107107
policy_arn = try(aws_iam_policy.lambda_audit_splunk_sqs_queue_send_policy[0].arn, null)
108-
}
108+
}

infrastructure/lambda-login-redirect.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module "login_redirect_lambda" {
3131
APPCONFIG_ENVIRONMENT = module.ndr-app-config.app_config_environment_id
3232
APPCONFIG_CONFIGURATION = module.ndr-app-config.app_config_configuration_profile_id
3333
WORKSPACE = terraform.workspace
34-
OIDC_CALLBACK_URL = "https://${terraform.workspace}.${var.domain}/auth-callback"
34+
OIDC_CALLBACK_URL = contains(["prod"], terraform.workspace) ? "https://${var.domain}/auth-callback" : "https://${terraform.workspace}.${var.domain}/auth-callback"
3535
AUTH_DYNAMODB_NAME = "${terraform.workspace}_${var.auth_state_dynamodb_table_name}"
3636
}
3737
depends_on = [
@@ -104,4 +104,4 @@ resource "aws_iam_policy" "ssm_policy_oidc" {
104104
}
105105
]
106106
})
107-
}
107+
}

infrastructure/lambda-logout.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module "logout-gateway" {
77
authorization = "NONE"
88
gateway_path = "Logout"
99
require_credentials = false
10-
origin = "'https://${terraform.workspace}.${var.domain}'"
10+
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
1111
# Lambda Variables
1212
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn
1313
owner = var.owner

infrastructure/lambda-search-doc-references.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module "search-document-references-gateway" {
88
gateway_path = "SearchDocumentReferences"
99
authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id
1010
require_credentials = true
11-
origin = "'https://${terraform.workspace}.${var.domain}'"
11+
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
1212

1313
# Lambda Variables
1414
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn

0 commit comments

Comments
 (0)