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 infrastructure/terraform/modules/lambda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
| <a name="input_description"></a> [description](#input\_description) | Description of the Lambda | `string` | n/a | yes |
| <a name="input_enable_dlq_and_notifications"></a> [enable\_dlq\_and\_notifications](#input\_enable\_dlq\_and\_notifications) | Create an SQS Queue and on-failure destination to be used as the Lambda's Dead Letter Queue and notifications | `bool` | `false` | no |
| <a name="input_enable_lambda_insights"></a> [enable\_lambda\_insights](#input\_enable\_lambda\_insights) | Enable the lambda insights layer, this must be disabled for lambda@edge usage | `bool` | `true` | no |
| <a name="input_enable_xray_tracing"></a> [enable\_xray\_tracing](#input\_enable\_xray\_tracing) | Enable AWS X-Ray active tracing for the Lambda function. | `bool` | `false` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
| <a name="input_filter_pattern"></a> [filter\_pattern](#input\_filter\_pattern) | Filter pattern to use for the log subscription filter | `string` | `""` | no |
| <a name="input_force_lambda_code_deploy"></a> [force\_lambda\_code\_deploy](#input\_force\_lambda\_code\_deploy) | If the lambda package in s3 has the same commit id tag as the terraform build branch, the lambda will not update automatically. Set to True if making changes to Lambda code from on the same commit for example during development | `bool` | `false` | no |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "aws_iam_role_policy_attachment" "xray" {
count = var.enable_xray_tracing ? 1 : 0

role = aws_iam_role.main.name
policy_arn = "arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess"
}
7 changes: 7 additions & 0 deletions infrastructure/terraform/modules/lambda/lambda_function.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ resource "aws_lambda_function" "main" {
}
}

dynamic "tracing_config" {
for_each = var.enable_xray_tracing ? [1] : []
content {
mode = "Active"
}
}

dynamic "vpc_config" {
for_each = var.vpc_config != null ? [""] : []

Expand Down
6 changes: 6 additions & 0 deletions infrastructure/terraform/modules/lambda/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ variable "enable_lambda_insights" {
default = true
}

variable "enable_xray_tracing" {
type = bool
description = "Enable AWS X-Ray active tracing for the Lambda function."
default = false
}

variable "lambda_at_edge" {
type = bool
description = "Whether this Lambda is a Lambda@Edge function"
Expand Down
Loading