2 Star 1 Fork 0

HuaweiCloudDeveloper/huaweicloud-solution-migrating-databases-with-dbsyncer

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
migrating-databases-with-dbsyncer.tf.json 9.63 KB
一键复制 编辑 原始数据 按行查看 历史
HWCloudSolution 提交于 2024-02-07 11:47 +08:00 . add dbsyncer codes
{
"terraform": {
"required_providers": [
{
"huaweicloud": {
"source": "huawei.com/provider/huaweicloud",
"version": "1.57.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": "new",
"description": "子网ID。如使用已有虚拟私有云 VPC,请填写已有VPC子网ID;如使用新建VPC须填写new,新建VPC名称同弹性云服务器 ECS名称,子网名称:{ecs_name}-subnet。获取已有VPC子网ID请参考部署指南。默认:new。",
"type": "string",
"nullable": "false",
"validation": {
"condition": "${length(regexall(\"^(([a-z0-9]{8}(-[a-z0-9]{4}){3}-[a-z0-9]{12})|new)$\",var.subnet_id))>0}",
"error_message": "Invalid input. Please re-enter."
}
},
"security_group_name": {
"default": "migrating-databases-with-dbsyncer",
"description": "安全组名称。该模板使用新建安全组。取值范围:1-64个字符,支持数字、字母、中文、_(下划线)、-(中划线)、.(点)。默认:migrating-databases-with-dbsyncer。",
"type": "string",
"nullable": "false"
},
"ecs_name": {
"default": "migrating-databases-with-dbsyncer",
"description": "弹性云服务器 ECS名称。不允许重名。取值范围:1-56个字符组成,支持字母、数字、中文、下划线(_)、中划线(-)、英文句号(.)。默认:migrating-databases-with-dbsyncer。",
"type": "string",
"nullable": "false"
},
"ecs_flavor": {
"default": "s6.large.2",
"description": "弹性云服务器 ECS规格。其他规格请参考部署指南配置,默认:s6.large.2(2U4G)。",
"type": "string",
"nullable": "false",
"validation": {
"condition": "${length(regexall(\"^([a-z][a-z0-9]{1,3}\\\\.)(small\\\\.|medium\\\\.|(x||[1-9][0-9]{0,1}x)large\\\\.)[1-9][0-9]{0,1}$\",var.ecs_flavor))>0}",
"error_message": "Invalid input. Please re-enter."
}
},
"system_disk_size": {
"default": 100,
"description": "弹性云服务器 ECS系统盘大小,磁盘类型默认为通用型SSD。单位:GB,取值范围为40~1,024,不支持缩盘。默认为100。",
"type": "number",
"nullable": "false",
"validation": {
"condition": "${length(regexall(\"^([4-9]\\\\d|[1-9]\\\\d{2}|10[0-1][0-9]|102[0-4])$\",var.system_disk_size))>0}",
"error_message": "Invalid input, please re-enter."
}
},
"ecs_password": {
"default": "",
"description": "弹性云服务器 ECS密码。取值范围:长度为8-26个字符,密码至少包含大写字母、小写字母、数字和特殊字符(!@$%^-_=+[{()}]:,./?~#*)中的三种,Windows系统密码不能包含用户名或用户名的逆序,不能包含用户名中超过两个连续字符的部分。管理员账户默认root。",
"type": "string",
"nullable": "false",
"sensitive": "true"
},
"charging_mode": {
"default": "postPaid",
"description": "弹性云服务器 ECS计费模式,默认自动扣费。可选值为:postPaid(按需计费)、prePaid(包年包月)。默认postPaid。",
"type": "string",
"nullable": "false",
"validation": {
"condition": "${contains([\"postPaid\",\"prePaid\"], var.charging_mode)}",
"error_message": "Invalid input, please re-enter."
}
},
"charging_unit": {
"default": "month",
"description": "弹性云服务器 ECS订购周期类型,仅当charging_mode为prePaid(包年/包月)生效,此时该参数为必填参数。可选值为:month(月),year(年)。默认month。",
"type": "string",
"nullable": "false",
"validation": {
"condition": "${contains([\"month\",\"year\"], var.charging_unit)}",
"error_message": "Invalid input, please re-enter."
}
},
"charging_period": {
"default": 1,
"description": "弹性云服务器 ECS订购周期,仅当charging_mode为prePaid(包年/包月)生效,此时该参数为必填参数。当charging_unit=month(周期类型为月)时,取值范围:1-9;当charging_unit=year(周期类型为年)时,取值范围:1-3。默认订购1个月。",
"type": "number",
"nullable": "false",
"validation": {
"condition": "${length(regexall(\"^[1-9]$\",var.charging_period))>0}",
"error_message": "Invalid input, please re-enter."
}
}
},
"data": {
"huaweicloud_availability_zones": {
"az": {}
},
"huaweicloud_images_image": {
"image": {
"most_recent": true,
"name": "CentOS 8.0 64bit",
"visibility": "public"
}
},
"huaweicloud_vpc_subnet": {
"subnet": {
"count": "${var.subnet_id == \"new\" ? 0 : 1}",
"id": "${var.subnet_id}"
}
}
},
"resource": {
"huaweicloud_vpc": {
"vpc": {
"count": "${var.subnet_id == \"new\" ? 1 : 0}",
"cidr": "192.168.0.0/16",
"name": "${var.ecs_name}"
}
},
"huaweicloud_vpc_subnet": {
"subnet": {
"count": "${var.subnet_id == \"new\" ? 1 : 0}",
"cidr": "${huaweicloud_vpc.vpc[0].cidr}",
"gateway_ip": "192.168.0.1",
"name": "${var.ecs_name}-subnet",
"vpc_id": "${huaweicloud_vpc.vpc[0].id}"
}
},
"huaweicloud_networking_secgroup": {
"secgroup": {
"name": "${var.security_group_name}"
}
},
"huaweicloud_networking_secgroup_rule": {
"allow_accessing_dbsyncer": {
"description": "访问DBSyncer界面的网络端口",
"direction": "ingress",
"ethertype": "IPv4",
"ports": "18686",
"protocol": "tcp",
"remote_ip_prefix": "192.168.0.0/16",
"security_group_id": "${huaweicloud_networking_secgroup.secgroup.id}"
},
"allow_ping": {
"description": "允许ping程序测试弹性云服务器的连通性",
"direction": "ingress",
"ethertype": "IPv4",
"protocol": "icmp",
"remote_ip_prefix": "0.0.0.0/0",
"security_group_id": "${huaweicloud_networking_secgroup.secgroup.id}"
}
},
"huaweicloud_vpc_eip": {
"eip": {
"name": "${var.ecs_name}-eip",
"bandwidth": {
"charge_mode": "traffic",
"name": "${var.ecs_name}-traffic",
"share_type": "PER",
"size": 300
},
"publicip": {
"type": "5_bgp"
},
"charging_mode": "postPaid"
}
},
"huaweicloud_compute_instance": {
"ecs": {
"depends_on": [
"huaweicloud_vpc_eip.eip"
],
"eip_id": "${huaweicloud_vpc_eip.eip.id}",
"availability_zone": "${data.huaweicloud_availability_zones.az.names[0]}",
"flavor_id": "${var.ecs_flavor}",
"image_id": "${data.huaweicloud_images_image.image.id}",
"name": "${var.ecs_name}",
"network": {
"uuid": "${var.subnet_id == \"new\" ? huaweicloud_vpc_subnet.subnet[0].id : data.huaweicloud_vpc_subnet.subnet[0].id}"
},
"security_group_ids": [
"${huaweicloud_networking_secgroup.secgroup.id}"
],
"system_disk_size": "${var.system_disk_size}",
"system_disk_type": "GPSSD",
"charging_mode": "${var.charging_mode}",
"period_unit": "${var.charging_unit}",
"period": "${var.charging_period}",
"agent_list": "ces,hss",
"user_data": "#!/bin/bash\necho 'root:${var.ecs_password}' | chpasswd\nwget -P /root/ https://documentation-samples.obs.cn-north-4.myhuaweicloud.com/solution-as-code-publicbucket/solution-as-code-moudle/migrating-databases-with-dbsyncer/userdata/install_dbsyncer.sh\nchmod 744 /root/install_dbsyncer.sh\nsource /root/install_dbsyncer.sh >>/tmp/install_dbsyncer.log\nrm -rf /root/install_dbsyncer.sh"
}
}
},
"output": {
"登录DBSyncer页面": {
"value": "部署成功后,再耐心等待5-10分钟,在浏览器页面访问http://${huaweicloud_vpc_eip.eip.address}:18686,即可访问DBSyncer环境界面。"
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/HuaweiCloudDeveloper/huaweicloud-solution-migrating-databases-with-dbsyncer.git
git@gitee.com:HuaweiCloudDeveloper/huaweicloud-solution-migrating-databases-with-dbsyncer.git
HuaweiCloudDeveloper
huaweicloud-solution-migrating-databases-with-dbsyncer
huaweicloud-solution-migrating-databases-with-dbsyncer
master-dev

搜索帮助