Skip to content

Commit

Permalink
fix: rename code_version to sam_release_version
Browse files Browse the repository at this point in the history
The original variable name does not adequately capture there are other
assets beyond code which are of interest to our terraform module. In
particular, we want to be able to get the recommended metric filter
based on the pinned version.
  • Loading branch information
jta committed Jun 7, 2024
1 parent a79d8d8 commit cffabed
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions modules/forwarder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ module "forwarder" {

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_code_uri"></a> [code\_uri](#input\_code\_uri) | S3 URI for lambda binary. If set, takes precedence over code\_version. | `string` | `""` | no |
| <a name="input_code_version"></a> [code\_version](#input\_code\_version) | Binary version as released on github.com/observeinc/aws-sam-apps. | `string` | `""` | no |
| <a name="input_code_uri"></a> [code\_uri](#input\_code\_uri) | S3 URI for lambda binary. If set, takes precedence over sam\_release\_version. | `string` | `""` | no |
| <a name="input_content_type_overrides"></a> [content\_type\_overrides](#input\_content\_type\_overrides) | A list of key value pairs. The key is a regular expression which is<br>applied to the S3 source (<bucket>/<key>) of forwarded files. The value<br>is the content type to set for matching files. For example,<br>`\.json$=application/x-ndjson` would forward all files ending in `.json`<br>as newline delimited JSON | <pre>list(object({<br> pattern = string<br> content_type = string<br> }))</pre> | `[]` | no |
| <a name="input_debug_endpoint"></a> [debug\_endpoint](#input\_debug\_endpoint) | Endpoint to send debugging telemetry to. Sets the OTEL\_EXPORTER\_OTLP\_ENDPOINT environment variable for the lambda function. | `string` | `""` | no |
| <a name="input_destination"></a> [destination](#input\_destination) | Destination filedrop | <pre>object({<br> arn = optional(string, "")<br> bucket = optional(string, "")<br> prefix = optional(string, "")<br> # exclusively for backward compatible HTTP endpoint<br> uri = optional(string, "")<br> })</pre> | n/a | yes |
Expand All @@ -116,6 +115,7 @@ module "forwarder" {
| <a name="input_queue_maximum_batching_window_in_seconds"></a> [queue\_maximum\_batching\_window\_in\_seconds](#input\_queue\_maximum\_batching\_window\_in\_seconds) | The maximum amount of time to gather records before invoking the function, in seconds (between 0 and 300) | `number` | `1` | no |
| <a name="input_queue_message_retention_seconds"></a> [queue\_message\_retention\_seconds](#input\_queue\_message\_retention\_seconds) | Maximum amount of time a message will be retained in queue.<br>This value applies to both source queue and dead letter queue if one<br>exists. | `number` | `345600` | no |
| <a name="input_retention_in_days"></a> [retention\_in\_days](#input\_retention\_in\_days) | Retention in days of cloudwatch log group | `number` | `365` | no |
| <a name="input_sam_release_version"></a> [sam\_release\_version](#input\_sam\_release\_version) | Release version for SAM apps as defined on github.com/observeinc/aws-sam-apps. | `string` | `""` | no |
| <a name="input_source_bucket_names"></a> [source\_bucket\_names](#input\_source\_bucket\_names) | A list of bucket names which the forwarder is allowed to read from. This<br>list only affects permissions, and supports wildcards. In order to have<br>files copied to Filedrop, you must also subscribe S3 Bucket Notifications<br>to the forwarder. | `list(string)` | `[]` | no |
| <a name="input_source_kms_key_arns"></a> [source\_kms\_key\_arns](#input\_source\_kms\_key\_arns) | A list of KMS Key ARNs the forwarder is allowed to use to decrypt objects in S3. | `list(string)` | `[]` | no |
| <a name="input_source_topic_arns"></a> [source\_topic\_arns](#input\_source\_topic\_arns) | A list of SNS topics the forwarder is allowed to be subscribed to. | `list(string)` | `[]` | no |
Expand Down
2 changes: 1 addition & 1 deletion modules/forwarder/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ module "samversion" {
source = "../samversion"
app = "forwarder"
function = "Forwarder"
release = var.code_version
release = var.sam_release_version
}
6 changes: 3 additions & 3 deletions modules/forwarder/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ variable "verbosity" {
default = 1
}

variable "code_version" {
description = "Binary version as released on github.com/observeinc/aws-sam-apps."
variable "sam_release_version" {
description = "Release version for SAM apps as defined on github.com/observeinc/aws-sam-apps."
type = string
default = ""
nullable = false
}

variable "code_uri" {
description = "S3 URI for lambda binary. If set, takes precedence over code_version."
description = "S3 URI for lambda binary. If set, takes precedence over sam_release_version."
type = string
default = ""
nullable = false
Expand Down
4 changes: 2 additions & 2 deletions modules/logwriter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ module "logwriter" {
| <a name="input_bucket_arn"></a> [bucket\_arn](#input\_bucket\_arn) | S3 Bucket ARN to write log records to. | `string` | n/a | yes |
| <a name="input_buffering_interval"></a> [buffering\_interval](#input\_buffering\_interval) | Buffer incoming data for the specified period of time, in seconds, before<br>delivering it to S3. | `number` | `60` | no |
| <a name="input_buffering_size"></a> [buffering\_size](#input\_buffering\_size) | Buffer incoming data to the specified size, in MiBs, before delivering it<br>to S3. | `number` | `1` | no |
| <a name="input_code_uri"></a> [code\_uri](#input\_code\_uri) | S3 URI for lambda binary. If set, takes precedence over code\_version. | `string` | `null` | no |
| <a name="input_code_version"></a> [code\_version](#input\_code\_version) | Binary version as released on github.com/observeinc/aws-sam-apps. | `string` | `null` | no |
| <a name="input_code_uri"></a> [code\_uri](#input\_code\_uri) | S3 URI for lambda binary. If set, takes precedence over sam\_release\_version. | `string` | `null` | no |
| <a name="input_debug_endpoint"></a> [debug\_endpoint](#input\_debug\_endpoint) | Endpoint to send debugging telemetry to. Sets the OTEL\_EXPORTER\_OTLP\_ENDPOINT environment variable for the lambda function. | `string` | `null` | no |
| <a name="input_discovery_rate"></a> [discovery\_rate](#input\_discovery\_rate) | EventBridge rate expression for periodically triggering discovery. If not<br>set, no eventbridge rules are configured. | `string` | `null` | no |
| <a name="input_exclude_log_group_name_patterns"></a> [exclude\_log\_group\_name\_patterns](#input\_exclude\_log\_group\_name\_patterns) | Exclude any log group names matching the provided set of regular<br>expressions. | `list(string)` | `null` | no |
Expand All @@ -109,6 +108,7 @@ module "logwriter" {
| <a name="input_name"></a> [name](#input\_name) | Name for resources. | `string` | n/a | yes |
| <a name="input_num_workers"></a> [num\_workers](#input\_num\_workers) | Maximum number of concurrent workers when processing log groups. | `number` | `null` | no |
| <a name="input_prefix"></a> [prefix](#input\_prefix) | Optional prefix to write log records to. | `string` | `"cloudwatchlogs/"` | no |
| <a name="input_sam_release_version"></a> [sam\_release\_version](#input\_sam\_release\_version) | Release version for SAM apps as defined on github.com/observeinc/aws-sam-apps. | `string` | `null` | no |
| <a name="input_verbosity"></a> [verbosity](#input\_verbosity) | Logging verbosity for Lambda. Highest log verbosity is 9. | `number` | `null` | no |

## Outputs
Expand Down
2 changes: 1 addition & 1 deletion modules/logwriter/subscriber.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ module "subscriber" {
debug_endpoint = var.debug_endpoint
verbosity = var.verbosity
code_uri = var.code_uri
code_version = var.code_version
sam_release_version = var.sam_release_version
}
6 changes: 3 additions & 3 deletions modules/logwriter/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ variable "verbosity" {
default = null
}

variable "code_version" {
description = "Binary version as released on github.com/observeinc/aws-sam-apps."
variable "sam_release_version" {
description = "Release version for SAM apps as defined on github.com/observeinc/aws-sam-apps."
type = string
default = null
}

variable "code_uri" {
description = "S3 URI for lambda binary. If set, takes precedence over code_version."
description = "S3 URI for lambda binary. If set, takes precedence over sam_release_version."
type = string
default = null
}
2 changes: 1 addition & 1 deletion modules/samversion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This is a helper module that given a SAM App name and Lambda function resource I
module "samversion" {
app = "forwarder"
function = "Forwarder"
releasen = "1.19.3"
release = "1.19.3"
}
```

Expand Down
8 changes: 4 additions & 4 deletions modules/samversion/main.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
locals {
latest_release = "1.19.3"
code_version = var.release != "" ? var.release : local.latest_release
code_uri = yamldecode(data.http.manifest.response_body)["Resources"][var.function]["Properties"]["CodeUri"]
latest_release = "1.19.3"
sam_release_version = var.release != "" ? var.release : local.latest_release
code_uri = yamldecode(data.http.manifest.response_body)["Resources"][var.function]["Properties"]["CodeUri"]
}

data "aws_region" "current" {}

data "http" "manifest" {
url = "https://observeinc-${data.aws_region.current.name}.s3.amazonaws.com/aws-sam-apps/${local.code_version}/${var.app}.yaml"
url = "https://observeinc-${data.aws_region.current.name}.s3.amazonaws.com/aws-sam-apps/${local.sam_release_version}/${var.app}.yaml"

lifecycle {
postcondition {
Expand Down
1 change: 1 addition & 0 deletions modules/samversion/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ variable "app" {
variable "function" {
description = "Function name"
type = string
default = ""
nullable = false
}

Expand Down
6 changes: 3 additions & 3 deletions modules/stack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,16 @@ You can additionally configure other submodules in this manner:

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_code_version"></a> [code\_version](#input\_code\_version) | Binary versions as released on github.com/observeinc/aws-sam-apps. | `string` | `null` | no |
| <a name="input_config"></a> [config](#input\_config) | Variables for AWS Config collection. | <pre>object({<br> include_resource_types = list(string)<br> exclude_resource_types = optional(list(string))<br> delivery_frequency = optional(string)<br> include_global_resource_types = optional(bool)<br> })</pre> | `null` | no |
| <a name="input_configsubscription"></a> [configsubscription](#input\_configsubscription) | Variables for AWS Config subscription. | <pre>object({<br> delivery_bucket_name = string<br> })</pre> | `null` | no |
| <a name="input_debug_endpoint"></a> [debug\_endpoint](#input\_debug\_endpoint) | Endpoint to send debugging telemetry to. Sets OTEL\_EXPORTER\_OTLP\_ENDPOINT environment variable for supported lambda functions. | `string` | `null` | no |
| <a name="input_destination"></a> [destination](#input\_destination) | Destination filedrop | <pre>object({<br> arn = optional(string, "")<br> bucket = optional(string, "")<br> prefix = optional(string, "")<br> # exclusively for backward compatible HTTP endpoint<br> uri = optional(string, "")<br> })</pre> | n/a | yes |
| <a name="input_forwarder"></a> [forwarder](#input\_forwarder) | Variables for forwarder module. | <pre>object({<br> source_bucket_names = optional(list(string), [])<br> source_topic_arns = optional(list(string), [])<br> content_type_overrides = optional(list(object({ pattern = string, content_type = string })), [])<br> max_file_size = optional(number)<br> lambda_memory_size = optional(number)<br> lambda_timeout = optional(number)<br> lambda_env_vars = optional(map(string))<br> retention_in_days = optional(number)<br> queue_max_receive_count = optional(number)<br> queue_delay_seconds = optional(number)<br> queue_message_retention_seconds = optional(number)<br> queue_batch_size = optional(number)<br> queue_maximum_batching_window_in_seconds = optional(number)<br> code_uri = optional(string)<br> code_version = optional(string)<br> })</pre> | `{}` | no |
| <a name="input_logwriter"></a> [logwriter](#input\_logwriter) | Variables for AWS CloudWatch Logs collection. | <pre>object({<br> log_group_name_patterns = optional(list(string))<br> log_group_name_prefixes = optional(list(string))<br> exclude_log_group_name_prefixes = optional(list(string))<br> buffering_interval = optional(number)<br> buffering_size = optional(number)<br> filter_name = optional(string)<br> filter_pattern = optional(string)<br> num_workers = optional(number)<br> discovery_rate = optional(string, "24 hours")<br> lambda_memory_size = optional(number)<br> lambda_timeout = optional(number)<br> code_uri = optional(string)<br> code_version = optional(string)<br> })</pre> | `null` | no |
| <a name="input_forwarder"></a> [forwarder](#input\_forwarder) | Variables for forwarder module. | <pre>object({<br> source_bucket_names = optional(list(string), [])<br> source_topic_arns = optional(list(string), [])<br> content_type_overrides = optional(list(object({ pattern = string, content_type = string })), [])<br> max_file_size = optional(number)<br> lambda_memory_size = optional(number)<br> lambda_timeout = optional(number)<br> lambda_env_vars = optional(map(string))<br> retention_in_days = optional(number)<br> queue_max_receive_count = optional(number)<br> queue_delay_seconds = optional(number)<br> queue_message_retention_seconds = optional(number)<br> queue_batch_size = optional(number)<br> queue_maximum_batching_window_in_seconds = optional(number)<br> code_uri = optional(string)<br> sam_release_version = optional(string)<br> })</pre> | `{}` | no |
| <a name="input_logwriter"></a> [logwriter](#input\_logwriter) | Variables for AWS CloudWatch Logs collection. | <pre>object({<br> log_group_name_patterns = optional(list(string))<br> log_group_name_prefixes = optional(list(string))<br> exclude_log_group_name_prefixes = optional(list(string))<br> buffering_interval = optional(number)<br> buffering_size = optional(number)<br> filter_name = optional(string)<br> filter_pattern = optional(string)<br> num_workers = optional(number)<br> discovery_rate = optional(string, "24 hours")<br> lambda_memory_size = optional(number)<br> lambda_timeout = optional(number)<br> code_uri = optional(string)<br> sam_release_version = optional(string)<br> })</pre> | `null` | no |
| <a name="input_metricstream"></a> [metricstream](#input\_metricstream) | Variables for AWS CloudWatch Metrics Stream collection. | <pre>object({<br> include_filters = optional(list(object({ namespace = string, metric_names = optional(list(string)) })))<br> exclude_filters = optional(list(object({ namespace = string, metric_names = optional(list(string)) })))<br> buffering_interval = optional(number)<br> buffering_size = optional(number)<br> })</pre> | `null` | no |
| <a name="input_name"></a> [name](#input\_name) | Name of role. Since this name must be unique within the<br>account, it will be reused for most of the resources created by this<br>module. | `string` | n/a | yes |
| <a name="input_s3_bucket_lifecycle_expiration"></a> [s3\_bucket\_lifecycle\_expiration](#input\_s3\_bucket\_lifecycle\_expiration) | Expiration in days for S3 objects in collection bucket | `number` | `4` | no |
| <a name="input_sam_release_version"></a> [sam\_release\_version](#input\_sam\_release\_version) | Release version for SAM apps as defined on github.com/observeinc/aws-sam-apps. | `string` | `null` | no |
| <a name="input_verbosity"></a> [verbosity](#input\_verbosity) | Logging verbosity for Lambda. Highest log verbosity is 9. | `number` | `null` | no |

## Outputs
Expand Down
2 changes: 1 addition & 1 deletion modules/stack/forwarder.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ module "forwarder" {
debug_endpoint = var.debug_endpoint
verbosity = var.verbosity
code_uri = var.forwarder.code_uri
code_version = try(coalesce(var.forwarder.code_version, var.code_version), null)
sam_release_version = try(coalesce(var.forwarder.sam_release_version, var.sam_release_version), null)
}
2 changes: 1 addition & 1 deletion modules/stack/logwriter.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module "logwriter" {
debug_endpoint = var.debug_endpoint
verbosity = var.verbosity
code_uri = var.logwriter.code_uri
code_version = try(coalesce(var.logwriter.code_version, var.code_version), null)
sam_release_version = try(coalesce(var.logwriter.sam_release_version, var.sam_release_version), null)

depends_on = [aws_s3_bucket_notification.this]
}
8 changes: 4 additions & 4 deletions modules/stack/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ variable "forwarder" {
queue_batch_size = optional(number)
queue_maximum_batching_window_in_seconds = optional(number)
code_uri = optional(string)
code_version = optional(string)
sam_release_version = optional(string)
})
default = {}
nullable = false
Expand Down Expand Up @@ -89,7 +89,7 @@ variable "logwriter" {
lambda_memory_size = optional(number)
lambda_timeout = optional(number)
code_uri = optional(string)
code_version = optional(string)
sam_release_version = optional(string)
})
default = null
}
Expand Down Expand Up @@ -125,8 +125,8 @@ variable "verbosity" {
default = null
}

variable "code_version" {
description = "Binary versions as released on github.com/observeinc/aws-sam-apps."
variable "sam_release_version" {
description = "Release version for SAM apps as defined on github.com/observeinc/aws-sam-apps."
type = string
default = null
}
Loading

0 comments on commit cffabed

Please sign in to comment.