Skip to content

Commit 3085b05

Browse files
committed
examples/complete: improve the examples
1 parent 880aaf1 commit 3085b05

File tree

8 files changed

+121
-28
lines changed

8 files changed

+121
-28
lines changed

README-CN.md

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Terraform Module for creating Service Mesh on Alibaba Cloud.
33
terraform-alicloud-service-mesh
44
=====================================================================
55

6-
[English](README.md) | 简体中文
6+
[English](https://github.com/alibabacloud-automation/terraform-alicloud-service-mesh/blob/main/README.md) | 简体中文
77

88
本 Module 用于在阿里云自动化创建和管理服务网格。
99

@@ -27,18 +27,61 @@ module "example" {
2727
* 本 Module 使用的 AccessKey 和 SecretKey 可以直接从 `profile``shared_credentials_file`
2828
中获取。如果未设置,可通过下载安装 [aliyun-cli](https://github.com/aliyun/aliyun-cli#installation) 后进行配置.
2929

30-
## 要求
30+
#<!-- BEGIN_TF_DOCS -->
31+
## Requirements
3132

3233
| Name | Version |
3334
|------|---------|
34-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | > = 0.13.0 |
35-
| <a name="requirement_alicloud"></a> [alicloud](#requirement\_alicloud) | > = 1.138.0 |
35+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
3636

3737
## Providers
3838

3939
| Name | Version |
4040
|------|---------|
41-
| <a name="provider_alicloud"></a> [alicloud](#provider\_alicloud) | > = 1.138.0 |
41+
| <a name="provider_alicloud"></a> [alicloud](#provider\_alicloud) | n/a |
42+
43+
## Modules
44+
45+
No modules.
46+
47+
## Resources
48+
49+
| Name | Type |
50+
|------|------|
51+
| [alicloud_service_mesh_service_mesh.mesh](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/service_mesh_service_mesh) | resource |
52+
53+
## Inputs
54+
55+
| Name | Description | Type | Default | Required |
56+
|------|-------------|------|---------|:--------:|
57+
| <a name="input_access_log"></a> [access\_log](#input\_access\_log) | The configuration of the access logging. | `map(string)` | `{}` | no |
58+
| <a name="input_audit"></a> [audit](#input\_audit) | The configuration of the audit. | `map(string)` | `{}` | no |
59+
| <a name="input_create_service_mesh"></a> [create\_service\_mesh](#input\_create\_service\_mesh) | Controls if service mesh should be created | `bool` | `false` | no |
60+
| <a name="input_customized_zipkin"></a> [customized\_zipkin](#input\_customized\_zipkin) | Whether or not to enable the use of a custom zipkin. | `bool` | `false` | no |
61+
| <a name="input_edition"></a> [edition](#input\_edition) | The type of the resource. Valid values: Default and Pro. Default:the standard. Pro:the Pro version. | `string` | `"Default"` | no |
62+
| <a name="input_enable_locality_lb"></a> [enable\_locality\_lb](#input\_enable\_locality\_lb) | The enable locality lb. | `bool` | `false` | no |
63+
| <a name="input_force"></a> [force](#input\_force) | This parameter is used for resource destroy. Default value is false. | `bool` | `false` | no |
64+
| <a name="input_kiali"></a> [kiali](#input\_kiali) | The configuration of the Kiali. | `map(string)` | `{}` | no |
65+
| <a name="input_load_balancer"></a> [load\_balancer](#input\_load\_balancer) | The configuration of the Load Balancer. | `map(string)` | `{}` | no |
66+
| <a name="input_name"></a> [name](#input\_name) | The name of the resource. | `string` | `""` | no |
67+
| <a name="input_opa"></a> [opa](#input\_opa) | The open-door policy of agent (OPA) plug-in information. | `map(string)` | `{}` | no |
68+
| <a name="input_outbound_traffic_policy"></a> [outbound\_traffic\_policy](#input\_outbound\_traffic\_policy) | The policy of the Out to the traffic. Valid values: ALLOW\_ANY and REGISTRY\_ONLY. | `string` | `"ALLOW_ANY"` | no |
69+
| <a name="input_pilot"></a> [pilot](#input\_pilot) | The configuration of the Link trace sampling. | `map(string)` | `{}` | no |
70+
| <a name="input_proxy"></a> [proxy](#input\_proxy) | The configuration of the Proxy. | `map(string)` | `{}` | no |
71+
| <a name="input_service_mesh_version"></a> [service\_mesh\_version](#input\_service\_mesh\_version) | The version of the resource. you can look up the version using `alicloud_service_mesh_versions`. | `string` | `null` | no |
72+
| <a name="input_sidecar_injector"></a> [sidecar\_injector](#input\_sidecar\_injector) | The configuration of the Sidecar injector. | `map(string)` | `{}` | no |
73+
| <a name="input_telemetry"></a> [telemetry](#input\_telemetry) | Whether to enable acquisition Prometheus metrics | `bool` | `false` | no |
74+
| <a name="input_tracing"></a> [tracing](#input\_tracing) | Whether to enable link trace | `bool` | `false` | no |
75+
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The ID of the VPC. | `string` | `""` | no |
76+
| <a name="input_vswitche_ids"></a> [vswitche\_ids](#input\_vswitche\_ids) | The list of Virtual Switch. | `list(string)` | `[]` | no |
77+
78+
## Outputs
79+
80+
| Name | Description |
81+
|------|-------------|
82+
| <a name="output_service_mesh_id"></a> [service\_mesh\_id](#output\_service\_mesh\_id) | The resource ID in terraform of Service Mesh. |
83+
| <a name="output_service_mesh_status"></a> [service\_mesh\_status](#output\_service\_mesh\_status) | The status of the resource. |
84+
<!-- END_TF_DOCS -->
4285

4386
## 提交问题
4487

README.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Terraform Module for creating Service Mesh on Alibaba Cloud.
33
terraform-alicloud-service-mesh
44
=====================================================================
55

6-
English | [简体中文](README-CN.md)
6+
English | [简体中文](https://github.com/alibabacloud-automation/terraform-alicloud-service-mesh/blob/main/README-CN.md)
77

88
This module is used to create a Service Mesh with `VPC` and `Vswitch` under Alibaba Cloud.
99

@@ -30,18 +30,62 @@ module "example" {
3030
* This module using AccessKey and SecretKey are from `profile` and `shared_credentials_file`. If you have not set them
3131
yet, please install [aliyun-cli](https://github.com/aliyun/aliyun-cli#installation) and configure it.
3232

33+
34+
<!-- BEGIN_TF_DOCS -->
3335
## Requirements
3436

3537
| Name | Version |
3638
|------|---------|
37-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | > = 0.13.0 |
38-
| <a name="requirement_alicloud"></a> [alicloud](#requirement\_alicloud) | > = 1.138.0 |
39+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
3940

4041
## Providers
4142

4243
| Name | Version |
4344
|------|---------|
44-
| <a name="provider_alicloud"></a> [alicloud](#provider\_alicloud) | > = 1.138.0 |
45+
| <a name="provider_alicloud"></a> [alicloud](#provider\_alicloud) | n/a |
46+
47+
## Modules
48+
49+
No modules.
50+
51+
## Resources
52+
53+
| Name | Type |
54+
|------|------|
55+
| [alicloud_service_mesh_service_mesh.mesh](https://registry.terraform.io/providers/hashicorp/alicloud/latest/docs/resources/service_mesh_service_mesh) | resource |
56+
57+
## Inputs
58+
59+
| Name | Description | Type | Default | Required |
60+
|------|-------------|------|---------|:--------:|
61+
| <a name="input_access_log"></a> [access\_log](#input\_access\_log) | The configuration of the access logging. | `map(string)` | `{}` | no |
62+
| <a name="input_audit"></a> [audit](#input\_audit) | The configuration of the audit. | `map(string)` | `{}` | no |
63+
| <a name="input_create_service_mesh"></a> [create\_service\_mesh](#input\_create\_service\_mesh) | Controls if service mesh should be created | `bool` | `false` | no |
64+
| <a name="input_customized_zipkin"></a> [customized\_zipkin](#input\_customized\_zipkin) | Whether or not to enable the use of a custom zipkin. | `bool` | `false` | no |
65+
| <a name="input_edition"></a> [edition](#input\_edition) | The type of the resource. Valid values: Default and Pro. Default:the standard. Pro:the Pro version. | `string` | `"Default"` | no |
66+
| <a name="input_enable_locality_lb"></a> [enable\_locality\_lb](#input\_enable\_locality\_lb) | The enable locality lb. | `bool` | `false` | no |
67+
| <a name="input_force"></a> [force](#input\_force) | This parameter is used for resource destroy. Default value is false. | `bool` | `false` | no |
68+
| <a name="input_kiali"></a> [kiali](#input\_kiali) | The configuration of the Kiali. | `map(string)` | `{}` | no |
69+
| <a name="input_load_balancer"></a> [load\_balancer](#input\_load\_balancer) | The configuration of the Load Balancer. | `map(string)` | `{}` | no |
70+
| <a name="input_name"></a> [name](#input\_name) | The name of the resource. | `string` | `""` | no |
71+
| <a name="input_opa"></a> [opa](#input\_opa) | The open-door policy of agent (OPA) plug-in information. | `map(string)` | `{}` | no |
72+
| <a name="input_outbound_traffic_policy"></a> [outbound\_traffic\_policy](#input\_outbound\_traffic\_policy) | The policy of the Out to the traffic. Valid values: ALLOW\_ANY and REGISTRY\_ONLY. | `string` | `"ALLOW_ANY"` | no |
73+
| <a name="input_pilot"></a> [pilot](#input\_pilot) | The configuration of the Link trace sampling. | `map(string)` | `{}` | no |
74+
| <a name="input_proxy"></a> [proxy](#input\_proxy) | The configuration of the Proxy. | `map(string)` | `{}` | no |
75+
| <a name="input_service_mesh_version"></a> [service\_mesh\_version](#input\_service\_mesh\_version) | The version of the resource. you can look up the version using `alicloud_service_mesh_versions`. | `string` | `null` | no |
76+
| <a name="input_sidecar_injector"></a> [sidecar\_injector](#input\_sidecar\_injector) | The configuration of the Sidecar injector. | `map(string)` | `{}` | no |
77+
| <a name="input_telemetry"></a> [telemetry](#input\_telemetry) | Whether to enable acquisition Prometheus metrics | `bool` | `false` | no |
78+
| <a name="input_tracing"></a> [tracing](#input\_tracing) | Whether to enable link trace | `bool` | `false` | no |
79+
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The ID of the VPC. | `string` | `""` | no |
80+
| <a name="input_vswitche_ids"></a> [vswitche\_ids](#input\_vswitche\_ids) | The list of Virtual Switch. | `list(string)` | `[]` | no |
81+
82+
## Outputs
83+
84+
| Name | Description |
85+
|------|-------------|
86+
| <a name="output_service_mesh_id"></a> [service\_mesh\_id](#output\_service\_mesh\_id) | The resource ID in terraform of Service Mesh. |
87+
| <a name="output_service_mesh_status"></a> [service\_mesh\_status](#output\_service\_mesh\_status) | The status of the resource. |
88+
<!-- END_TF_DOCS -->
4589

4690
## Submit Issues
4791

examples/complete/main.tf

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ data "alicloud_zones" "default" {
77
}
88

99
module "vpc" {
10-
source = "alibaba/vpc/alicloud"
10+
source = "alibaba/vpc/alicloud"
11+
version = "~> 1.11.0"
12+
1113
create = true
1214
vpc_name = "tf-test-service-mesh"
1315
vpc_cidr = "172.16.0.0/16"
1416
vswitch_name = "tf-test-service-mesh"
1517
vswitch_cidrs = ["172.16.0.0/21"]
16-
availability_zones = [data.alicloud_zones.default.zones.0.id]
18+
availability_zones = [data.alicloud_zones.default.zones[0].id]
1719
}
1820

1921
resource "random_integer" "default" {
@@ -22,8 +24,8 @@ resource "random_integer" "default" {
2224
}
2325

2426
resource "alicloud_log_project" "default" {
25-
name = "tf-example-${random_integer.default.result}"
26-
description = "created by terraform"
27+
project_name = "tf-example-${random_integer.default.result}"
28+
description = "created by terraform"
2729
}
2830

2931

@@ -34,10 +36,10 @@ data "alicloud_service_mesh_versions" "default" {
3436
module "example" {
3537
source = "../.."
3638
create_service_mesh = true
37-
name = var.name
39+
name = "${var.name}--${random_integer.default.result}"
3840
vpc_id = module.vpc.this_vpc_id
3941
vswitche_ids = [module.vpc.this_vswitch_ids[0]]
40-
service_mesh_version = reverse(data.alicloud_service_mesh_versions.default.versions).0.version
42+
service_mesh_version = reverse(data.alicloud_service_mesh_versions.default.versions)[0].version
4143
edition = var.edition
4244
force = var.force
4345
customized_zipkin = var.customized_zipkin

examples/complete/variables.tf

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ variable "force" {
2020
variable "customized_zipkin" {
2121
description = "Whether or not to enable the use of a custom zipkin."
2222
type = bool
23-
default = false
23+
default = true
2424
}
2525

2626
variable "enable_locality_lb" {
@@ -47,15 +47,6 @@ variable "access_log" {
4747
default = {}
4848
}
4949

50-
variable "audit" {
51-
description = "The configuration of the audit."
52-
type = map(string)
53-
default = {
54-
55-
56-
}
57-
}
58-
5950
variable "kiali" {
6051
description = "The configuration of the Kiali."
6152
type = map(string)

examples/complete/versions.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
terraform {
2+
required_version = ">= 0.13"
3+
required_providers {
4+
alicloud = {
5+
source = "hashicorp/alicloud"
6+
}
7+
}
8+
}

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ resource "alicloud_service_mesh_service_mesh" "mesh" {
2323
enabled = lookup(var.access_log, "enabled", false)
2424
}
2525
audit {
26-
enabled = lookup(var.audit, "enabled",null)
26+
enabled = lookup(var.audit, "enabled", null)
2727
project = lookup(var.audit, "project", null)
2828
}
2929
kiali {

outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
output "service_mesh_id" {
33
description = "The resource ID in terraform of Service Mesh."
4-
value = concat(alicloud_service_mesh_service_mesh.mesh.*.id, [""])[0]
4+
value = concat(alicloud_service_mesh_service_mesh.mesh[*].id, [""])[0]
55
}
66

77
output "service_mesh_status" {
88
description = "The status of the resource."
9-
value = concat(alicloud_service_mesh_service_mesh.mesh.*.status, [""])[0]
9+
value = concat(alicloud_service_mesh_service_mesh.mesh[*].status, [""])[0]
1010
}

versions.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
terraform {
22
required_version = ">= 0.13"
3+
required_providers {
4+
alicloud = {
5+
source = "hashicorp/alicloud"
6+
}
7+
}
38
}

0 commit comments

Comments
 (0)