Skip to content

Commit dea30f7

Browse files
authored
1 parent 5803a98 commit dea30f7

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

src/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## PR [#814](https://github.com/cloudposse/terraform-aws-components/pull/814)
2+
3+
### Fix for `enabled = false` or Destroy and Recreate
4+
5+
Previously, when `enabled = false` was set, the component would not necessarily
6+
function as desired (deleting any existing resources and not creating any new ones).
7+
Also, previously, when deleting the component, there was a race condition where
8+
the log group could be deleted before the lambda function was deleted, causing
9+
the lambda function to trigger automatic recreation of the log group. This
10+
would result in re-creation failing because Terraform would try to create the
11+
log group but it already existed.
12+
13+
These issues have been fixed in this PR.

src/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Component: `datadog-lambda-forwarder`
22

33
This component is responsible for provision all the necessary infrastructure to
4-
deploy [Datadog Lambda forwarders](https://github.com/DataDog/datadog-serverless-functions/tree/master/aws/logs_monitoring).
4+
deploy [Datadog Lambda forwarders](https://github.com/DataDog/datadog-serverless-functions/tree/master/aws/logs_monitoring). It depends on
5+
the `datadog-configuration` component to get the Datadog API keys.
56

67

78
## Usage
@@ -62,9 +63,9 @@ components:
6263
6364
| Name | Source | Version |
6465
|------|--------|---------|
65-
| <a name="module_datadog-integration"></a> [datadog-integration](#module\_datadog-integration) | cloudposse/stack-config/yaml//modules/remote-state | 1.4.1 |
66+
| <a name="module_datadog-integration"></a> [datadog-integration](#module\_datadog-integration) | cloudposse/stack-config/yaml//modules/remote-state | 1.5.0 |
6667
| <a name="module_datadog_configuration"></a> [datadog\_configuration](#module\_datadog\_configuration) | ../datadog-configuration/modules/datadog_keys | n/a |
67-
| <a name="module_datadog_lambda_forwarder"></a> [datadog\_lambda\_forwarder](#module\_datadog\_lambda\_forwarder) | cloudposse/datadog-lambda-forwarder/aws | 1.3.1 |
68+
| <a name="module_datadog_lambda_forwarder"></a> [datadog\_lambda\_forwarder](#module\_datadog\_lambda\_forwarder) | cloudposse/datadog-lambda-forwarder/aws | 1.5.3 |
6869
| <a name="module_iam_roles"></a> [iam\_roles](#module\_iam\_roles) | ../account-map/modules/iam-roles | n/a |
6970
| <a name="module_log_group_prefix"></a> [log\_group\_prefix](#module\_log\_group\_prefix) | cloudposse/label/null | 0.25.0 |
7071
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
@@ -92,7 +93,7 @@ components:
9293
| <a name="input_datadog_forwarder_lambda_environment_variables"></a> [datadog\_forwarder\_lambda\_environment\_variables](#input\_datadog\_forwarder\_lambda\_environment\_variables) | Map of environment variables to pass to the Lambda Function | `map(string)` | `{}` | no |
9394
| <a name="input_dd_api_key_kms_ciphertext_blob"></a> [dd\_api\_key\_kms\_ciphertext\_blob](#input\_dd\_api\_key\_kms\_ciphertext\_blob) | CiphertextBlob stored in environment variable DD\_KMS\_API\_KEY used by the lambda function, along with the KMS key, to decrypt Datadog API key | `string` | `""` | no |
9495
| <a name="input_dd_artifact_filename"></a> [dd\_artifact\_filename](#input\_dd\_artifact\_filename) | The Datadog artifact filename minus extension | `string` | `"aws-dd-forwarder"` | no |
95-
| <a name="input_dd_forwarder_version"></a> [dd\_forwarder\_version](#input\_dd\_forwarder\_version) | Version tag of Datadog lambdas to use. https://github.com/DataDog/datadog-serverless-functions/releases | `string` | `"3.61.0"` | no |
96+
| <a name="input_dd_forwarder_version"></a> [dd\_forwarder\_version](#input\_dd\_forwarder\_version) | Version tag of Datadog lambdas to use. https://github.com/DataDog/datadog-serverless-functions/releases | `string` | `"3.66.0"` | no |
9697
| <a name="input_dd_module_name"></a> [dd\_module\_name](#input\_dd\_module\_name) | The Datadog GitHub repository name | `string` | `"datadog-serverless-functions"` | no |
9798
| <a name="input_dd_tags_map"></a> [dd\_tags\_map](#input\_dd\_tags\_map) | A map of Datadog tags to apply to all logs forwarded to Datadog | `map(string)` | `{}` | no |
9899
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |

src/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
locals {
2-
enabled = module.this.enabled
2+
enabled = module.this.enabled
3+
lambda_arn_enabled = local.enabled && var.lambda_arn_enabled
34

45
# If any keys contain name_suffix, then use a null label to get the label prefix, and create
56
# the appropriate input for the upstream module.
@@ -40,7 +41,7 @@ module "log_group_prefix" {
4041

4142
module "datadog_lambda_forwarder" {
4243
source = "cloudposse/datadog-lambda-forwarder/aws"
43-
version = "1.3.1"
44+
version = "1.5.3"
4445

4546
cloudwatch_forwarder_log_groups = local.cloudwatch_forwarder_log_groups
4647
cloudwatch_forwarder_event_patterns = var.cloudwatch_forwarder_event_patterns
@@ -88,28 +89,28 @@ module "datadog_lambda_forwarder" {
8889

8990
# Create a new Datadog - Amazon Web Services integration Lambda ARN
9091
resource "datadog_integration_aws_lambda_arn" "rds_collector" {
91-
count = var.lambda_arn_enabled && var.forwarder_rds_enabled ? 1 : 0
92+
count = local.lambda_arn_enabled && var.forwarder_rds_enabled ? 1 : 0
9293

9394
account_id = module.datadog-integration.outputs.aws_account_id
9495
lambda_arn = module.datadog_lambda_forwarder.lambda_forwarder_rds_function_arn
9596
}
9697

9798
resource "datadog_integration_aws_lambda_arn" "vpc_logs_collector" {
98-
count = var.lambda_arn_enabled && var.forwarder_vpc_logs_enabled ? 1 : 0
99+
count = local.lambda_arn_enabled && var.forwarder_vpc_logs_enabled ? 1 : 0
99100

100101
account_id = module.datadog-integration.outputs.aws_account_id
101102
lambda_arn = module.datadog_lambda_forwarder.lambda_forwarder_vpc_log_function_arn
102103
}
103104

104105
resource "datadog_integration_aws_lambda_arn" "log_collector" {
105-
count = var.lambda_arn_enabled && var.forwarder_log_enabled ? 1 : 0
106+
count = local.lambda_arn_enabled && var.forwarder_log_enabled ? 1 : 0
106107

107108
account_id = module.datadog-integration.outputs.aws_account_id
108109
lambda_arn = module.datadog_lambda_forwarder.lambda_forwarder_log_function_arn
109110
}
110111

111112
resource "datadog_integration_aws_log_collection" "main" {
112-
count = var.lambda_arn_enabled ? 1 : 0
113+
count = local.lambda_arn_enabled ? 1 : 0
113114
account_id = module.datadog-integration.outputs.aws_account_id
114115
services = var.log_collection_services
115116

src/remote-state.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module "datadog-integration" {
22
source = "cloudposse/stack-config/yaml//modules/remote-state"
3-
version = "1.4.1"
3+
version = "1.5.0"
44

55
component = "datadog-integration"
66

7-
environment = "gbl"
7+
environment = module.iam_roles.global_environment_name
88
context = module.this.context
99
}

src/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ variable "dd_module_name" {
5555
variable "dd_forwarder_version" {
5656
type = string
5757
description = "Version tag of Datadog lambdas to use. https://github.com/DataDog/datadog-serverless-functions/releases"
58-
default = "3.61.0"
58+
default = "3.66.0"
5959
}
6060

6161
variable "forwarder_log_enabled" {

0 commit comments

Comments
 (0)