Skip to content

Commit

Permalink
chore(script): adjust the variable design
Browse files Browse the repository at this point in the history
  • Loading branch information
Lance52259 committed Nov 6, 2024
1 parent 85438e8 commit 120e464
Show file tree
Hide file tree
Showing 16 changed files with 445 additions and 522 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,18 @@ Full contributing [guidelines are covered here](.github/how_to_contribute.md).
<!-- markdownlint-disable MD013 -->
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|----------|
| enterprise_project_id | Used to specify whether the resource is created under the enterprise project (this parameter is only valid for enterprise users) | string | null | N |
| name_suffix | The suffix string of name for all Network resources | string | "" | N |
| enterprise_project_id | Used to specify whether the resource is created under the enterprise project (this parameter is only valid for enterprise users) | string | "" | N |
| is_vpc_create | Controls whether a VPC should be created (it affects all VPC related resources under this module) | bool | true | N |
| vpc_name | The name of the VPC resource | string | "" | Y (Unless is_vpc_create is specified as false) |
| vpc_cidr | The CIDR block of the VPC resource | string | "192.168.0.0/16" | N |
| vpc_description | The description of the VPC resource | string | "" | N |
| vpc_secondary_cidrs | The secondary CIDR blocks of the VPC resource | list(string) | <pre>[]</pre> | N |
| vpc_tags | The key/value pairs to associte with the VPC resource | map(string) | <pre>{}</pre> | N |
| subnets_configuration | The configuration for the subnet resources to which the VPC belongs | <pre>list(object({<br> name = string<br> description = optional(string, null)<br> cidr = string<br> ipv6_enabled = optional(bool, true)<br> dhcp_enabled = optional(bool, true)<br> dns_list = optional(list(string), null)<br> tags = optional(map(string), {})<br> delete_timeout = optional(string, null)<br>}))</pre> | <pre>[<br> {<br> name = "module-default-subnet",<br> cidr = "192.168.16.0/20",<br> },<br>]</pre> | N |
| subnets_configuration | The configuration for the subnet resources to which the VPC belongs | <pre>list(object({<br> name = string<br> cidr = string<br> description = optional(string, "")<br> ipv6_enabled = optional(bool, null)<br> dhcp_enabled = optional(bool, null)<br> dns_list = optional(list(string), [])<br> tags = optional(map(string), {})<br>}))</pre> | <pre>[]</pre> | N |
| is_security_group_create | Controls whether a security group should be created (it affects all security group related resources under this module) | bool | true | N |
| security_group_name | The name of the security group resource" | string | "" | Y (Unless is_security_group_create is specified as false) |
| security_group_description | The description of the security group resource | string | null | N |
| security_group_rules_configuration | The configuration for security group rule resources to which the security group belongs<br>Notes:<br>1. The usage priority of the parameters remote_ip_prefix, remote_group_id, and remote_address_group_id is: remote_group_id > remote_address_group_id > remote_ip_prefix<br>2. The parameters remote_address_group_id and remote_addresses cannot be configured at the same time<br>3. The parameters address_group_name is required if remote_addresses is configured | <pre>list(object({<br> description = optional(string, null)<br> direction = optional(string, "ingress")<br> ethertype = optional(string, "IPv4")<br> protocol = optional(string, null)<br> ports = optional(string, null)<br> remote_ip_prefix = optional(string, "0.0.0.0/0")<br> remote_group_id = optional(string, null)<br> remote_address_group_id = optional(string, null)<br> address_group_name = optional(string, null)<br> remote_addresses = optional(list(string), [])<br> action = optional(string, "allow")<br> priority = optional(number, null)<br>}))</pre> | [] | N |
| security_group_description | The description of the security group resource | string | "" | N |
| security_group_rules_configuration | The configuration for security group rule resources to which the security group belongs<br>Notes:<br>1. The usage priority of the parameters remote_ip_prefix, remote_group_id, and remote_address_group_id is: remote_group_id > remote_address_group_id > remote_ip_prefix<br>2. The parameters remote_address_group_id and remote_addresses cannot be configured at the same time<br>3. The parameters address_group_name is required if remote_addresses is configured | <pre>list(object({<br> description = optional(string, "")<br> direction = optional(string, "ingress")<br> ethertype = optional(string, "IPv4")<br> protocol = optional(string, "")<br> ports = optional(string, "")<br> remote_ip_prefix = optional(string, "0.0.0.0/0")<br> remote_group_id = optional(string, "")<br> remote_address_group_id = optional(string, "")<br> address_group_name = optional(string, "")<br> remote_addresses = optional(list(string), [])<br> action = optional(string, "allow")<br> priority = optional(number, 0)<br>}))</pre> | <pre>[]</pre> | N |
| query_vpc_names | The VPC name list used to query the resource IDs | list(string) | <pre>[]</pre> | N |
| query_subnet_names | The subnet name list used to query the resource IDs | list(string) | <pre>[]</pre> | N |
| query_security_group_names | The security group name list used to query the resource IDs | list(string) | <pre>[]</pre> | N |
Expand Down
9 changes: 4 additions & 5 deletions examples/full_resource_inputs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,17 @@ but they have quota limits). Run `terraform destroy` when you don't need these r
| Name | Description | Type | Value |
|------|-------------|------|-------|
| enterprise_project_id | Used to specify whether the resource is created under the enterprise project (this parameter is only valid for enterprise users) | string | null |
| is_vpc_create | Controls whether a VPC should be created (it affects all VPC related resources under this module) | bool | false |
| name_suffix | The suffix string of name for all Network resources | string | "-terraform-module" |
| vpc_name | The name of the VPC resource | string | demo |
| is_vpc_create | Controls whether a VPC should be created (it affects all VPC related resources under this module) | bool | true |
| vpc_name | The name of the VPC resource | string | "demo" |
| vpc_cidr | The CIDR block of the VPC resource | string | "172.16.128.0/20" |
| vpc_description | The description of the VPC resource | string | "Created by terraform module" |
| vpc_secondary_cidrs | The secondary CIDR blocks of the VPC resource | list(string) | <pre>["172.16.192.0/20"]</pre> |
| vpc_tags | The key/value pairs to associte with the VPC resource | map(string) | <pre>{<br> "foo": "bar"<br>}</pre> |
| subnets_configuration | The configuration for the subnet resources to which the VPC belongs | <pre>list(object({<br> name = string<br> description = optional(string, null)<br> cidr = string<br> ipv6_enabled = optional(bool, true)<br> dhcp_enabled = optional(bool, true)<br> dns_list = optional(list(string), null)<br> tags = optional(map(string), {})<br> delete_timeout = optional(string, null)<br>}))</pre> | <pre>[<br> {name="demo-master", description="Created by terraform module", cidr="172.16.136.0/24", ipv6_enabled=false, dhcp_enabled=false, dns_list=["5.5.5.5"], tags={"foo": "bar"}, delete_timeout="30m"},<br> {name="demo-slave", cidr="172.16.138.0/24"},<br>]</pre> |
| subnets_configuration | The configuration for the subnet resources to which the VPC belongs | <pre>list(object({<br> name = string<br> description = optional(string, "")<br> cidr = string<br> ipv6_enabled = optional(bool, true)<br> dhcp_enabled = optional(bool, true)<br> dns_list = optional(list(string), [])<br> tags = optional(map(string), {})<br> delete_timeout = optional(string, null)<br>}))</pre> | <pre>[<br> {name="demo-master", description="Created by terraform module", cidr="172.16.136.0/24", ipv6_enabled=false, dhcp_enabled=false, dns_list=["5.5.5.5"], tags={"foo": "bar"}, delete_timeout="30m"},<br> {name="demo-slave", cidr="172.16.138.0/24"},<br>]</pre> |
| is_security_group_create | Controls whether a security group should be created (it affects all security group related resources under this module) | bool | true |
| security_group_name | The name of the security group resource | string | "demo" |
| security_group_description | The description of the security group resource | string | "Created by terraform module" |
| security_group_rules_configuration | The configuration for security group rule resources to which the security group belongs<br>Notes:<br>1. The usage priority of the parameters remote_ip_prefix, remote_group_id, and remote_address_group_id is: remote_group_id > remote_address_group_id > remote_ip_prefix<br>2. The parameters remote_address_group_id and remote_addresses cannot be configured at the same time<br>3. The parameters address_group_name is required if remote_addresses is configured | <pre>list(object({<br> description = optional(string, null)<br> direction = optional(string, "ingress")<br> ethertype = optional(string, "IPv4")<br> protocol = optional(string, null)<br> ports = optional(string, null)<br> remote_ip_prefix = optional(string, "0.0.0.0/0")<br> remote_group_id = optional(string, null)<br> remote_address_group_id = optional(string, null)<br> address_group_name = optional(string, null)<br> remote_addresses = optional(list(string), [])<br> action = optional(string, "allow")<br> priority = optional(number, null)<br>}))</pre> | <pre>[<br> {description="Created by terraform module", direction="ingress", ethertype="IPv4", protocol="icmp", priority=100},<br> {description="Created by terraform module", direction="ingress", ethertype="IPv6", protocol="icmp", remote_ip_prefix="::/0", priority=100},<br> {direction="egress", ethertype="IPv4", priority=1},<br> {direction="egress", ethertype="IPv6", remote_ip_prefix="::/0", priority=1},<br> {direction="ingress", ethertype="IPv6", protocol="tcp", ports="22", address_group_name="ipv6_address_group", remote_addresses=["FC00:0:130F:0:0:9C0:876A:130B"], action="deny", priority=100},<br> {protocol="tcp", ports="30000", address_group_name="ipv4_address_group", remote_addresses=["192.168.128.0", "192.168.128.3-192.168.128.99"], priority=100},<br>]</pre> |
| security_group_rules_configuration | The configuration for security group rule resources to which the security group belongs<br>Notes:<br>1. The usage priority of the parameters remote_ip_prefix, remote_group_id, and remote_address_group_id is: remote_group_id > remote_address_group_id > remote_ip_prefix<br>2. The parameters remote_address_group_id and remote_addresses cannot be configured at the same time<br>3. The parameters address_group_name is required if remote_addresses is configured | <pre>list(object({<br> description = optional(string, "")<br> direction = optional(string, "ingress")<br> ethertype = optional(string, "IPv4")<br> protocol = optional(string, "")<br> ports = optional(string, null)<br> remote_ip_prefix = optional(string, "0.0.0.0/0")<br> remote_group_id = optional(string, "")<br> remote_address_group_id = optional(string, "")<br> address_group_name = optional(string, "")<br> remote_addresses = optional(list(string), [])<br> action = optional(string, "allow")<br> priority = optional(number, 0)<br>}))</pre> | <pre>[<br> {description="Created by terraform module", direction="ingress", ethertype="IPv4", protocol="icmp", priority=100},<br> {description="Created by terraform module", direction="ingress", ethertype="IPv6", protocol="icmp", remote_ip_prefix="::/0", priority=100},<br> {direction="egress", ethertype="IPv4", priority=1},<br> {direction="egress", ethertype="IPv6", remote_ip_prefix="::/0", priority=1},<br> {direction="ingress", ethertype="IPv6", protocol="tcp", ports="22", address_group_name="ipv6_address_group", remote_addresses=["FC00:0:130F:0:0:9C0:876A:130B"], action="deny", priority=100},<br> {protocol="tcp", ports="30000", address_group_name="ipv4_address_group", remote_addresses=["192.168.128.0", "192.168.128.3-192.168.128.99"], priority=100},<br>]</pre> |
<!-- markdownlint-enable MD013 -->

## Outputs
Expand Down
3 changes: 0 additions & 3 deletions examples/full_resource_inputs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ module "vpc_service" {
source = "../.."

enterprise_project_id = var.enterprise_project_id
name_suffix = var.name_suffix

is_vpc_create = var.is_vpc_create
vpc_name = var.vpc_name
vpc_cidr = var.vpc_cidr
vpc_description = var.vpc_description
vpc_secondary_cidrs = var.vpc_secondary_cidrs
vpc_tags = var.vpc_tags
subnets_configuration = var.subnets_configuration

is_security_group_create = var.is_security_group_create
security_group_name = var.security_group_name
security_group_description = var.security_group_description
security_group_rules_configuration = var.security_group_rules_configuration
Expand Down
149 changes: 73 additions & 76 deletions examples/full_resource_inputs/variables.json
Original file line number Diff line number Diff line change
@@ -1,78 +1,75 @@
{
"enterprise_project_id": "0",
"name_suffix": "-terraform-module",
"is_vpc_create": true,
"vpc_name": "demo",
"vpc_cidr": "172.16.128.0/20",
"vpc_description": "Created by terraform module",
"vpc_secondary_cidrs": ["172.16.192.0/20"],
"vpc_tags": {
"foo": "bar"
},
"subnets_configuration": [
{
"name": "demo-master",
"description": "Created by terraform module",
"cidr": "172.16.136.0/24",
"ipv6_enabled": false,
"dhcp_enabled": false,
"dns_list": ["5.5.5.5"],
"tags": {
"foo": "bar"
},
"delete_timeout": "30m"
},
{
"name": "demo-slave",
"cidr": "172.16.138.0/24"
}
],
"is_security_group_create": true,
"security_group_name": "demo",
"security_group_description": "Created by terraform module",
"security_group_rules_configuration": [
{
"description": "Created by terraform module",
"direction": "ingress",
"ethertype": "IPv4",
"protocol": "icmp",
"priority": 100
},
{
"description": "Created by terraform module",
"direction": "ingress",
"ethertype": "IPv6",
"protocol": "icmp",
"remote_ip_prefix": "::/0",
"priority": 100
},
{
"direction": "egress",
"ethertype": "IPv4",
"priority": 1
},
{
"direction": "egress",
"ethertype": "IPv6",
"remote_ip_prefix": "::/0",
"priority": 1
},
{
"direction": "ingress",
"ethertype": "IPv6",
"protocol": "tcp",
"ports": "22",
"address_group_name": "ipv6_address_group",
"remote_addresses": ["FC00:0:130F:0:0:9C0:876A:130B"],
"action": "deny",
"priority": 100
},
{
"protocol": "tcp",
"ports": "30000",
"address_group_name": "ipv4_address_group",
"remote_addresses": ["192.168.128.0", "192.168.128.3-192.168.128.99"],
"priority": 100
}
]
"enterprise_project_id": "0",
"vpc_name": "demo",
"vpc_cidr": "172.16.128.0/20",
"vpc_description": "Created by terraform module",
"vpc_secondary_cidrs": ["172.16.192.0/20"],
"vpc_tags": {
"foo": "bar"
},
"subnets_configuration": [
{
"name": "demo-master",
"description": "Created by terraform module",
"cidr": "172.16.136.0/24",
"ipv6_enabled": false,
"dhcp_enabled": false,
"dns_list": ["5.5.5.5"],
"tags": {
"foo": "bar"
},
"delete_timeout": "30m"
},
{
"name": "demo-slave",
"cidr": "172.16.138.0/24"
}
],
"security_group_name": "demo",
"security_group_description": "Created by terraform module",
"security_group_rules_configuration": [
{
"description": "Created by terraform module",
"direction": "ingress",
"ethertype": "IPv4",
"protocol": "icmp",
"priority": 100
},
{
"description": "Created by terraform module",
"direction": "ingress",
"ethertype": "IPv6",
"protocol": "icmp",
"remote_ip_prefix": "::/0",
"priority": 100
},
{
"direction": "egress",
"ethertype": "IPv4",
"priority": 1
},
{
"direction": "egress",
"ethertype": "IPv6",
"remote_ip_prefix": "::/0",
"priority": 1
},
{
"direction": "ingress",
"ethertype": "IPv6",
"protocol": "tcp",
"ports": "22",
"address_group_name": "ipv6_address_group",
"remote_addresses": ["FC00:0:130F:0:0:9C0:876A:130B"],
"action": "deny",
"priority": 100
},
{
"protocol": "tcp",
"ports": "30000",
"address_group_name": "ipv4_address_group",
"remote_addresses": ["192.168.128.0", "192.168.128.3-192.168.128.99"],
"priority": 100
}
]
}
Loading

0 comments on commit 120e464

Please sign in to comment.