Skip to content

Commit bfb30cb

Browse files
CCM-12875: Terraform changes, and updates
1 parent 3aab73b commit bfb30cb

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

infrastructure/terraform/components/dl/apigateway_pdm_mock.tf

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# API Gateway REST API for PDM Mock
21
resource "aws_api_gateway_rest_api" "pdm_mock" {
32
name = "${var.project}-${var.environment}-pdm-mock-api"
43
description = "PDM Mock API for testing integration with Patient Data Manager"
@@ -15,26 +14,23 @@ resource "aws_api_gateway_rest_api" "pdm_mock" {
1514
}
1615
}
1716

18-
# /resource path
1917
resource "aws_api_gateway_resource" "resource" {
2018
rest_api_id = aws_api_gateway_rest_api.pdm_mock.id
2119
parent_id = aws_api_gateway_rest_api.pdm_mock.root_resource_id
2220
path_part = "resource"
2321
}
2422

25-
# /resource/{id} path
2623
resource "aws_api_gateway_resource" "resource_id" {
2724
rest_api_id = aws_api_gateway_rest_api.pdm_mock.id
2825
parent_id = aws_api_gateway_resource.resource.id
2926
path_part = "{id}"
3027
}
3128

32-
# POST /resource - Create resource
3329
resource "aws_api_gateway_method" "create_resource" {
3430
rest_api_id = aws_api_gateway_rest_api.pdm_mock.id
3531
resource_id = aws_api_gateway_resource.resource.id
3632
http_method = "POST"
37-
authorization = "NONE"
33+
authorization = "AWS_IAM"
3834
}
3935

4036
resource "aws_api_gateway_integration" "create_resource" {
@@ -47,12 +43,11 @@ resource "aws_api_gateway_integration" "create_resource" {
4743
uri = module.pdm_mock_api.lambda_invoke_arn
4844
}
4945

50-
# GET /resource/{id} - Get resource
5146
resource "aws_api_gateway_method" "get_resource" {
5247
rest_api_id = aws_api_gateway_rest_api.pdm_mock.id
5348
resource_id = aws_api_gateway_resource.resource_id.id
5449
http_method = "GET"
55-
authorization = "NONE"
50+
authorization = "AWS_IAM"
5651
}
5752

5853
resource "aws_api_gateway_integration" "get_resource" {
@@ -65,18 +60,15 @@ resource "aws_api_gateway_integration" "get_resource" {
6560
uri = module.pdm_mock_api.lambda_invoke_arn
6661
}
6762

68-
# Lambda permission for API Gateway
6963
resource "aws_lambda_permission" "pdm_mock_api_gateway" {
7064
statement_id = "AllowAPIGatewayInvoke"
7165
action = "lambda:InvokeFunction"
7266
function_name = module.pdm_mock_api.lambda_function_name
7367
principal = "apigateway.amazonaws.com"
7468

75-
# More specific source ARN for better security
7669
source_arn = "${aws_api_gateway_rest_api.pdm_mock.execution_arn}/*/*"
7770
}
7871

79-
# Deployment
8072
resource "aws_api_gateway_deployment" "pdm_mock" {
8173
depends_on = [
8274
aws_api_gateway_integration.create_resource,
@@ -100,8 +92,6 @@ resource "aws_api_gateway_deployment" "pdm_mock" {
10092
create_before_destroy = true
10193
}
10294
}
103-
104-
# Stage
10595
resource "aws_api_gateway_stage" "pdm_mock" {
10696
deployment_id = aws_api_gateway_deployment.pdm_mock.id
10797
rest_api_id = aws_api_gateway_rest_api.pdm_mock.id
@@ -132,8 +122,6 @@ resource "aws_api_gateway_stage" "pdm_mock" {
132122
Component = local.component
133123
}
134124
}
135-
136-
# CloudWatch Log Group for API Gateway
137125
resource "aws_cloudwatch_log_group" "pdm_mock_api_gateway" {
138126
name = "/aws/apigateway/${var.project}-${var.environment}-pdm-mock-api"
139127
retention_in_days = var.log_retention_in_days
@@ -146,8 +134,6 @@ resource "aws_cloudwatch_log_group" "pdm_mock_api_gateway" {
146134
Component = local.component
147135
}
148136
}
149-
150-
# Outputs
151137
output "pdm_mock_api_endpoint" {
152138
description = "The base URL of the PDM Mock API"
153139
value = aws_api_gateway_stage.pdm_mock.invoke_url

0 commit comments

Comments
 (0)