Skip to content

Commit 095dd8f

Browse files
committed
eli-204 adding main GET method and deployment stages for API gateway
1 parent 670e2ed commit 095dd8f

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

infrastructure/stacks/api-layer/api_gateway.tf

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,58 @@ resource "aws_api_gateway_resource" "patient_check" {
2020
path_part = "patient-check"
2121
}
2222

23-
resource "aws_api_gateway_resource" "id" {
23+
resource "aws_api_gateway_resource" "patient" {
2424
rest_api_id = module.eligibility_signposting_api_gateway.rest_api_id
2525
parent_id = aws_api_gateway_resource.patient_check.id
2626
path_part = "{id}"
2727
}
28+
29+
# deployment
30+
31+
resource "aws_api_gateway_deployment" "eligibility_signposting_api" {
32+
rest_api_id = module.eligibility_signposting_api_gateway.rest_api_id
33+
34+
triggers = {
35+
redeployment = sha1(jsonencode([
36+
aws_api_gateway_integration.get_patient_check.id,
37+
aws_api_gateway_integration._status.id,
38+
]))
39+
}
40+
41+
lifecycle {
42+
create_before_destroy = true
43+
}
44+
}
45+
46+
resource "aws_api_gateway_stage" "eligibility-signposting-api" {
47+
deployment_id = aws_api_gateway_deployment.eligibility_signposting_api.id
48+
rest_api_id = module.eligibility_signposting_api_gateway.rest_api_id
49+
stage_name = "${local.workspace}-eligibility-signposting-api-live"
50+
xray_tracing_enabled = true
51+
52+
access_log_settings {
53+
destination_arn = module.eligibility_signposting_api_gateway.cloudwatch_destination_arn
54+
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\", \"domainName\":\"$context.domainName\", \"error_message\":\"$context.error.message\", \"clientCertSerialNumber\":\"$context.identity.clientCert.serialNumber\", \"clientCertValidityNotBefore\":\"$context.identity.clientCert.validity.notBefore\", \"clientCertValidityNotAfter\":\"$context.identity.clientCert.validity.notAfter\" }"
55+
}
56+
57+
depends_on = [
58+
module.eligibility_signposting_api_gateway.api_gateway_account,
59+
module.eligibility_signposting_api_gateway.logging_policy_attachment
60+
]
61+
}
62+
63+
resource "aws_api_gateway_method_settings" "example" {
64+
rest_api_id = module.eligibility_signposting_api_gateway.rest_api_id
65+
stage_name = aws_api_gateway_stage.eligibility-signposting-api.stage_name
66+
method_path = "*/*"
67+
68+
settings {
69+
metrics_enabled = true
70+
logging_level = "INFO"
71+
}
72+
73+
depends_on = [
74+
module.eligibility_signposting_api_gateway.api_gateway_account,
75+
module.eligibility_signposting_api_gateway.logging_policy_attachment
76+
]
77+
}

0 commit comments

Comments
 (0)