Skip to content

Commit 65931ef

Browse files
committed
feat(resource-group): support region variable for aws provider v6
1 parent b6040cf commit 65931ef

File tree

5 files changed

+39
-9
lines changed

5 files changed

+39
-9
lines changed

modules/resource-group/README.md

Lines changed: 7 additions & 4 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.5 |
13-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.14 |
12+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.12 |
13+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0 |
1414

1515
## Providers
1616

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

2121
## Modules
2222

@@ -35,7 +35,8 @@ 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> (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 |
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 |
39+
| <a name="input_region"></a> [region](#input\_region) | (Optional) The region in which to create the resource group. If not provided, the resource group will be created in the provider's configured region. | `string` | `null` | no |
3940
| <a name="input_tags"></a> [tags](#input\_tags) | (Optional) A map of tags to add to all resources. | `map(string)` | `{}` | no |
4041

4142
## Outputs
@@ -44,7 +45,9 @@ No modules.
4445
|------|-------------|
4546
| <a name="output_arn"></a> [arn](#output\_arn) | The ARN of the resource group. |
4647
| <a name="output_description"></a> [description](#output\_description) | The description of the resource group. |
48+
| <a name="output_id"></a> [id](#output\_id) | The ID of the resource group. |
4749
| <a name="output_name"></a> [name](#output\_name) | The name of the resource group. |
50+
| <a name="output_region"></a> [region](#output\_region) | The region in which the resource group is created. |
4851
| <a name="output_resource_tags"></a> [resource\_tags](#output\_resource\_tags) | The resource tags used by the resource group to query resources. |
4952
| <a name="output_resource_types"></a> [resource\_types](#output\_resource\_types) | The resource types used by the resource group to query resources. |
5053
<!-- END_TF_DOCS -->

modules/resource-group/main.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ locals {
55
module = basename(path.module)
66
name = var.name
77
}
8-
module_tags = {
8+
module_tags = var.module_tags_enabled ? {
99
"module.terraform.io/package" = local.metadata.package
1010
"module.terraform.io/version" = local.metadata.version
1111
"module.terraform.io/name" = local.metadata.module
1212
"module.terraform.io/full-name" = "${local.metadata.package}/${local.metadata.module}"
1313
"module.terraform.io/instance" = local.metadata.name
14-
}
14+
} : {}
1515
}
1616

1717

@@ -35,6 +35,8 @@ locals {
3535
}
3636

3737
resource "aws_resourcegroups_group" "this" {
38+
region = var.region
39+
3840
name = var.name
3941
description = var.description
4042

@@ -47,7 +49,7 @@ resource "aws_resourcegroups_group" "this" {
4749
{
4850
"Name" = var.name
4951
},
50-
var.module_tags_enabled ? local.module_tags : {},
52+
local.module_tags,
5153
var.tags,
5254
)
5355
}

modules/resource-group/outputs.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
output "region" {
2+
description = "The region in which the resource group is created."
3+
value = aws_resourcegroups_group.this.region
4+
}
5+
16
output "arn" {
27
description = "The ARN of the resource group."
38
value = aws_resourcegroups_group.this.arn
49
}
510

11+
output "id" {
12+
description = "The ID of the resource group."
13+
value = aws_resourcegroups_group.this.id
14+
}
15+
616
output "name" {
717
description = "The name of the resource group."
818
value = aws_resourcegroups_group.this.name
@@ -22,3 +32,11 @@ output "resource_tags" {
2232
description = "The resource tags used by the resource group to query resources."
2333
value = var.query.resource_tags
2434
}
35+
36+
# output "debug" {
37+
# value = {
38+
# for k, v in aws_resourcegroups_group.this :
39+
# k => v
40+
# if !contains(["tags_all", "tags", "region", "arn", "id", "name", "description", "resource_query", "timeouts"], k)
41+
# }
42+
# }

modules/resource-group/variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
variable "region" {
2+
description = "(Optional) The region in which to create the resource group. If not provided, the resource group will be created in the provider's configured region."
3+
type = string
4+
default = null
5+
nullable = true
6+
}
7+
18
variable "name" {
29
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`."
310
type = string

modules/resource-group/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1.5"
2+
required_version = ">= 1.12"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 4.14"
7+
version = ">= 6.0"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)