1- # API Gateway REST API for PDM Mock
21resource "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
1917resource "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
2623resource "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
3329resource "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
4036resource "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
5146resource "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
5853resource "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
6963resource "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
8072resource "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
10595resource "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
137125resource "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
151137output "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