8000 Update resource-group module to support optional attributes (#35) · tedilabs/terraform-aws-misc@99a4896 · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit 99a4896

Browse files
authored
Update resource-group module to support optional attributes (#35)
1 parent d160603 commit 99a4896

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

modules/resource-group/README.md

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

1010
| Name | Version |
1111
|------|---------|
12-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.1 |
12+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5 |
1313
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.14 |
1414

1515
## Providers
1616

1717
| Name | Version |
1818
|------|---------|
19-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.16.0 |
19+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.15.0 |
2020

2121
## Modules
2222

@@ -35,7 +35,7 @@ No modules.
3535
| <a name="input_name"></a> [name](#input\_name) | (Required) A name to identify the resource group. A resource group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`. | `string` | n/a | yes |
3636
| <a name="input_description"></a> [description](#input\_description) | (Optional) The description of the resource group. | `string` | `"Managed by Terraform."` | no |
3737
| <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 |
38-
| <a name="input_query"></a> [query](#input\_query) | (Optional) A configuration for the actual query used to match against resources. It supports `resource_types` and `resource_tags`. `query` block as defined below.<br> (Required) `resource_tags` - A map of key/value pairs that are compared to the tags attached to resources.<br> (Optional) `resource_types` - A list of resource-type specification strings with `AWS::service-id::resource-type` format. Limit the results to only those resource types that match the filter. Specify `AWS::AllSupported` to include resources of any resources that are currently supported by Resource Group. | `any` | `{}` | no |
38+
| <a name="input_query"></a> [query](#input\_query) | (Optional) A configuration for the actual query used to match against resources. It supports `resource_types` and `resource_tags`. `query` block as defined below.<br> (Optional) `resource_tags` - A map of key/value pairs that are compared to the tags attached to resources.<br> (Optional) `resource_types` - A list of resource-type specification strings with `AWS::service-id::resource-type` format. Limit the results to only those resource types that match the filter. Specify `AWS::AllSupported` to include resources of any resources that are currently supported by Resource Group. | <pre>object({<br> resource_tags = optional(map(string), {})<br> resource_types = optional(list(string), ["AWS::AllSupported"])<br> })</pre> | `{}` | no |
3939
| <a name="input_tags"></a> [tags](#input\_tags) | (Optional) A map of tags to add to all resources. | `map(string)` | `{}` | no |
4040

4141
## Outputs

modules/resource-group/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ locals {
2121

2222
locals {
2323
filters = [
24-
for key, value in try(var.query.resource_tags, {}) : {
24+
for key, value in var.query.resource_tags : {
2525
"Key" = key
2626
"Values" = flatten([value])
2727
}
2828
]
2929
query = <<-JSON
3030
{
31-
"ResourceTypeFilters": ${jsonencode(try(var.query.resource_types, ["AWS::AllSupported"]))},
31+
"ResourceTypeFilters": ${jsonencode(var.query.resource_types)},
3232
"TagFilters": ${jsonencode(local.filters)}
3333
}
3434
JSON

modules/resource-group/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ output "description" {
1515

1616
output "resource_types" {
1717
description = "The resource types used by the resource group to query resources."
18-
value = try(var.query.resource_types, ["AWS::AllSupported"])
18+
value = var.query.resource_types
1919
}
2020

2121
output "resource_tags" {
2222
description = "The resource tags used by the resource group to query resources."
23-
value = try(var.query.resource_tags, {})
23+
value = var.query.resource_tags
2424
}

modules/resource-group/variables.tf

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
11
variable "name" {
22
description = "(Required) A name to identify the resource group. A resource group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`."
33
type = string
4+
nullable = false
45
}
56

67
variable "description" {
78
description = "(Optional) The description of the resource group."
89
type = string
910
default = "Managed by Terraform."
11+
nullable = false
1012
}
1113

1214
variable "query" {
1315
description = <<EOF
1416
(Optional) A configuration for the actual query used to match against resources. It supports `resource_types` and `resource_tags`. `query` block as defined below.
15-
(Required) `resource_tags` - A map of key/value pairs that are compared to the tags attached to resources.
17+
(Optional) `resource_tags` - A map of key/value pairs that are compared to the tags attached to resources.
1618
(Optional) `resource_types` - A list of resource-type specification strings with `AWS::service-id::resource-type` format. Limit the results to only those resource types that match the filter. Specify `AWS::AllSupported` to include resources of any resources that are currently supported by Resource Group.
1719
EOF
18-
type = any
19-
default = {}
20+
type = object({
21+
resource_tags = optional(map(string), {})
22+
resource_types = optional(list(string), ["AWS::AllSupported"])
23+
})
24+
default = {}
25+
nullable = false
2026
}
2127

2228
variable "tags" {
2329
description = "(Optional) A map of tags to add to all resources."
2430
type = map(string)
2531
default = {}
32+
nullable = false
2633
}
2734

2835
variable "module_tags_enabled" {
2936
description = "(Optional) Whether to create AWS Resource Tags for the module informations."
3037
type = bool
3138
default = true
39+
nullable = false
3240
}

modules/resource-group/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 1.1"
2+
required_version = ">= 1.5"
33

44
required_providers {
55
aws = {

0 commit comments

Comments
 (0)
0