diff --git a/modules/resource-group/README.md b/modules/resource-group/README.md index 348fae5..5cb4712 100644 --- a/modules/resource-group/README.md +++ b/modules/resource-group/README.md @@ -9,14 +9,14 @@ This module creates following resources. | Name | Version | |------|---------| -| [terraform](#requirement\_terraform) | >= 1.1 | +| [terraform](#requirement\_terraform) | >= 1.5 | | [aws](#requirement\_aws) | >= 4.14 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | 4.16.0 | +| [aws](#provider\_aws) | 5.15.0 | ## Modules @@ -35,7 +35,7 @@ No modules. | [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 | | [description](#input\_description) | (Optional) The description of the resource group. | `string` | `"Managed by Terraform."` | no | | [module\_tags\_enabled](#input\_module\_tags\_enabled) | (Optional) Whether to create AWS Resource Tags for the module informations. | `bool` | `true` | no | -| [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.
(Required) `resource_tags` - A map of key/value pairs that are compared to the tags attached to resources.
(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 | +| [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.
(Optional) `resource_tags` - A map of key/value pairs that are compared to the tags attached to resources.
(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. |
object({
resource_tags = optional(map(string), {})
resource_types = optional(list(string), ["AWS::AllSupported"])
})
| `{}` | no | | [tags](#input\_tags) | (Optional) A map of tags to add to all resources. | `map(string)` | `{}` | no | ## Outputs diff --git a/modules/resource-group/main.tf b/modules/resource-group/main.tf index 1efd8b3..fe9e009 100644 --- a/modules/resource-group/main.tf +++ b/modules/resource-group/main.tf @@ -21,14 +21,14 @@ locals { locals { filters = [ - for key, value in try(var.query.resource_tags, {}) : { + for key, value in var.query.resource_tags : { "Key" = key "Values" = flatten([value]) } ] query = <<-JSON { - "ResourceTypeFilters": ${jsonencode(try(var.query.resource_types, ["AWS::AllSupported"]))}, + "ResourceTypeFilters": ${jsonencode(var.query.resource_types)}, "TagFilters": ${jsonencode(local.filters)} } JSON diff --git a/modules/resource-group/outputs.tf b/modules/resource-group/outputs.tf index 1e0f6ea..4ddf8a8 100644 --- a/modules/resource-group/outputs.tf +++ b/modules/resource-group/outputs.tf @@ -15,10 +15,10 @@ output "description" { output "resource_types" { description = "The resource types used by the resource group to query resources." - value = try(var.query.resource_types, ["AWS::AllSupported"]) + value = var.query.resource_types } output "resource_tags" { description = "The resource tags used by the resource group to query resources." - value = try(var.query.resource_tags, {}) + value = var.query.resource_tags } diff --git a/modules/resource-group/variables.tf b/modules/resource-group/variables.tf index 6ae4201..70b82c2 100644 --- a/modules/resource-group/variables.tf +++ b/modules/resource-group/variables.tf @@ -1,32 +1,40 @@ variable "name" { 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`." type = string + nullable = false } variable "description" { description = "(Optional) The description of the resource group." type = string default = "Managed by Terraform." + nullable = false } variable "query" { description = <