diff --git a/README.md b/README.md index 3b137d7..f64592e 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,9 @@ Terraform module which sets up a Lambda to forward event data towards Observe. module "observe_lambda" { source = "observeinc/lambda/aws" - name = "observe-lambda" - observe_customer = "" - observe_token = "" + name = "observe-lambda" + observe_collection_endpoint = "https://.collect.observeinc.com" + observe_token = "" } ``` @@ -76,8 +76,9 @@ No modules. | [lambda\_version](#input\_lambda\_version) | Version of lambda binary to use | `string` | `"latest"` | no | | [memory\_size](#input\_memory\_size) | The amount of memory that your function has access to. Increasing the function's memory also increases its CPU allocation.
The default value is 128 MB. The value must be a multiple of 64 MB. | `number` | `128` | no | | [name](#input\_name) | Name of Lambda resource | `string` | n/a | yes | -| [observe\_customer](#input\_observe\_customer) | Observe Customer ID | `string` | n/a | yes | -| [observe\_domain](#input\_observe\_domain) | Observe domain | `string` | `"observeinc.com"` | no | +| [observe\_collection\_endpoint](#input\_observe\_collection\_endpoint) | Observe Collection Endpoint, e.g https://123456789012.collect.observeinc.com | `string` | `null` | no | +| [observe\_customer](#input\_observe\_customer) | Observe Customer ID. Deprecated, please use observe\_collection\_endpoint instead | `string` | `null` | no | +| [observe\_domain](#input\_observe\_domain) | Observe domain. Deprecated, please use observe\_collection\_endpoint instead | `string` | `"observeinc.com"` | no | | [observe\_token](#input\_observe\_token) | Observe Token | `string` | n/a | yes | | [reserved\_concurrent\_executions](#input\_reserved\_concurrent\_executions) | The number of simultaneous executions to reserve for the function. | `number` | `100` | no | | [retention\_in\_days](#input\_retention\_in\_days) | Retention in days of cloudwatch log group | `number` | `14` | no | diff --git a/examples/cloudtrail/README.md b/examples/cloudtrail/README.md index 69246d3..836684d 100644 --- a/examples/cloudtrail/README.md +++ b/examples/cloudtrail/README.md @@ -58,8 +58,7 @@ Note that this will create AWS resources - once you are done, run `terraform des | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [observe\_customer](#input\_observe\_customer) | Observe Customer ID | `string` | n/a | yes | -| [observe\_domain](#input\_observe\_domain) | Observe Domain | `string` | `null` | no | +| [observe\_collection\_endpoint](#input\_observe\_collection\_endpoint) | Observe Collection Endpoint, e.g https://123456789012.collect.observeinc.com | `string` | n/a | yes | | [observe\_token](#input\_observe\_token) | Observe token | `string` | n/a | yes | ## Outputs diff --git a/examples/cloudtrail/main.tf b/examples/cloudtrail/main.tf index ee7377f..dfd6242 100644 --- a/examples/cloudtrail/main.tf +++ b/examples/cloudtrail/main.tf @@ -23,11 +23,10 @@ module "cloudtrail" { } module "observe_lambda" { - source = "../.." - observe_customer = var.observe_customer - observe_token = var.observe_token - observe_domain = var.observe_domain - name = random_pet.run.id + source = "../.." + observe_collection_endpoint = var.observe_collection_endpoint + observe_token = var.observe_token + name = random_pet.run.id } module "observe_lambda_s3_subscription" { diff --git a/examples/cloudtrail/variables.tf b/examples/cloudtrail/variables.tf index b05f9d3..d145d04 100644 --- a/examples/cloudtrail/variables.tf +++ b/examples/cloudtrail/variables.tf @@ -1,5 +1,5 @@ -variable "observe_customer" { - description = "Observe Customer ID" +variable "observe_collection_endpoint" { + description = "Observe Collection Endpoint, e.g https://123456789012.collect.observeinc.com" type = string } @@ -7,9 +7,3 @@ variable "observe_token" { description = "Observe token" type = string } - -variable "observe_domain" { - description = "Observe Domain" - type = string - default = null -} diff --git a/examples/s3_access_logs/README.md b/examples/s3_access_logs/README.md index 661ecf3..ebe544b 100644 --- a/examples/s3_access_logs/README.md +++ b/examples/s3_access_logs/README.md @@ -60,8 +60,7 @@ Note that this will create AWS resources - once you are done, run `terraform des | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [name](#input\_name) | Lambda name | `string` | n/a | yes | -| [observe\_customer](#input\_observe\_customer) | Observe Customer ID | `string` | n/a | yes | -| [observe\_domain](#input\_observe\_domain) | Observe Domain | `string` | `null` | no | +| [observe\_collection\_endpoint](#input\_observe\_collection\_endpoint) | Observe Collection Endpoint, e.g https://123456789012.collect.observeinc.com | `string` | n/a | yes | | [observe\_token](#input\_observe\_token) | Observe token | `string` | n/a | yes | ## Outputs diff --git a/examples/s3_access_logs/main.tf b/examples/s3_access_logs/main.tf index 443ae5d..7dea45d 100644 --- a/examples/s3_access_logs/main.tf +++ b/examples/s3_access_logs/main.tf @@ -27,11 +27,10 @@ resource "aws_s3_bucket_acl" "access_logs" { } module "observe_lambda" { - source = "../.." - observe_customer = var.observe_customer - observe_token = var.observe_token - observe_domain = var.observe_domain - name = var.name + source = "../.." + observe_collection_endpoint = var.observe_collection_endpoint + observe_token = var.observe_token + name = var.name } module "observe_lambda_s3_subscription" { diff --git a/examples/s3_access_logs/variables.tf b/examples/s3_access_logs/variables.tf index 559147d..5f645a0 100644 --- a/examples/s3_access_logs/variables.tf +++ b/examples/s3_access_logs/variables.tf @@ -1,5 +1,5 @@ -variable "observe_customer" { - description = "Observe Customer ID" +variable "observe_collection_endpoint" { + description = "Observe Collection Endpoint, e.g https://123456789012.collect.observeinc.com" type = string } @@ -8,12 +8,6 @@ variable "observe_token" { type = string } -variable "observe_domain" { - description = "Observe Domain" - type = string - default = null -} - variable "name" { description = "Lambda name" type = string diff --git a/examples/s3_bucket/README.md b/examples/s3_bucket/README.md index c39ea2a..68e1e01 100644 --- a/examples/s3_bucket/README.md +++ b/examples/s3_bucket/README.md @@ -58,8 +58,7 @@ Note that this will create AWS resources - once you are done, run `terraform des | [bucket\_count](#input\_bucket\_count) | Number of buckets to create and subscribe. | `number` | `1` | no | | [filter\_prefix](#input\_filter\_prefix) | Specifies object key name prefix on S3 bucket notifications. | `string` | `null` | no | | [filter\_suffix](#input\_filter\_suffix) | Specifies object key name suffix on S3 bucket notifications. | `string` | `null` | no | -| [observe\_customer](#input\_observe\_customer) | Observe Customer ID | `string` | n/a | yes | -| [observe\_domain](#input\_observe\_domain) | Observe Domain | `string` | `null` | no | +| [observe\_collection\_endpoint](#input\_observe\_collection\_endpoint) | Observe Collection Endpoint, e.g https://123456789012.collect.observeinc.com | `string` | n/a | yes | | [observe\_token](#input\_observe\_token) | Observe token | `string` | n/a | yes | ## Outputs diff --git a/examples/s3_bucket/main.tf b/examples/s3_bucket/main.tf index 9796f28..75f71de 100644 --- a/examples/s3_bucket/main.tf +++ b/examples/s3_bucket/main.tf @@ -9,11 +9,10 @@ module "observe_s3_bucket" { } module "observe_lambda" { - source = "../.." - observe_customer = var.observe_customer - observe_token = var.observe_token - observe_domain = var.observe_domain - name = random_pet.run.id + source = "../.." + observe_collection_endpoint = var.observe_collection_endpoint + observe_token = var.observe_token + name = random_pet.run.id } module "observe_lambda_s3_subscription" { diff --git a/examples/s3_bucket/variables.tf b/examples/s3_bucket/variables.tf index 3102c7a..9777bee 100644 --- a/examples/s3_bucket/variables.tf +++ b/examples/s3_bucket/variables.tf @@ -1,5 +1,5 @@ -variable "observe_customer" { - description = "Observe Customer ID" +variable "observe_collection_endpoint" { + description = "Observe Collection Endpoint, e.g https://123456789012.collect.observeinc.com" type = string } @@ -8,12 +8,6 @@ variable "observe_token" { type = string } -variable "observe_domain" { - description = "Observe Domain" - type = string - default = null -} - variable "bucket_count" { description = "Number of buckets to create and subscribe." type = number diff --git a/examples/vpc_config/README.md b/examples/vpc_config/README.md index e14464c..d63f76c 100644 --- a/examples/vpc_config/README.md +++ b/examples/vpc_config/README.md @@ -61,8 +61,7 @@ Note that this will create AWS resources - once you are done, run `terraform des | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [observe\_customer](#input\_observe\_customer) | Observe Customer ID | `string` | n/a | yes | -| [observe\_domain](#input\_observe\_domain) | Observe Domain | `string` | `"observeinc.com"` | no | +| [observe\_collection\_endpoint](#input\_observe\_collection\_endpoint) | Observe Collection Endpoint, e.g https://123456789012.collect.observeinc.com | `string` | n/a | yes | | [observe\_token](#input\_observe\_token) | Observe token | `string` | n/a | yes | ## Outputs diff --git a/examples/vpc_config/main.tf b/examples/vpc_config/main.tf index 166dc12..205cef6 100644 --- a/examples/vpc_config/main.tf +++ b/examples/vpc_config/main.tf @@ -10,10 +10,9 @@ resource "random_pet" "run" { module "observe_lambda" { source = "../.." - name = random_pet.run.id - observe_domain = var.observe_domain - observe_customer = var.observe_customer - observe_token = var.observe_token + name = random_pet.run.id + observe_collection_endpoint = var.observe_collection_endpoint + observe_token = var.observe_token vpc_config = { subnets = [aws_subnet.private] diff --git a/examples/vpc_config/variables.tf b/examples/vpc_config/variables.tf index d655013..d145d04 100644 --- a/examples/vpc_config/variables.tf +++ b/examples/vpc_config/variables.tf @@ -1,5 +1,5 @@ -variable "observe_customer" { - description = "Observe Customer ID" +variable "observe_collection_endpoint" { + description = "Observe Collection Endpoint, e.g https://123456789012.collect.observeinc.com" type = string } @@ -7,9 +7,3 @@ variable "observe_token" { description = "Observe token" type = string } - -variable "observe_domain" { - description = "Observe Domain" - type = string - default = "observeinc.com" -} diff --git a/main.tf b/main.tf index 9aaf9b3..56e675b 100644 --- a/main.tf +++ b/main.tf @@ -54,8 +54,8 @@ resource "aws_lambda_function" "this" { environment { variables = merge({ - OBSERVE_URL = format("https://%s.collect.%s/v1/http", var.observe_customer, var.observe_domain) - OBSERVE_TOKEN = var.observe_token + OBSERVE_COLLECTION_ENDPOINT = var.observe_collection_endpoint != null ? var.observe_collection_endpoint : format("https://%s.collect.%s", var.observe_customer, var.observe_domain) + OBSERVE_TOKEN = var.observe_token }, length(var.lambda_s3_custom_rules) > 0 ? { S3_CUSTOM_RULES = base64encode(jsonencode(var.lambda_s3_custom_rules)) } : {} diff --git a/modules/cloudwatch_logs_subscription/README.md b/modules/cloudwatch_logs_subscription/README.md index 7951667..ecb478d 100644 --- a/modules/cloudwatch_logs_subscription/README.md +++ b/modules/cloudwatch_logs_subscription/README.md @@ -19,11 +19,10 @@ resource "aws_cloudwatch_log_group" "group" { } module "observe_lambda" { - source = "observeinc/lambda/aws" - observe_customer = var.observe_customer - observe_token = var.observe_token - observe_domain = var.observe_domain - name = random_pet.run.id + source = "observeinc/lambda/aws" + observe_collection_endpoint = var.observe_collection_endpoint + observe_token = var.observe_token + name = random_pet.run.id } module "observe_lambda_cloudwatch_logs_subscription" { diff --git a/modules/cloudwatch_metrics/README.md b/modules/cloudwatch_metrics/README.md index 002b680..3c4df2d 100644 --- a/modules/cloudwatch_metrics/README.md +++ b/modules/cloudwatch_metrics/README.md @@ -15,11 +15,10 @@ Lambda to ensure that all requested endpoints are accessible. ```hcl module "observe_lambda" { - source = "observeinc/lambda/aws" - observe_customer = var.observe_customer - observe_token = var.observe_token - observe_domain = var.observe_domain - name = random_pet.run.id + source = "observeinc/lambda/aws" + observe_collection_endpoint = var.observe_collection_endpoint + observe_token = var.observe_token + name = random_pet.run.id } module "cloudwatch_metrics" { diff --git a/modules/s3_bucket/README.md b/modules/s3_bucket/README.md index 023298f..b9937fc 100644 --- a/modules/s3_bucket/README.md +++ b/modules/s3_bucket/README.md @@ -13,11 +13,10 @@ module "observe_s3_bucket" } module "observe_lambda" { - source = "observeinc/lambda/aws" - observe_customer = var.observe_customer - observe_token = var.observe_token - observe_domain = var.observe_domain - name = random_pet.run.id + source = "observeinc/lambda/aws" + observe_collection_endpoint = var.observe_collection_endpoint + observe_token = var.observe_token + name = random_pet.run.id } module "observe_lambda_s3_subscription" { diff --git a/modules/s3_bucket_subscription/README.md b/modules/s3_bucket_subscription/README.md index 69d49fa..deb4103 100644 --- a/modules/s3_bucket_subscription/README.md +++ b/modules/s3_bucket_subscription/README.md @@ -14,11 +14,10 @@ resource "aws_s3_bucket" "bucket" { } module "observe_lambda" { - source = "observeinc/lambda/aws" - observe_customer = var.observe_customer - observe_token = var.observe_token - observe_domain = var.observe_domain - name = random_pet.run.id + source = "observeinc/lambda/aws" + observe_collection_endpoint = var.observe_collection_endpoint + observe_token = var.observe_token + name = random_pet.run.id } module "observe_lambda_s3_subscription" { diff --git a/modules/snapshot/README.md b/modules/snapshot/README.md index 8801005..6688273 100644 --- a/modules/snapshot/README.md +++ b/modules/snapshot/README.md @@ -9,11 +9,10 @@ to ensure that all requested endpoints are accessible. ```hcl module "observe_lambda" { - source = "observeinc/lambda/aws" - observe_customer = var.observe_customer - observe_token = var.observe_token - observe_domain = var.observe_domain - name = random_pet.run.id + source = "observeinc/lambda/aws" + observe_collection_endpoint = var.observe_collection_endpoint + observe_token = var.observe_token + name = random_pet.run.id } module "observe_lambda_snapshot" { diff --git a/variables.tf b/variables.tf index 56c5871..50d0d8e 100644 --- a/variables.tf +++ b/variables.tf @@ -3,9 +3,20 @@ variable "name" { type = string } +variable "observe_collection_endpoint" { + description = "Observe Collection Endpoint, e.g https://123456789012.collect.observeinc.com" + type = string + default = null + validation { + condition = var.observe_collection_endpoint == null || can(regex("^https://.*$", var.observe_collection_endpoint)) + error_message = "Endpoint must be a valid HTTPS URL." + } +} + variable "observe_customer" { - description = "Observe Customer ID" + description = "Observe Customer ID. Deprecated, please use observe_collection_endpoint instead" type = string + default = null } variable "observe_token" { @@ -18,9 +29,8 @@ variable "observe_token" { } } -# Optional input variables variable "observe_domain" { - description = "Observe domain" + description = "Observe domain. Deprecated, please use observe_collection_endpoint instead" type = string nullable = false default = "observeinc.com"