Skip to content

Add variable to disable instrumentation #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ resource "aws_lambda_function" "this" {
# User defined environment variables take precedence over datadog defined environment variables
# This allows users the option to override default behavior
environment {
variables = merge(
variables = var.disable_instrumentation ? var.environment_variables : merge(
local.environment_variables.common,
local.environment_variables.runtime,
var.environment_variables
Expand All @@ -171,12 +171,12 @@ resource "aws_lambda_function" "this" {

filename = var.filename
function_name = var.function_name
handler = local.handler
handler = var.disable_instrumentation ? var.handler : local.handler
kms_key_arn = var.kms_key_arn

# Datadog layers are defined in single element lists
# This allows for runtimes where a lambda layer is not needed by concatenating an empty list
layers = concat(
layers = var.disable_instrumentation ? var.layers : concat(
var.layers,
local.layers.lambda,
local.layers.extension,
Expand Down Expand Up @@ -215,7 +215,7 @@ resource "aws_lambda_function" "this" {

# Datadog defined tags take precedence over user defined tags
# This is to ensure that the dd_sls_terraform_module tag is set correctly
tags = merge(
tags = var.disable_instrumentation ? var.tags : merge(
var.tags,
local.tags
)
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# Datadog
###########

variable "disable_instrumentation" {
description = "If true, will disable the instrumentation completely, and deploy the lambda as is"
type = bool
default = false
}

variable "datadog_extension_layer_version" {
description = "Version for the Datadog Extension Layer"
type = number
Expand Down