Skip to content

Commit 4f8b63c

Browse files
author
Blake Morgan
authored
Add X-Ray Option (#20)
* Add xray enabled var * Update version * Format terraform * Terraform fmt * Remove xray flag in simple examples
1 parent 8dddfa7 commit 4f8b63c

File tree

8 files changed

+20
-7
lines changed

8 files changed

+20
-7
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Also Note: CodePipeline and CodeDeploy cannot be used together to deploy a Lambd
2626
## Usage
2727
```hcl
2828
module "lambda_api" {
29-
source = "github.com/byu-oit/terraform-aws-lambda-api?ref=v1.2.0"
29+
source = "github.com/byu-oit/terraform-aws-lambda-api?ref=v1.3.0"
3030
app_name = "my-lambda"
3131
env = "dev"
3232
codedeploy_service_role_arn = module.acs.power_builder_role.arn
@@ -101,6 +101,7 @@ module "lambda_api" {
101101
| use_codedeploy | bool | If true, CodeDeploy App and Deployment Group will be created and TF will not update alias to point to new versions of the Lambda (becuase CodeDeploy will do that). | false
102102
| timeout | number | How long the lambda will run (in seconds) before timing out | 3 (same as terraform default)
103103
| memory_size | number | Size of the memory of the lambda. CPU will scale along with it | 128 (same as terraform default)
104+
| xray_enabled | bool | Whether or not the X-Ray daemon should be created with the Lambda API. | false
104105

105106
#### lambda_vpc_config
106107

examples/ci-12/ci.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module "lambda_api" {
2323
vpc_id = module.acs.vpc.id
2424
public_subnet_ids = module.acs.public_subnet_ids
2525
role_permissions_boundary_arn = module.acs.role_permissions_boundary.arn
26+
xray_enabled = true
2627

2728
lambda_vpc_config = {
2829
subnet_ids = module.acs.private_subnet_ids

examples/ci-13/ci.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module "lambda_api" {
2323
vpc_id = module.acs.vpc.id
2424
public_subnet_ids = module.acs.public_subnet_ids
2525
role_permissions_boundary_arn = module.acs.role_permissions_boundary.arn
26+
xray_enabled = true
2627

2728
lambda_vpc_config = {
2829
subnet_ids = module.acs.private_subnet_ids

examples/no-codedeploy/example.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
provider "aws" {
2-
version = "~> 2.56"
2+
version = "~> 3.0"
33
region = "us-west-2"
44
}
55

66
module "acs" {
7-
source = "github.com/byu-oit/terraform-aws-acs-info?ref=v2.1.0"
7+
source = "github.com/byu-oit/terraform-aws-acs-info?ref=v3.2.0"
88
}
99

1010
module "lambda_api" {
11-
# source = "../../"
12-
source = "github.com/byu-oit/terraform-aws-lambda-api?ref=v1.2.0"
11+
// source = "../../"
12+
source = "github.com/byu-oit/terraform-aws-lambda-api?ref=v1.3.0"
1313
app_name = "my-lambda"
1414
env = "dev"
1515
lambda_zip_file = "./src/lambda.zip"
@@ -20,6 +20,7 @@ module "lambda_api" {
2020
vpc_id = module.acs.vpc.id
2121
public_subnet_ids = module.acs.public_subnet_ids
2222
role_permissions_boundary_arn = module.acs.role_permissions_boundary.arn
23+
xray_enabled = true
2324
}
2425

2526
output "url" {

examples/simple-lambda-in-vpc/example.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module "acs" {
99

1010
module "lambda_api" {
1111
# source = "../../"
12-
source = "github.com/byu-oit/terraform-aws-lambda-api?ref=v1.2.0"
12+
source = "github.com/byu-oit/terraform-aws-lambda-api?ref=v1.3.0"
1313
app_name = "my-lambda"
1414
env = "dev"
1515
lambda_zip_file = "./src/lambda.zip"

examples/simple-lambda-with-deploy-test/example.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module "acs" {
99

1010
module "lambda_api" {
1111
# source = "../../"
12-
source = "github.com/byu-oit/terraform-aws-lambda-api?ref=v1.2.0"
12+
source = "github.com/byu-oit/terraform-aws-lambda-api?ref=v1.3.0"
1313
app_name = "my-lambda-codedeploy"
1414
env = "dev"
1515
codedeploy_service_role_arn = module.acs.power_builder_role.arn

main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ resource "aws_lambda_function" "api_lambda" {
251251
timeout = var.timeout
252252
memory_size = var.memory_size
253253

254+
tracing_config {
255+
mode = var.xray_enabled == true ? "Active" : "PassThrough"
256+
}
257+
254258
dynamic "environment" {
255259
for_each = var.environment_variables != null ? [1] : []
256260
content {

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,8 @@ variable "memory_size" {
127127
description = "Memory Size of the lambda"
128128
default = 128
129129
}
130+
variable "xray_enabled" {
131+
type = bool
132+
description = "Whether or not the X-Ray daemon should be created with the Lambda API."
133+
default = false
134+
}

0 commit comments

Comments
 (0)