Skip to content

Commit 64691cf

Browse files
authored
1 parent b81de5f commit 64691cf

File tree

10 files changed

+27
-203
lines changed

10 files changed

+27
-203
lines changed

src/README.md

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ components:
2121
spacelift:
2222
workspace_enabled: true
2323
vars:
24-
datadog_secrets_store_type: SSM
25-
datadog_secrets_source_store_account: "tools"
26-
datadog_secrets_source_store_region: "us-west-2"
27-
datadog_api_secret_key: "dev"
28-
datadog_app_secret_key: "dev"
24+
enabled: true
2925
```
3026
3127
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
@@ -34,35 +30,25 @@ components:
3430
| Name | Version |
3531
|------|---------|
3632
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
37-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 4.0 |
33+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.9.0 |
3834
| <a name="requirement_datadog"></a> [datadog](#requirement\_datadog) | >= 3.3.0 |
3935
4036
## Providers
4137
42-
| Name | Version |
43-
|------|---------|
44-
| <a name="provider_aws.api_keys"></a> [aws.api\_keys](#provider\_aws.api\_keys) | ~> 4.0 |
38+
No providers.
4539
4640
## Modules
4741
4842
| Name | Source | Version |
4943
|------|--------|---------|
50-
| <a name="module_datadog_integration"></a> [datadog\_integration](#module\_datadog\_integration) | cloudposse/datadog-integration/aws | 0.18.0 |
44+
| <a name="module_datadog_configuration"></a> [datadog\_configuration](#module\_datadog\_configuration) | ../datadog-configuration/modules/datadog_keys | n/a |
45+
| <a name="module_datadog_integration"></a> [datadog\_integration](#module\_datadog\_integration) | cloudposse/datadog-integration/aws | 1.0.0 |
5146
| <a name="module_iam_roles"></a> [iam\_roles](#module\_iam\_roles) | ../account-map/modules/iam-roles | n/a |
52-
| <a name="module_iam_roles_datadog_secrets"></a> [iam\_roles\_datadog\_secrets](#module\_iam\_roles\_datadog\_secrets) | ../account-map/modules/iam-roles | n/a |
53-
| <a name="module_store_write"></a> [store\_write](#module\_store\_write) | cloudposse/ssm-parameter-store/aws | 0.10.0 |
5447
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
5548
5649
## Resources
5750
58-
| Name | Type |
59-
|------|------|
60-
| [aws_secretsmanager_secret.datadog_api_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/secretsmanager_secret) | data source |
61-
| [aws_secretsmanager_secret.datadog_app_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/secretsmanager_secret) | data source |
62-
| [aws_secretsmanager_secret_version.datadog_api_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/secretsmanager_secret_version) | data source |
63-
| [aws_secretsmanager_secret_version.datadog_app_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/secretsmanager_secret_version) | data source |
64-
| [aws_ssm_parameter.datadog_api_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
65-
| [aws_ssm_parameter.datadog_app_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
51+
No resources.
6652
6753
## Inputs
6854
@@ -73,16 +59,7 @@ components:
7359
| <a name="input_attributes"></a> [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,<br>in the order they appear in the list. New attributes are appended to the<br>end of the list. The elements of the list are joined by the `delimiter`<br>and treated as a single ID element. | `list(string)` | `[]` | no |
7460
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
7561
| <a name="input_context_host_and_filter_tags"></a> [context\_host\_and\_filter\_tags](#input\_context\_host\_and\_filter\_tags) | Automatically add host and filter tags for these context keys | `list(string)` | <pre>[<br> "namespace",<br> "tenant",<br> "stage"<br>]</pre> | no |
76-
| <a name="input_datadog_api_secret_key"></a> [datadog\_api\_secret\_key](#input\_datadog\_api\_secret\_key) | The name of the Datadog API secret | `string` | `"default"` | no |
77-
| <a name="input_datadog_api_secret_key_source_pattern"></a> [datadog\_api\_secret\_key\_source\_pattern](#input\_datadog\_api\_secret\_key\_source\_pattern) | The format string (%v will be replaced by the var.datadog\_api\_secret\_key) for the key of the Datadog API secret in the source account | `string` | `"/datadog/%v/datadog_api_key"` | no |
78-
| <a name="input_datadog_api_secret_key_target_pattern"></a> [datadog\_api\_secret\_key\_target\_pattern](#input\_datadog\_api\_secret\_key\_target\_pattern) | The format string (%v will be replaced by the var.datadog\_api\_secret\_key) for the key of the Datadog API secret in the target account | `string` | `"/datadog/datadog_api_key"` | no |
79-
| <a name="input_datadog_app_secret_key"></a> [datadog\_app\_secret\_key](#input\_datadog\_app\_secret\_key) | The name of the Datadog APP secret | `string` | `"default"` | no |
80-
| <a name="input_datadog_app_secret_key_source_pattern"></a> [datadog\_app\_secret\_key\_source\_pattern](#input\_datadog\_app\_secret\_key\_source\_pattern) | The format string (%v will be replaced by the var.datadog\_app\_secret\_key) for the key of the Datadog APP secret in the source account | `string` | `"/datadog/%v/datadog_app_key"` | no |
81-
| <a name="input_datadog_app_secret_key_target_pattern"></a> [datadog\_app\_secret\_key\_target\_pattern](#input\_datadog\_app\_secret\_key\_target\_pattern) | The format string (%v will be replaced by the var.datadog\_api\_secret\_key) for the key of the Datadog APP secret in the target account | `string` | `"/datadog/datadog_app_key"` | no |
8262
| <a name="input_datadog_aws_account_id"></a> [datadog\_aws\_account\_id](#input\_datadog\_aws\_account\_id) | The AWS account ID Datadog's integration servers use for all integrations | `string` | `"464622532012"` | no |
83-
| <a name="input_datadog_secrets_source_store_account_stage"></a> [datadog\_secrets\_source\_store\_account\_stage](#input\_datadog\_secrets\_source\_store\_account\_stage) | Stage holding Secret Store for Datadog API and app keys. | `string` | `"tools"` | no |
84-
| <a name="input_datadog_secrets_source_store_account_tenant"></a> [datadog\_secrets\_source\_store\_account\_tenant](#input\_datadog\_secrets\_source\_store\_account\_tenant) | Tenant holding Secret Store for Datadog API and app keys. | `string` | `"core"` | no |
85-
| <a name="input_datadog_secrets_store_type"></a> [datadog\_secrets\_store\_type](#input\_datadog\_secrets\_store\_type) | Secret Store type for Datadog API and app keys. Valid values: `SSM`, `ASM` | `string` | `"SSM"` | no |
8663
| <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 |
8764
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
8865
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |

src/asm.tf

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/default.auto.tfvars

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/main.tf

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module "datadog_integration" {
22
source = "cloudposse/datadog-integration/aws"
3-
version = "0.18.0"
3+
version = "1.0.0"
4+
5+
count = module.this.enabled && length(var.integrations) > 0 ? 1 : 0
46

57
datadog_aws_account_id = var.datadog_aws_account_id
68
integrations = var.integrations
@@ -13,13 +15,7 @@ module "datadog_integration" {
1315
}
1416

1517
locals {
16-
enabled = module.this.enabled
17-
asm_enabled = local.enabled && var.datadog_secrets_store_type == "ASM"
18-
ssm_enabled = local.enabled && var.datadog_secrets_store_type == "SSM"
19-
20-
# https://docs.datadoghq.com/account_management/api-app-keys/
21-
datadog_api_key = local.enabled ? (local.asm_enabled ? data.aws_secretsmanager_secret_version.datadog_api_key[0].secret_string : data.aws_ssm_parameter.datadog_api_key[0].value) : null
22-
datadog_app_key = local.enabled ? (local.asm_enabled ? data.aws_secretsmanager_secret_version.datadog_app_key[0].secret_string : data.aws_ssm_parameter.datadog_app_key[0].value) : null
18+
enabled = module.this.enabled
2319

2420
# Get the context tags and skip tags that we don't want applied to every resource.
2521
# i.e. we don't want name since each metric would be called something other than this component's name.

src/outputs.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
output "aws_account_id" {
2-
value = module.datadog_integration.aws_account_id
2+
value = one(module.datadog_integration[*].aws_account_id)
33
description = "AWS Account ID of the IAM Role for the Datadog integration"
44
}
55

66
output "aws_role_name" {
7-
value = module.datadog_integration.aws_role_name
7+
value = one(module.datadog_integration[*].aws_role_name)
88
description = "Name of the AWS IAM Role for the Datadog integration"
99
}
1010

1111
output "datadog_external_id" {
12-
value = module.datadog_integration.datadog_external_id
12+
value = one(module.datadog_integration[*].datadog_external_id)
1313
description = "Datadog integration external ID"
1414
}

src/provider-datadog.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module "datadog_configuration" {
2+
source = "../datadog-configuration/modules/datadog_keys"
3+
region = var.region
4+
context = module.this.context
5+
}
6+
7+
provider "datadog" {
8+
api_key = module.datadog_configuration.datadog_api_key
9+
app_key = module.datadog_configuration.datadog_app_key
10+
api_url = module.datadog_configuration.datadog_api_url
11+
validate = local.enabled
12+
}

src/providers.tf

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ provider "aws" {
22
region = var.region
33

44
profile = module.iam_roles.profiles_enabled ? coalesce(var.import_profile_name, module.iam_roles.terraform_profile_name) : null
5+
56
dynamic "assume_role" {
67
for_each = module.iam_roles.profiles_enabled ? [] : ["role"]
78
content {
@@ -26,29 +27,3 @@ variable "import_role_arn" {
2627
default = null
2728
description = "IAM Role ARN to use when importing a resource"
2829
}
29-
30-
provider "aws" {
31-
alias = "api_keys"
32-
region = var.region
33-
34-
profile = module.iam_roles_datadog_secrets.profiles_enabled ? coalesce(var.import_profile_name, module.iam_roles_datadog_secrets.terraform_profile_name) : null
35-
dynamic "assume_role" {
36-
for_each = module.iam_roles.profiles_enabled ? [] : ["role"]
37-
content {
38-
role_arn = coalesce(var.import_role_arn, module.iam_roles_datadog_secrets.terraform_role_arn)
39-
}
40-
}
41-
}
42-
43-
module "iam_roles_datadog_secrets" {
44-
source = "../account-map/modules/iam-roles"
45-
stage = var.datadog_secrets_source_store_account_stage
46-
tenant = var.datadog_secrets_source_store_account_tenant
47-
context = module.this.context
48-
}
49-
50-
provider "datadog" {
51-
api_key = local.datadog_api_key
52-
app_key = local.datadog_app_key
53-
validate = local.enabled
54-
}

src/ssm.tf

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/variables.tf

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -39,60 +39,6 @@ variable "account_specific_namespace_rules" {
3939
default = {}
4040
}
4141

42-
variable "datadog_secrets_store_type" {
43-
type = string
44-
description = "Secret Store type for Datadog API and app keys. Valid values: `SSM`, `ASM`"
45-
default = "SSM"
46-
}
47-
48-
variable "datadog_secrets_source_store_account_stage" {
49-
type = string
50-
description = "Stage holding Secret Store for Datadog API and app keys."
51-
default = "tools"
52-
}
53-
54-
variable "datadog_secrets_source_store_account_tenant" {
55-
type = string
56-
description = "Tenant holding Secret Store for Datadog API and app keys."
57-
default = "core"
58-
}
59-
60-
variable "datadog_api_secret_key_source_pattern" {
61-
type = string
62-
description = "The format string (%v will be replaced by the var.datadog_api_secret_key) for the key of the Datadog API secret in the source account"
63-
default = "/datadog/%v/datadog_api_key"
64-
}
65-
66-
variable "datadog_app_secret_key_source_pattern" {
67-
type = string
68-
description = "The format string (%v will be replaced by the var.datadog_app_secret_key) for the key of the Datadog APP secret in the source account"
69-
default = "/datadog/%v/datadog_app_key"
70-
}
71-
72-
variable "datadog_api_secret_key_target_pattern" {
73-
type = string
74-
description = "The format string (%v will be replaced by the var.datadog_api_secret_key) for the key of the Datadog API secret in the target account"
75-
default = "/datadog/datadog_api_key"
76-
}
77-
78-
variable "datadog_app_secret_key_target_pattern" {
79-
type = string
80-
description = "The format string (%v will be replaced by the var.datadog_api_secret_key) for the key of the Datadog APP secret in the target account"
81-
default = "/datadog/datadog_app_key"
82-
}
83-
84-
variable "datadog_api_secret_key" {
85-
type = string
86-
description = "The name of the Datadog API secret"
87-
default = "default"
88-
}
89-
90-
variable "datadog_app_secret_key" {
91-
type = string
92-
description = "The name of the Datadog APP secret"
93-
default = "default"
94-
}
95-
#
9642
variable "context_host_and_filter_tags" {
9743
type = list(string)
9844
description = "Automatically add host and filter tags for these context keys"

src/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = "~> 4.0"
7+
version = ">= 4.9.0"
88
}
99
datadog = {
1010
source = "datadog/datadog"

0 commit comments

Comments
 (0)