4 Star 1 Fork 2

HuaweiCloudDeveloper/huaweicloud-solution-build-high-availability-four-layer-load-balancing

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build-high-availability-four-layer-load-balancing.tf.json 8.78 KB
一键复制 编辑 原始数据 按行查看 历史
HWCloudSolution 提交于 2023-01-04 09:52 . 代码优化
{
"terraform": {
"required_providers": [
{
"huaweicloud": {
"source": "huawei.com/provider/huaweicloud",
"version": ">=1.37.0"
}
}
]
},
"provider": {
"huaweicloud": {
"cloud": "myhuaweicloud.com",
"endpoints": {
"iam": "iam.cn-north-4.myhuaweicloud.com",
"dns": "dns.cn-north-4.myhuaweicloud.com"
},
"insecure": true,
"region": "cn-north-4",
"auth_url": "https://iam.cn-north-4.myhuaweicloud.com/v3"
}
},
"variable": {
"subnet_id": {
"default": "",
"description": "子网ID,该模板使用已有子网,请选择后端业务服务器所在虚拟私有云VPC内子网,查询子网ID请参考部署指南。",
"type": "string",
"nullable": false
},
"security_group_id": {
"default": "",
"description": "安全组ID,该模板使用已有安全组,建议选择后端业务服务器相同安全组,查询安全组ID请参考部署指南。",
"type": "string",
"nullable": false
},
"ecs_name": {
"default": "high-availability-four-layer-load-balancing-demo",
"description": "负载均衡主、备云服务器名称,命名方式为{ecs_name}-master,{ecs_name}-backup,不支持重名。取值范围:1-57个字符组成,包括字母、数字、下划线 (_)、连字符 (-) 和句点 (.)。默认high-availability-four-layer-load-balancing-demo。",
"type": "string",
"nullable": false
},
"ecs_flavor": {
"default": "s6.large.2",
"description": "负载均衡主、备云服务器规格,规格请参考部署指南配置。默认s6.large.2(c6|2vCPUs|4GiB)。",
"type": "string",
"nullable": false
},
"ecs_password": {
"default": "",
"description": "负载均衡主、备云服务器初始化密码,创建完成后,请参考部署指南登录ECS控制台修改密码。取值范围:长度为8-26个字符,密码至少包含大写字母、小写字母、数字和特殊字符($!@%-_=+[]:./^,{}?)中的三种,密码不能包含用户名或用户名的逆序。管理员账户默认为root。",
"type": "string",
"nullable": false,
"sensitive": true
},
"bandwidth_size": {
"default": "5",
"description": "带宽大小,该模板计费方式为按带宽计费。取值范围:1-2,000Mbit/s。默认5Mbit/s。",
"type": "number",
"nullable": false
},
"ip_list": {
"default": "",
"description": "用户后端业务服务器的私有IP地址,多个IP之间以英文半角逗号(,)隔开。",
"type": "string",
"nullable": false
},
"charge_mode": {
"default": "postPaid",
"description": "计费模式,默认自动扣费,可选值为:postPaid(按需计费)、prePaid(包年包月),默认postPaid。",
"type": "string",
"nullable": false
},
"charge_period_unit": {
"default": "month",
"description": "订购周期类型,仅当charge_mode为prePaid(包年/包月)生效。取值范围:month(月),year(年)。默认month。",
"type": "string",
"nullable": false
},
"charge_period": {
"default": 1,
"description": "订购周期,仅当charge_mode为prePaid(包年/包月)生效。取值范围:charge_period_unit=month(周期类型为月)时,取值为1-9;charge_period_unit=year(周期类型为年)时,取值为1-3。默认订购1月。",
"type": "number",
"nullable": false
}
},
"data": {
"huaweicloud_availability_zones": {
"zones": {}
},
"huaweicloud_images_image": {
"euleros": {
"name": "EulerOS 2.5 64bit",
"visibility": "public",
"most_recent": true
}
}
},
"resource": {
"huaweicloud_networking_vip": {
"myvip": {
"name": "${var.ecs_name}-vip",
"network_id": "${var.subnet_id}"
}
},
"huaweicloud_vpc_eip": {
"myeip": {
"bandwidth": {
"share_type": "PER",
"name": "${var.ecs_name}-eip",
"size": "${var.bandwidth_size}",
"charge_mode": "bandwidth"
},
"publicip": {
"type": "5_bgp"
},
"charging_mode": "${var.charge_mode}",
"period_unit": "${var.charge_period_unit}",
"period": "${var.charge_period}"
}
},
"huaweicloud_compute_instance": {
"lvs_master": {
"name": "${var.ecs_name}-master",
"availability_zone": "${data.huaweicloud_availability_zones.zones.names[0]}",
"image_id": "${data.huaweicloud_images_image.euleros.id}",
"flavor_id": "${var.ecs_flavor}",
"security_group_ids": [
"${var.security_group_id}"
],
"system_disk_type": "SAS",
"system_disk_size": 100,
"admin_pass": "${var.ecs_password}",
"delete_disks_on_termination": true,
"network": {
"uuid": "${var.subnet_id}",
"source_dest_check": false
},
"charging_mode": "${var.charge_mode}",
"period_unit": "${var.charge_period_unit}",
"period": "${var.charge_period}",
"user_data": "#!/bin/bash\necho 'root:${var.ecs_password}' | chpasswd\nwget -P /etc/keepalived/ https://documentation-samples.obs.cn-north-4.myhuaweicloud.com/solution-as-code-publicbucket/solution-as-code-moudle/build-high-availability-four-layer-load-balancing/userdata/configure-lvs-keepalived-master.sh\nchmod +x /etc/keepalived/configure-lvs-keepalived-master.sh\nsh /etc/keepalived/configure-lvs-keepalived-master.sh ${huaweicloud_networking_vip.myvip.ip_address} ${var.ip_list}\nrm -rf /etc/keepalived/configure-lvs-keepalived-master.sh"
},
"lvs_backup": {
"name": "${var.ecs_name}-backup",
"availability_zone": "${data.huaweicloud_availability_zones.zones.names[0]}",
"image_id": "${data.huaweicloud_images_image.euleros.id}",
"flavor_id": "${var.ecs_flavor}",
"security_group_ids": [
"${var.security_group_id}"
],
"system_disk_type": "SAS",
"system_disk_size": 100,
"admin_pass": "${var.ecs_password}",
"delete_disks_on_termination": true,
"network": {
"uuid": "${var.subnet_id}",
"source_dest_check": false
},
"charging_mode": "${var.charge_mode}",
"period_unit": "${var.charge_period_unit}",
"period": "${var.charge_period}",
"user_data": "#!/bin/bash\necho 'root:${var.ecs_password}' | chpasswd\nwget -P /etc/keepalived/ https://documentation-samples.obs.cn-north-4.myhuaweicloud.com/solution-as-code-publicbucket/solution-as-code-moudle/build-high-availability-four-layer-load-balancing/userdata/configure-lvs-keepalived-backup.sh\nchmod +x /etc/keepalived/configure-lvs-keepalived-backup.sh\nsh /etc/keepalived/configure-lvs-keepalived-backup.sh ${huaweicloud_networking_vip.myvip.ip_address} ${var.ip_list}\nrm -rf /etc/keepalived/configure-lvs-keepalived-backup.sh"
}
},
"huaweicloud_vpc_eip_associate": {
"associated_vip": {
"public_ip": "${huaweicloud_vpc_eip.myeip.address}",
"port_id": "${huaweicloud_networking_vip.myvip.id}"
}
},
"huaweicloud_networking_vip_associate": {
"lvs_associated_vip": {
"vip_id": "${huaweicloud_networking_vip.myvip.id}",
"port_ids": [
"${huaweicloud_compute_instance.lvs_master.network.0.port}",
"${huaweicloud_compute_instance.lvs_backup.network.0.port}"
]
}
}
},
"output": {
"说明": {
"depends_on": ["huaweicloud_vpc_eip_associate.associated_vip"],
"value": "虚拟IP私网地址为:${huaweicloud_networking_vip.myvip.ip_address},用户可以通过浏览器访问虚拟IP绑定的弹性公网IP访问业务服务器:http://${huaweicloud_vpc_eip.myeip.address}。"
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/HuaweiCloudDeveloper/huaweicloud-solution-build-high-availability-four-layer-load-balancing.git
git@gitee.com:HuaweiCloudDeveloper/huaweicloud-solution-build-high-availability-four-layer-load-balancing.git
HuaweiCloudDeveloper
huaweicloud-solution-build-high-availability-four-layer-load-balancing
huaweicloud-solution-build-high-availability-four-layer-load-balancing
master-dev

搜索帮助

0d507c66 1850385 C8b1a773 1850385