Skip to content

Commit fb2e3a6

Browse files
authored
upstream acm and datadog-integration (cloudposse/terraform-aws-components#666)
1 parent c964e1d commit fb2e3a6

File tree

3 files changed

+24
-47
lines changed

3 files changed

+24
-47
lines changed

src/README.md

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Component: `datadog-integration`
22

3-
This component is responsible for provisioning Datadog AWS integrations.
3+
This component is responsible for provisioning Datadog AWS integrations.
44

55
See Datadog's [documentation about provisioning keys](https://docs.datadoghq.com/account_management/api-app-keys) for more information.
66

@@ -32,7 +32,9 @@ components:
3232
3333
## Providers
3434
35-
No providers.
35+
| Name | Version |
36+
|------|---------|
37+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.9.0 |
3638
3739
## Modules
3840
@@ -46,7 +48,9 @@ No providers.
4648
4749
## Resources
4850
49-
No resources.
51+
| Name | Type |
52+
|------|------|
53+
| [aws_regions.all](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/regions) | data source |
5054
5155
## Inputs
5256
@@ -68,6 +72,7 @@ No resources.
6872
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
6973
| <a name="input_import_profile_name"></a> [import\_profile\_name](#input\_import\_profile\_name) | AWS Profile name to use when importing a resource | `string` | `null` | no |
7074
| <a name="input_import_role_arn"></a> [import\_role\_arn](#input\_import\_role\_arn) | IAM Role ARN to use when importing a resource | `string` | `null` | no |
75+
| <a name="input_included_regions"></a> [included\_regions](#input\_included\_regions) | An array of AWS regions to include in metrics collection | `list(string)` | `[]` | no |
7176
| <a name="input_integrations"></a> [integrations](#input\_integrations) | List of AWS permission names to apply for different integrations (e.g. 'all', 'core') | `list(string)` | <pre>[<br> "all"<br>]</pre> | no |
7277
| <a name="input_label_key_case"></a> [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.<br>Does not affect keys of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no |
7378
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |
@@ -91,49 +96,6 @@ No resources.
9196
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
9297

9398

94-
## FAQ:
95-
96-
### Stack Errors (Spacelift):
97-
98-
```
99-
100-
│ Error: error creating AWS integration from https://api.datadoghq.com/api/v1/integration/aws: 409 Conflict: {"errors": ["Could not update AWS Integration due to conflicting updates"]}
101-
102-
│ with module.datadog_integration.datadog_integration_aws.integration[0],
103-
│ on .terraform/modules/datadog_integration/main.tf line 18, in resource "datadog_integration_aws" "integration":
104-
│ 18: resource "datadog_integration_aws" "integration" {
105-
106-
107-
```
108-
109-
This can happen when you apply multiple integrations at the same time. Fix is easy though, re-trigger the stack.
110-
111-
## Enabling Security Audits
112-
113-
To enable the Datadog compliance capabilities, AWS integration to must have the `SecurityAudit` policy attached to the Datadog IAM role. This is handled by our [https://github.com/cloudposse/terraform-aws-datadog-integration](https://github.com/cloudposse/terraform-aws-datadog-integration) module used
114-
115-
the by the `datadog-integration` component.
116-
117-
Attaching the `SecurityAudit` policy allows Datadog to collect information about how AWS resources are configured (used in Datadog Cloud Security Posture Management to read security configuration metadata)
118-
119-
- Datadog Cloud Security Posture Management (CSPM) makes it easier to assess and visualize the current and historic security posture of cloud environments, automate audit evidence collection, and catch misconfigurations that leave your organization vulnerable to attacks
120-
121-
- Cloud Security Posture Management (CSPM) can be accessed at [https://app.datadoghq.com/security/compliance/home](https://app.datadoghq.com/security/compliance/home)
122-
123-
- The process to enable Datadog Cloud Security Posture Management (CSPM) consists of two steps (one automated, the other manual):
124-
125-
- Enable `SecurityAudit` policy and provision it with terraform
126-
127-
- In Datadog UI, perform the following manual steps:
128-
129-
```
130-
Go to the Datadog AWS integration tile
131-
Click on the AWS account where you wish to enable resource collection
132-
Go to the Resource collection section for that account and check the box "Route resource data to the Cloud Security Posture Management product"
133-
At the bottom left of the tile, click Update Configuration
134-
135-
```
136-
13799
## References
138100
* Datadog's [documentation about provisioning keys](https://docs.datadoghq.com/account_management/api-app-keys)
139101
* [cloudposse/terraform-aws-components](https://github.com/cloudposse/terraform-aws-components/tree/master/modules/datadog-integration) - Cloud Posse's upstream component

src/main.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
locals {
2+
use_include_regions = length(var.included_regions) > 0
3+
all_regions = data.aws_regions.all.names
4+
excluded_list_by_include = setsubtract(local.use_include_regions ? local.all_regions : [], var.included_regions)
5+
}
6+
7+
data "aws_regions" "all" {
8+
all_regions = true
9+
}
10+
111
module "datadog_integration" {
212
source = "cloudposse/datadog-integration/aws"
313
version = "1.0.0"
@@ -8,7 +18,7 @@ module "datadog_integration" {
818
integrations = var.integrations
919
filter_tags = local.filter_tags
1020
host_tags = local.host_tags
11-
excluded_regions = var.excluded_regions
21+
excluded_regions = concat(var.excluded_regions, tolist(local.excluded_list_by_include))
1222
account_specific_namespace_rules = var.account_specific_namespace_rules
1323

1424
context = module.this.context

src/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ variable "excluded_regions" {
3333
default = []
3434
}
3535

36+
variable "included_regions" {
37+
type = list(string)
38+
description = "An array of AWS regions to include in metrics collection"
39+
default = []
40+
}
3641
variable "account_specific_namespace_rules" {
3742
type = map(string)
3843
description = "An object, (in the form {\"namespace1\":true/false, \"namespace2\":true/false} ), that enables or disables metric collection for specific AWS namespaces for this AWS account only"

0 commit comments

Comments
 (0)