|
| 1 | +Terraform module to Implement NAT64 based on ALB for Alibaba Cloud |
| 2 | + |
| 3 | +terraform-alicloud-nat64-based-on-alb |
| 4 | +====================================== |
| 5 | + |
| 6 | +[English](https://github.com/alibabacloud-automation/terraform-alicloud-nat64-based-on-alb/blob/main/README.md) | 简体中文 |
| 7 | + |
| 8 | +面对IPv6改造要求,部分企业会采用“6to4”转换方案。即通过将来自客户端的IPv6访问请求,转换为IPv4协议转发至服务器,帮助应用系统简单快速的具备IPv6访问能力。 |
| 9 | + |
| 10 | +本 Module 介绍如何快速部署双栈版本的ALB,为云上应用系统,提供“6 to 4”转换能力。 |
| 11 | + |
| 12 | +架构图: |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +## 用法 |
| 17 | + |
| 18 | +```hcl |
| 19 | +provider "alicloud" { |
| 20 | + region = "cn-shanghai" |
| 21 | +} |
| 22 | +
|
| 23 | +module "complete" { |
| 24 | + source = "alibabacloud-automation/nat64-based-on-alb/alicloud" |
| 25 | + vpc_config = { |
| 26 | + cidr_block = "10.0.0.0/8" |
| 27 | + ipv6_isp = "BGP" |
| 28 | + } |
| 29 | +
|
| 30 | + alb_vswitches = [{ |
| 31 | + vswitch_name = "ipv6-alb-vsw1" |
| 32 | + ipv6_cidr_block_mask = 1 |
| 33 | + zone_id = "cn-shanghai-g" |
| 34 | + cidr_block = "10.0.0.0/25" |
| 35 | + }, { |
| 36 | + vswitch_name = "ipv6-alb-vsw2" |
| 37 | + ipv6_cidr_block_mask = 2 |
| 38 | + zone_id = "cn-shanghai-l" |
| 39 | + cidr_block = "10.0.0.128/25" |
| 40 | + }] |
| 41 | +
|
| 42 | + app_vswitches = [{ |
| 43 | + vswitch_name = "ipv6-app-vsw3" |
| 44 | + ipv6_cidr_block_mask = 3 |
| 45 | + zone_id = "cn-shanghai-g" |
| 46 | + cidr_block = "10.0.1.0/24" |
| 47 | + }, { |
| 48 | + vswitch_name = "ipv6-app-vsw4" |
| 49 | + ipv6_cidr_block_mask = 4 |
| 50 | + zone_id = "cn-shanghai-l" |
| 51 | + cidr_block = "10.0.2.0/24" |
| 52 | + }] |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +## 示例 |
| 57 | + |
| 58 | +* [完整示例](https://github.com/alibabacloud-automation/terraform-alicloud-nat64-based-on-alb/tree/main/examples/complete) |
| 59 | + |
| 60 | + |
| 61 | +<!-- BEGIN_TF_DOCS --> |
| 62 | +## Requirements |
| 63 | + |
| 64 | +| Name | Version | |
| 65 | +|------|---------| |
| 66 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 | |
| 67 | + |
| 68 | +## Providers |
| 69 | + |
| 70 | +| Name | Version | |
| 71 | +|------|---------| |
| 72 | +| <a name="provider_alicloud"></a> [alicloud](#provider\_alicloud) | n/a | |
| 73 | + |
| 74 | +## Modules |
| 75 | + |
| 76 | +No modules. |
| 77 | + |
| 78 | +## Resources |
| 79 | + |
| 80 | +| Name | Type | |
| 81 | +|------|------| |
| 82 | +| [alicloud_alb_listener.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/alb_listener) | resource | |
| 83 | +| [alicloud_alb_load_balancer.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/alb_load_balancer) | resource | |
| 84 | +| [alicloud_alb_server_group.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/alb_server_group) | resource | |
| 85 | +| [alicloud_common_bandwidth_package.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/common_bandwidth_package) | resource | |
| 86 | +| [alicloud_instance.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/instance) | resource | |
| 87 | +| [alicloud_security_group.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/security_group) | resource | |
| 88 | +| [alicloud_vpc.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/vpc) | resource | |
| 89 | +| [alicloud_vpc_ipv6_gateway.default](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/vpc_ipv6_gateway) | resource | |
| 90 | +| [alicloud_vswitch.alb](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/vswitch) | resource | |
| 91 | +| [alicloud_vswitch.app](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/vswitch) | resource | |
| 92 | + |
| 93 | +## Inputs |
| 94 | + |
| 95 | +| Name | Description | Type | Default | Required | |
| 96 | +|------|-------------|------|---------|:--------:| |
| 97 | +| <a name="input_alb_listener"></a> [alb\_listener](#input\_alb\_listener) | The parameters of alb listener. | <pre>object({<br> listener_protocol = optional(string, "HTTP")<br> listener_port = optional(number, 80)<br> })</pre> | `{}` | no | |
| 98 | +| <a name="input_alb_load_balancer"></a> [alb\_load\_balancer](#input\_alb\_load\_balancer) | The parameters of alb load balancer. | <pre>object({<br> load_balancer_edition = optional(string, "Standard")<br> load_balancer_name = optional(string, null)<br> pay_type = optional(string, "PayAsYouGo")<br> })</pre> | `{}` | no | |
| 99 | +| <a name="input_alb_server_group"></a> [alb\_server\_group](#input\_alb\_server\_group) | The parameters of alb server group. | <pre>object({<br> server_group_name = string<br> scheduler = optional(string, "Wrr")<br> protocol = optional(string, "HTTP")<br> sticky_session_config = optional(object({<br> sticky_session_enabled = optional(bool, true)<br> sticky_session_type = optional(string, "Insert")<br> }), {})<br> health_check_config = optional(object({<br> health_check_enabled = optional(bool, true)<br> health_check_connect_port = optional(number, 46325)<br> health_check_host = optional(string, "ipv6-example.com")<br> health_check_codes = optional(list(string), ["http_2xx", "http_3xx", "http_4xx"])<br> health_check_http_version = optional(string, "HTTP1.1")<br> health_check_interval = optional(number, 2)<br> health_check_method = optional(string, "HEAD")<br> health_check_path = optional(string, "/ipv6-example")<br> health_check_protocol = optional(string, "HTTP")<br> health_check_timeout = optional(number, 5)<br> healthy_threshold = optional(number, 3)<br> unhealthy_threshold = optional(number, 3)<br> }), {})<br> servers_port = optional(number, 80)<br> })</pre> | <pre>{<br> "server_group_name": "alb_server_group"<br>}</pre> | no | |
| 100 | +| <a name="input_alb_vswitches"></a> [alb\_vswitches](#input\_alb\_vswitches) | The vswitches used for nlb. | <pre>list(object({<br> zone_id = string<br> cidr_block = string<br> ipv6_cidr_block_mask = number<br> vswitch_name = optional(string, null)<br> }))</pre> | n/a | yes | |
| 101 | +| <a name="input_app_vswitches"></a> [app\_vswitches](#input\_app\_vswitches) | The vswitches used for application server. | <pre>list(object({<br> zone_id = string<br> cidr_block = string<br> ipv6_cidr_block_mask = number<br> vswitch_name = optional(string, null)<br> }))</pre> | n/a | yes | |
| 102 | +| <a name="input_common_bandwidth_package"></a> [common\_bandwidth\_package](#input\_common\_bandwidth\_package) | The parameters of common bandwidth package. | <pre>object({<br> name = optional(string, null)<br> internet_charge_type = optional(string, "PayBy95")<br> ratio = optional(number, 20)<br> isp = optional(string, "BGP")<br> bandwidth = optional(string, "1000")<br> })</pre> | `{}` | no | |
| 103 | +| <a name="input_create_common_bandwidth_package"></a> [create\_common\_bandwidth\_package](#input\_create\_common\_bandwidth\_package) | Whether to create common bandwidth package. | `bool` | `true` | no | |
| 104 | +| <a name="input_ecs_config"></a> [ecs\_config](#input\_ecs\_config) | The parameters of ecs instance. | <pre>object({<br> instance_type = optional(string, "ecs.g6e.large")<br> system_disk_category = optional(string, "cloud_essd")<br> image_id = optional(string, "ubuntu_24_04_x64_20G_alibase_20250113.vhd")<br> instance_name = optional(string, null)<br> internet_max_bandwidth_out = optional(number, 0)<br> ipv6_address_count = optional(number, 1)<br> })</pre> | `{}` | no | |
| 105 | +| <a name="input_exsiting_common_bandwidth_package_id"></a> [exsiting\_common\_bandwidth\_package\_id](#input\_exsiting\_common\_bandwidth\_package\_id) | The id of existing common bandwidth package. If `create_common_bandwidth_package` is false, this value is required. | `string` | `null` | no | |
| 106 | +| <a name="input_security_group_name"></a> [security\_group\_name](#input\_security\_group\_name) | The name of security group. | `string` | `null` | no | |
| 107 | +| <a name="input_vpc_config"></a> [vpc\_config](#input\_vpc\_config) | The parameters of vpc and vswitches. | <pre>object({<br> cidr_block = string<br> vpc_name = optional(string, null)<br> ipv6_isp = optional(string, "BGP")<br> })</pre> | n/a | yes | |
| 108 | +| <a name="input_vpc_ipv6_gateway_name"></a> [vpc\_ipv6\_gateway\_name](#input\_vpc\_ipv6\_gateway\_name) | The name of vpc ipv6 gateway. | `string` | `null` | no | |
| 109 | + |
| 110 | +## Outputs |
| 111 | + |
| 112 | +| Name | Description | |
| 113 | +|------|-------------| |
| 114 | +| <a name="output_alb_listener_id"></a> [alb\_listener\_id](#output\_alb\_listener\_id) | The ID of the ALB listener. | |
| 115 | +| <a name="output_alb_load_balancer_id"></a> [alb\_load\_balancer\_id](#output\_alb\_load\_balancer\_id) | The ID of the ALB load balancer. | |
| 116 | +| <a name="output_alb_server_group_id"></a> [alb\_server\_group\_id](#output\_alb\_server\_group\_id) | The ID of the ALB server group. | |
| 117 | +| <a name="output_alb_vswitch_ids"></a> [alb\_vswitch\_ids](#output\_alb\_vswitch\_ids) | The IDs of the ALB VSwitches. | |
| 118 | +| <a name="output_app_vswitch_ids"></a> [app\_vswitch\_ids](#output\_app\_vswitch\_ids) | The IDs of the App VSwitches. | |
| 119 | +| <a name="output_bandwidth_package_id"></a> [bandwidth\_package\_id](#output\_bandwidth\_package\_id) | The ID of the common bandwidth package. | |
| 120 | +| <a name="output_instance_ids"></a> [instance\_ids](#output\_instance\_ids) | The IDs of the ECS instances. | |
| 121 | +| <a name="output_ipv6_gateway_id"></a> [ipv6\_gateway\_id](#output\_ipv6\_gateway\_id) | The ID of the IPv6 gateway. | |
| 122 | +| <a name="output_security_group_id"></a> [security\_group\_id](#output\_security\_group\_id) | The ID of the security group. | |
| 123 | +| <a name="output_vpc_id"></a> [vpc\_id](#output\_vpc\_id) | The ID of the VPC. | |
| 124 | +<!-- END_TF_DOCS --> |
| 125 | + |
| 126 | +## 提交问题 |
| 127 | + |
| 128 | +如果在使用该 Terraform Module 的过程中有任何问题,可以直接创建一个 [Provider Issue](https://github.com/aliyun/terraform-provider-alicloud/issues/new),我们将根据问题描述提供解决方案。 |
| 129 | + |
| 130 | +**注意:** 不建议在该 Module 仓库中直接提交 Issue。 |
| 131 | + |
| 132 | +## 作者 |
| 133 | + |
| 134 | +Created and maintained by Alibaba Cloud Terraform Team( [email protected]). |
| 135 | + |
| 136 | +## 许可 |
| 137 | + |
| 138 | +MIT Licensed. See LICENSE for full details. |
| 139 | + |
| 140 | +## 参考 |
| 141 | + |
| 142 | +* [Terraform-Provider-Alicloud Github](https://github.com/aliyun/terraform-provider-alicloud) |
| 143 | +* [Terraform-Provider-Alicloud Release](https://releases.hashicorp.com/terraform-provider-alicloud/) |
| 144 | +* [Terraform-Provider-Alicloud Docs](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs) |
0 commit comments