Skip to content

Commit a491ed9

Browse files
committed
Support evaluation mode for config-managed-rule
1 parent 18c6860 commit a491ed9

File tree

6 files changed

+35
-5
lines changed

6 files changed

+35
-5
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.8.0
1+
0.8.1

modules/config-managed-rule/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ This module creates following resources.
1515

1616
| Name | Version |
1717
|------|---------|
18-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5 |
19-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.14 |
18+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6 |
19+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.23 |
2020

2121
## Providers
2222

2323
| Name | Version |
2424
|------|---------|
25-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.19.0 |
25+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.46.0 |
2626

2727
## Modules
2828

@@ -43,6 +43,7 @@ This module creates following resources.
4343
|------|-------------|------|---------|:--------:|
4444
| <a name="input_source_rule"></a> [source\_rule](#input\_source\_rule) | (Required) The identifier for AWS Config managed rule. Use the format like `root-account-mfa-enabled` instead of predefiend format like `ROOT_ACCOUNT_MFA_ENABLED`. | `string` | n/a | yes |
4545
| <a name="input_description"></a> [description](#input\_description) | (Optional) The description of the rule. Use default description if not provided. | `string` | `null` | no |
46+
| <a name="input_evaluation_modes"></a> [evaluation\_modes](#input\_evaluation\_modes) | (Optional) A set of evaluation modes to enable for the Config rule. Valid values are `DETECTIVE`, `PROACTIVE`. Default value contains only `DETECTIVE`. | `set(string)` | <pre>[<br> "DETECTIVE"<br>]</pre> | no |
4647
| <a name="input_excluded_accounts"></a> [excluded\_accounts](#input\_excluded\_accounts) | (Optional) A list of AWS account identifiers to exclude from the rule. Only need when `level` is configured with value `ORGANIZATION`. | `list(string)` | `[]` | no |
4748
| <a name="input_level"></a> [level](#input\_level) | (Optional) Choose to create a rule across all accounts in your Organization. Valid values are `ACCOUNT` and `ORGANIZATION`. Use `ORGANIZATION` level in Organization master account or delegated administrator accounts. | `string` | `"ACCOUNT"` | no |
4849
| <a name="input_module_tags_enabled"></a> [module\_tags\_enabled](#input\_module\_tags\_enabled) | (Optional) Whether to create AWS Resource Tags for the module informations. | `bool` | `true` | no |
@@ -64,6 +65,7 @@ This module creates following resources.
6465
|------|-------------|
6566
| <a name="output_arn"></a> [arn](#output\_arn) | The Amazon Resource Name (ARN) of the rule. |
6667
| <a name="output_description"></a> [description](#output\_description) | The description of the rule. |
68+
| <a name="output_evaluation_modes"></a> [evaluation\_modes](#output\_evaluation\_modes) | A set of evaluation modes to enable for the Config rule. |
6769
| <a name="output_excluded_accounts"></a> [excluded\_accounts](#output\_excluded\_accounts) | A list of AWS account identifiers excluded from the rule. |
6870
| <a name="output_id"></a> [id](#output\_id) | The ID of the rule. |
6971
| <a name="output_level"></a> [level](#output\_level) | The level of the rule. `ACOUNT` or `ORGANIZATION`. The rule is for accounts in your Organization if the value is configured with `ORGANIZATION`. |

modules/config-managed-rule/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ resource "aws_config_config_rule" "this" {
6767
input_parameters = jsonencode(var.parameters)
6868

6969
### Trigger by configuration change
70+
dynamic "evaluation_mode" {
71+
for_each = var.evaluation_modes
72+
73+
content {
74+
mode = evaluation_mode.value
75+
}
76+
}
77+
7078
## Scope: ALL_CHANGES
7179
dynamic "scope" {
7280
for_each = local.rule.trigger_by_change.enabled && var.scope == "ALL_CHANGES" ? ["go"] : []

modules/config-managed-rule/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ output "level" {
5353
value = var.level
5454
}
5555

56+
output "evaluation_modes" {
57+
description = "A set of evaluation modes to enable for the Config rule."
58+
value = var.evaluation_modes
59+
}
60+
5661
output "trigger_by_change" {
5762
description = "The information of trigger by configuration changes."
5863
value = {

modules/config-managed-rule/variables.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ variable "level" {
3737
}
3838
}
3939

40+
variable "evaluation_modes" {
41+
description = "(Optional) A set of evaluation modes to enable for the Config rule. Valid values are `DETECTIVE`, `PROACTIVE`. Default value contains only `DETECTIVE`."
42+
type = set(string)
43+
default = ["DETECTIVE"]
44+
nullable = false
45+
46+
validation {
47+
condition = alltrue([
48+
for mode in var.evaluation_modes :
49+
contains(["DETECTIVE", "PROACTIVE"], mode)
50+
])
51+
error_message = "Valid values for `evaluation_modes` should be one of `DETECTIVE`, `PROACTIVE`."
52+
}
53+
}
54+
4055
variable "scope" {
4156
description = "(Optional) Choose when evaluations will occur. Valid values are `ALL_CHANGES`, `RESOURCES`, or `TAGS`."
4257
type = string

modules/config-managed-rule/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 = ">= 5.5"
7+
version = ">= 5.23"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)