Skip to content

Commit

Permalink
feat: Add module ELB IP Group (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrTitov authored May 24, 2023
1 parent 3416046 commit ea5a4ff
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 1 deletion.
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
# Module name
# Huaweicloud ELB IP Group
<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.4 |
| <a name="requirement_huaweicloud"></a> [huaweicloud](#requirement\_huaweicloud) | ~>1.47 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_huaweicloud"></a> [huaweicloud](#provider\_huaweicloud) | ~>1.47 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [huaweicloud_elb_ipgroup.main](https://registry.terraform.io/providers/huaweicloud/huaweicloud/latest/docs/resources/elb_ipgroup) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_description"></a> [description](#input\_description) | Specifies the description of an elb ip group | `string` | `null` | no |
| <a name="input_ip_list"></a> [ip\_list](#input\_ip\_list) | Specifies the list of allowed IP address or CIDR block | `list(string)` | `[]` | no |
| <a name="input_name"></a> [name](#input\_name) | Specifies the elb ip group name | `string` | n/a | yes |
| <a name="input_name_postfix"></a> [name\_postfix](#input\_name\_postfix) | Specifies the elb ip group name postfix | `string` | `null` | no |
| <a name="input_region"></a> [region](#input\_region) | Specifies the region in which to create the resource, if omitted, the provider-level region will be used | `string` | `null` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_id"></a> [id](#output\_id) | The uuid of the ip group |
| <a name="output_name"></a> [name](#output\_name) | The name of the ip group |
<!-- END_TF_DOCS -->
16 changes: 16 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
locals {
name = var.name_postfix == null ? format("%s-ip-group", var.name) : format("%s-elb-%s", var.name, var.name_postfix)
}

resource "huaweicloud_elb_ipgroup" "main" {
name = local.name
description = var.description
region = var.region

dynamic "ip_list" {
for_each = toset(var.ip_list)
content {
ip = ip_list.key
}
}
}
9 changes: 9 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "id" {
description = "The uuid of the ip group"
value = huaweicloud_elb_ipgroup.main.id
}

output "name" {
description = "The name of the ip group"
value = huaweicloud_elb_ipgroup.main.name
}
29 changes: 29 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
variable "name" {
description = "Specifies the elb ip group name"
type = string
nullable = false
}

variable "name_postfix" {
description = "Specifies the elb ip group name postfix"
type = string
default = null
}

variable "description" {
description = "Specifies the description of an elb ip group"
type = string
default = null
}

variable "region" {
description = "Specifies the region in which to create the resource, if omitted, the provider-level region will be used"
type = string
default = null
}

variable "ip_list" {
description = "Specifies the list of allowed IP address or CIDR block"
type = list(string)
default = []
}
7 changes: 7 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
terraform {
required_version = "~> 1.4"

required_providers {
huaweicloud = {
source = "huaweicloud/huaweicloud"
version = "~>1.47"
}
}
}

0 comments on commit ea5a4ff

Please sign in to comment.