Skip to content

Commit 7d4afd7

Browse files
authored
Datadog Upstreams and Account Settings (cloudposse/terraform-aws-components#533)
1 parent 2a28e23 commit 7d4afd7

File tree

3 files changed

+11
-47
lines changed

3 files changed

+11
-47
lines changed

src/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ components:
4141
transfer-sftp:
4242
name: "/aws/transfer/s-xxxxxxxxxxxx"
4343
filter_pattern: ""
44-
dd_api_key_source:
45-
resource: "ssm"
46-
identifier: "datadog/datadog_api_key"
4744
```
4845
4946
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
@@ -67,7 +64,7 @@ components:
6764
|------|--------|---------|
6865
| <a name="module_datadog-integration"></a> [datadog-integration](#module\_datadog-integration) | cloudposse/stack-config/yaml//modules/remote-state | 1.3.1 |
6966
| <a name="module_datadog_configuration"></a> [datadog\_configuration](#module\_datadog\_configuration) | ../datadog-configuration/modules/datadog_keys | n/a |
70-
| <a name="module_datadog_lambda_forwarder"></a> [datadog\_lambda\_forwarder](#module\_datadog\_lambda\_forwarder) | cloudposse/datadog-lambda-forwarder/aws | 1.0.0 |
67+
| <a name="module_datadog_lambda_forwarder"></a> [datadog\_lambda\_forwarder](#module\_datadog\_lambda\_forwarder) | cloudposse/datadog-lambda-forwarder/aws | 1.1.0 |
7168
| <a name="module_iam_roles"></a> [iam\_roles](#module\_iam\_roles) | ../account-map/modules/iam-roles | n/a |
7269
| <a name="module_log_group_prefix"></a> [log\_group\_prefix](#module\_log\_group\_prefix) | cloudposse/label/null | 0.25.0 |
7370
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
@@ -93,7 +90,6 @@ components:
9390
| <a name="input_context_tags_enabled"></a> [context\_tags\_enabled](#input\_context\_tags\_enabled) | Whether to add context tags to add to each monitor | `bool` | `true` | no |
9491
| <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 |
9592
| <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 |
96-
| <a name="input_dd_api_key_source"></a> [dd\_api\_key\_source](#input\_dd\_api\_key\_source) | One of: ARN for AWS Secrets Manager (asm) to retrieve the Datadog (DD) api key, ARN for the KMS (kms) key used to decrypt the ciphertext\_blob of the api key, or the name of the SSM (ssm) parameter used to retrieve the Datadog API key | <pre>object({<br> resource = string<br> identifier = string<br> })</pre> | <pre>{<br> "identifier": "",<br> "resource": ""<br>}</pre> | no |
9793
| <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 |
9894
| <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 |
9995
| <a name="input_dd_module_name"></a> [dd\_module\_name](#input\_dd\_module\_name) | The Datadog GitHub repository name | `string` | `"datadog-serverless-functions"` | no |

src/main.tf

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ module "log_group_prefix" {
4040

4141
module "datadog_lambda_forwarder" {
4242
source = "cloudposse/datadog-lambda-forwarder/aws"
43-
version = "1.0.0"
43+
version = "1.1.0"
4444

45-
cloudwatch_forwarder_log_groups = local.cloudwatch_forwarder_log_groups
46-
dd_api_key_kms_ciphertext_blob = var.dd_api_key_kms_ciphertext_blob
47-
dd_api_key_source = var.dd_api_key_source
45+
cloudwatch_forwarder_log_groups = local.cloudwatch_forwarder_log_groups
46+
dd_api_key_kms_ciphertext_blob = var.dd_api_key_kms_ciphertext_blob
47+
dd_api_key_source = {
48+
resource = lower(module.datadog_configuration.datadog_secrets_store_type)
49+
identifier = module.datadog_configuration.datadog_api_key_location
50+
}
4851
dd_artifact_filename = var.dd_artifact_filename
4952
dd_forwarder_version = var.dd_forwarder_version
5053
dd_module_name = var.dd_module_name
@@ -76,6 +79,8 @@ module "datadog_lambda_forwarder" {
7679

7780
datadog_forwarder_lambda_environment_variables = var.datadog_forwarder_lambda_environment_variables
7881

82+
api_key_ssm_arn = module.datadog_configuration.api_key_ssm_arn
83+
7984
context = module.this.context
8085
}
8186

src/variables.tf

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,43 +34,6 @@ variable "tracing_config_mode" {
3434
default = "PassThrough"
3535
}
3636

37-
variable "dd_api_key_source" {
38-
description = "One of: ARN for AWS Secrets Manager (asm) to retrieve the Datadog (DD) api key, ARN for the KMS (kms) key used to decrypt the ciphertext_blob of the api key, or the name of the SSM (ssm) parameter used to retrieve the Datadog API key"
39-
type = object({
40-
resource = string
41-
identifier = string
42-
})
43-
44-
default = {
45-
resource = ""
46-
identifier = ""
47-
}
48-
49-
# Resource can be one of kms, asm, ssm ("" to disable all lambda resources)
50-
validation {
51-
condition = can(regex("(kms|asm|ssm)", var.dd_api_key_source.resource)) || var.dd_api_key_source.resource == ""
52-
error_message = "Provide one, and only one, ARN for (kms, asm) or name (ssm) to retrieve or decrypt Datadog api key."
53-
}
54-
55-
# Check KMS ARN format
56-
validation {
57-
condition = var.dd_api_key_source.resource == "kms" ? can(regex("arn:.*:kms:.*:key/.*", var.dd_api_key_source.identifier)) : true
58-
error_message = "ARN for KMS key does not appear to be valid format (example: arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab)."
59-
}
60-
61-
# Check ASM ARN format
62-
validation {
63-
condition = var.dd_api_key_source.resource == "asm" ? can(regex("arn:.*:secretsmanager:.*:secret:.*", var.dd_api_key_source.identifier)) : true
64-
error_message = "ARN for AWS Secrets Manager (asm) does not appear to be valid format (example: arn:aws:secretsmanager:us-west-2:111122223333:secret:aes128-1a2b3c)."
65-
}
66-
67-
# Check SSM name format
68-
validation {
69-
condition = var.dd_api_key_source.resource == "ssm" ? can(regex("^[a-zA-Z0-9_./-]+$", var.dd_api_key_source.identifier)) : true
70-
error_message = "Name for SSM parameter does not appear to be valid format, acceptable characters are `a-zA-Z0-9_.-` and `/` to delineate hierarchies."
71-
}
72-
}
73-
7437
variable "dd_api_key_kms_ciphertext_blob" {
7538
type = string
7639
description = "CiphertextBlob stored in environment variable DD_KMS_API_KEY used by the lambda function, along with the KMS key, to decrypt Datadog API key"
@@ -240,7 +203,7 @@ variable "lambda_arn_enabled" {
240203
curl -X GET "${DD_API_URL}/api/v1/integration/aws/logs/services" \
241204
-H "Accept: application/json" \
242205
-H "DD-API-KEY: ${DD_API_KEY}" \
243-
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
206+
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" | jq '.[] | .id'
244207
**/
245208
variable "log_collection_services" {
246209
type = list(string)

0 commit comments

Comments
 (0)