Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions project-d-serverless-api/apigateway.tf
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ resource "aws_api_gateway_stage" "prod" {
rest_api_id = aws_api_gateway_rest_api.api.id
deployment_id = aws_api_gateway_deployment.deploy.id
stage_name = "prod"
xray_tracing_enabled = true

# Access logging: records who called which endpoint and when
access_log_settings {
Expand Down
6 changes: 6 additions & 0 deletions project-d-serverless-api/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ resource "aws_iam_role_policy_attachment" "lambda_logs" {
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}

# Policy: Allow Lambda to send traces to X-Ray
resource "aws_iam_role_policy_attachment" "lambda_xray" {
role = aws_iam_role.lambda_role.name
policy_arn = "arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess"
}

# =============================================================================
# IAM Role for API Gateway -> CloudWatch Logs
# =============================================================================
Expand Down
4 changes: 4 additions & 0 deletions project-d-serverless-api/lambda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ resource "aws_lambda_function" "api" {
tags = {
Project = var.project_name
}

tracing_config {
mode = "Active"
}
}

# =============================================================================
Expand Down
Loading