Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This Terraform module wraps the [aws_lambda_function](https://registry.terraform
```
module "lambda-datadog" {
source = "DataDog/lambda-datadog/aws"
version = "1.5.0"
version = "1.6.0"

filename = "example.zip"
function_name = "example-function"
Expand All @@ -33,16 +33,16 @@ module "lambda-datadog" {
"DD_VERSION" : "1.0.0"
}

datadog_extension_layer_version = 65
datadog_python_layer_version = 99
datadog_extension_layer_version = 67
datadog_python_layer_version = 104
}
```

### Node
```
module "lambda-datadog" {
source = "DataDog/lambda-datadog/aws"
version = "1.5.0"
version = "1.6.0"

filename = "example.zip"
function_name = "example-function"
Expand All @@ -59,16 +59,16 @@ module "lambda-datadog" {
"DD_VERSION" : "1.0.0"
}

datadog_extension_layer_version = 65
datadog_node_layer_version = 115
datadog_extension_layer_version = 67
datadog_node_layer_version = 117
}
```

### .NET
```
module "lambda-datadog" {
source = "DataDog/lambda-datadog/aws"
version = "1.5.0"
version = "1.6.0"

filename = "example.zip"
function_name = "example-function"
Expand All @@ -85,7 +85,7 @@ module "lambda-datadog" {
"DD_VERSION" : "1.0.0"
}

datadog_extension_layer_version = 65
datadog_extension_layer_version = 67
datadog_dotnet_layer_version = 16
}
```
Expand All @@ -94,7 +94,7 @@ module "lambda-datadog" {
```
module "lambda-datadog" {
source = "DataDog/lambda-datadog/aws"
version = "1.5.0"
version = "1.6.0"

filename = "example.jar"
function_name = "example-function"
Expand All @@ -111,7 +111,7 @@ module "lambda-datadog" {
"DD_VERSION" : "1.0.0"
}

datadog_extension_layer_version = 65
datadog_extension_layer_version = 67
datadog_java_layer_version = 15
}
```
Expand Down Expand Up @@ -149,7 +149,7 @@ resource "aws_lambda_function" "example_lambda_function" {
```
module "lambda-datadog" {
source = "DataDog/lambda-datadog/aws"
version = "1.5.0"
version = "1.6.0"

function_name = "example-function"
...
Expand Down Expand Up @@ -225,11 +225,11 @@ No modules.
|------|-------------|------|---------|:--------:|
| <a name="input_architectures"></a> [architectures](#input\_architectures) | Instruction set architecture for your Lambda function. Valid values are ["x86\_64"] and ["arm64"]. | `list(string)` | <pre>["x86_64"]</pre> | no |
| <a name="input_code_signing_config_arn"></a> [code\_signing\_config\_arn](#input\_code\_signing\_config\_arn) | To enable code signing for this function, specify the ARN of a code-signing configuration. A code-signing configuration includes a set of signing profiles, which define the trusted publishers for this function. | `string` | `null` | no |
| <a name="input_datadog_extension_layer_version"></a> [datadog\_extension\_layer\_version](#input\_datadog\_extension\_layer\_version) | Version for the Datadog Extension Layer | `number` | `65` | no |
| <a name="input_datadog_extension_layer_version"></a> [datadog\_extension\_layer\_version](#input\_datadog\_extension\_layer\_version) | Version for the Datadog Extension Layer | `number` | `67` | no |
| <a name="input_datadog_dotnet_layer_version"></a> [datadog\_dotnet\_layer\_version](#input\_datadog\_dotnet\_layer\_version) | Version for the Datadog .NET Layer | `number` | `16` | no |
| <a name="input_datadog_java_layer_version"></a> [datadog\_java\_layer\_version](#input\_datadog\_java\_layer\_version) | Version for the Datadog Java Layer | `number` | `15` | no |
| <a name="input_datadog_node_layer_version"></a> [datadog\_node\_layer\_version](#input\_datadog\_node\_layer\_version) | Version for the Datadog Node Layer | `number` | `115` | no |
| <a name="input_datadog_python_layer_version"></a> [datadog\_python\_layer\_version](#input\_datadog\_python\_layer\_version) | Version for the Datadog Python Layer | `number` | `99` | no |
| <a name="input_datadog_node_layer_version"></a> [datadog\_node\_layer\_version](#input\_datadog\_node\_layer\_version) | Version for the Datadog Node Layer | `number` | `117` | no |
| <a name="input_datadog_python_layer_version"></a> [datadog\_python\_layer\_version](#input\_datadog\_python\_layer\_version) | Version for the Datadog Python Layer | `number` | `104` | no |
| <a name="input_dead_letter_config_target_arn"></a> [dead\_letter\_config\_target\_arn](#input\_dead\_letter\_config\_target\_arn) | ARN of an SNS topic or SQS queue to notify when an invocation fails. | `string` | `null` | no |
| <a name="input_description"></a> [description](#input\_description) | Description of what your Lambda Function does. | `string` | `null` | no |
| <a name="input_environment_variables"></a> [environment\_variables](#input\_environment\_variables) | Map of environment variables that are accessible from the function code during execution. | `map(string)` | `{}` | no |
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ locals {
}

tags = {
dd_sls_terraform_module = "1.5.0"
dd_sls_terraform_module = "1.6.0"
}
}

Expand Down
28 changes: 28 additions & 0 deletions smoke_tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Smoke Tests

A simple smoke test setup that creates one of each of the various functions
that we support, making sure that our default parameters are sensible.

## Usage

* Create a [Datadog API Key](https://app.datadoghq.com/organization-settings/api-keys)
* Create a secret in [AWS Secrets Manager](https://docs.aws.amazon.com/secretsmanager/latest/userguide/intro.html) and add the Datadog API Key as the secret value in plaintext
* Create a `terraform.tfvars` file
- Set the `datadog_secret_arn` to the arn of the secret you just created
- Set the `datadog_service_name` to the name of the service you want to use to filter for the resource in Datadog
- Set the `datadog_site` to the [Datadog destination site](https://docs.datadoghq.com/getting_started/site/) for your metrics, traces, and logs
* Run the following commands

```
terraform init
terraform plan
terraform apply
```

Confirm that the lambdas were all created as expected.

Run the following commands to clean up the environment:

```
terraform destroy
```
231 changes: 231 additions & 0 deletions smoke_tests/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
resource "aws_iam_role" "lambda_role" {
name = "terraform-smoketest-${var.datadog_service_name}-role"
assume_role_policy = jsonencode(
{
"Version" : "2012-10-17",
"Statement" : [
{
"Sid" : "",
"Effect" : "Allow",
"Action" : "sts:AssumeRole",
"Principal" : {
"Service" : "lambda.amazonaws.com"
}
}
]
})
}

resource "aws_iam_policy" "secrets_manager_read_policy" {
name = "terraform-smoketest-${var.datadog_service_name}-secrets-manager-policy"
description = "Policy to allow read access to Secrets Manager"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Sid = "ReadSecret"
Effect = "Allow"
Action = "secretsmanager:GetSecretValue"
Resource = var.datadog_secret_arn
}
]
})
}

resource "aws_iam_role_policy_attachment" "attach_iam_policy_to_iam_role" {
role = aws_iam_role.lambda_role.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}

resource "aws_iam_role_policy_attachment" "attach_secrets_manager_policy" {
role = aws_iam_role.lambda_role.name
policy_arn = aws_iam_policy.secrets_manager_read_policy.arn
}

data "archive_file" "zip_python_code" {
type = "zip"
source_dir = "${path.module}/src_python/"
output_path = "${path.module}/build/hello-python.zip"
}

data "archive_file" "zip_node_code" {
type = "zip"
source_dir = "${path.module}/src_node/"
output_path = "${path.module}/build/hello-node.zip"
}

module "lambda-python-3-12" {
source = "../"

filename = "${path.module}/build/hello-python.zip"
function_name = "terraform-smoketest-python-3-12-${var.datadog_service_name}-function"
role = aws_iam_role.lambda_role.arn
handler = "app.lambda_handler"
runtime = "python3.12"
architectures = ["arm64"]
memory_size = 256

environment_variables = {
"DD_API_KEY_SECRET_ARN" : var.datadog_secret_arn
"DD_ENV" : "dev"
"DD_SERVICE" : var.datadog_service_name
"DD_SITE": var.datadog_site
"DD_VERSION" : "1.0.0"
}
}

module "lambda-python-3-11" {
source = "../"

filename = "${path.module}/build/hello-python.zip"
function_name = "terraform-smoketest-python-3-11-${var.datadog_service_name}-function"
role = aws_iam_role.lambda_role.arn
handler = "app.lambda_handler"
runtime = "python3.11"
architectures = ["arm64"]
memory_size = 256

environment_variables = {
"DD_API_KEY_SECRET_ARN" : var.datadog_secret_arn
"DD_ENV" : "dev"
"DD_SERVICE" : var.datadog_service_name
"DD_SITE": var.datadog_site
"DD_VERSION" : "1.0.0"
}
}

module "lambda-python-3-10" {
source = "../"

filename = "${path.module}/build/hello-python.zip"
function_name = "terraform-smoketest-python-3-10-${var.datadog_service_name}-function"
role = aws_iam_role.lambda_role.arn
handler = "app.lambda_handler"
runtime = "python3.10"
architectures = ["arm64"]
memory_size = 256

environment_variables = {
"DD_API_KEY_SECRET_ARN" : var.datadog_secret_arn
"DD_ENV" : "dev"
"DD_SERVICE" : var.datadog_service_name
"DD_SITE": var.datadog_site
"DD_VERSION" : "1.0.0"
}
}

module "lambda-python-3-9" {
source = "../"

filename = "${path.module}/build/hello-python.zip"
function_name = "terraform-smoketest-python-3-9-${var.datadog_service_name}-function"
role = aws_iam_role.lambda_role.arn
handler = "app.lambda_handler"
runtime = "python3.9"
architectures = ["arm64"]
memory_size = 256

environment_variables = {
"DD_API_KEY_SECRET_ARN" : var.datadog_secret_arn
"DD_ENV" : "dev"
"DD_SERVICE" : var.datadog_service_name
"DD_SITE": var.datadog_site
"DD_VERSION" : "1.0.0"
}
}

module "lambda-python-3-8" {
source = "../"

filename = "${path.module}/build/hello-python.zip"
function_name = "terraform-smoketest-python-3-8-${var.datadog_service_name}-function"
role = aws_iam_role.lambda_role.arn
handler = "app.lambda_handler"
runtime = "python3.8"
architectures = ["arm64"]
memory_size = 256

environment_variables = {
"DD_API_KEY_SECRET_ARN" : var.datadog_secret_arn
"DD_ENV" : "dev"
"DD_SERVICE" : var.datadog_service_name
"DD_SITE": var.datadog_site
"DD_VERSION" : "1.0.0"
}
}

module "lambda-node-22" {
source = "../"

filename = "${path.module}/build/hello-node.zip"
function_name = "terraform-smoketest-node-22-${var.datadog_service_name}-function"
role = aws_iam_role.lambda_role.arn
handler = "index.lambda_handler"
runtime = "nodejs22.x"
memory_size = 256

environment_variables = {
"DD_API_KEY_SECRET_ARN" : var.datadog_secret_arn
"DD_ENV" : "dev"
"DD_SERVICE" : var.datadog_service_name
"DD_SITE": var.datadog_site
"DD_VERSION" : "1.0.0"
}
}

module "lambda-node-20" {
source = "../"

filename = "${path.module}/build/hello-node.zip"
function_name = "terraform-smoketest-node-20-${var.datadog_service_name}-function"
role = aws_iam_role.lambda_role.arn
handler = "index.lambda_handler"
runtime = "nodejs20.x"
memory_size = 256

environment_variables = {
"DD_API_KEY_SECRET_ARN" : var.datadog_secret_arn
"DD_ENV" : "dev"
"DD_SERVICE" : var.datadog_service_name
"DD_SITE": var.datadog_site
"DD_VERSION" : "1.0.0"
}
}

module "lambda-node-18" {
source = "../"

filename = "${path.module}/build/hello-node.zip"
function_name = "terraform-smoketest-node-18-${var.datadog_service_name}-function"
role = aws_iam_role.lambda_role.arn
handler = "index.lambda_handler"
runtime = "nodejs18.x"
memory_size = 256

environment_variables = {
"DD_API_KEY_SECRET_ARN" : var.datadog_secret_arn
"DD_ENV" : "dev"
"DD_SERVICE" : var.datadog_service_name
"DD_SITE": var.datadog_site
"DD_VERSION" : "1.0.0"
}
}

module "lambda-node-16" {
source = "../"

filename = "${path.module}/build/hello-node.zip"
function_name = "terraform-smoketest-node-16-${var.datadog_service_name}-function"
role = aws_iam_role.lambda_role.arn
handler = "index.lambda_handler"
runtime = "nodejs16.x"
memory_size = 256

environment_variables = {
"DD_API_KEY_SECRET_ARN" : var.datadog_secret_arn
"DD_ENV" : "dev"
"DD_SERVICE" : var.datadog_service_name
"DD_SITE": var.datadog_site
"DD_VERSION" : "1.0.0"
}
}
Loading