活动

天翼云最新优惠活动,涵盖免费试用,产品折扣等,助您降本增效!
热门活动
  • 12.12年度钜惠 NEW 爆款云主机2核2G仅需28.8元/年,X实例35.1元/半年起! 8代机+XSSD新客专享2.5折!
  • 免费体验DeepSeek,上天翼云息壤 NEW 新老用户均可免费体验2500万Tokens,限时两周
  • 云上钜惠 HOT 爆款云主机全场特惠,更有万元锦鲤券等你来领!
  • 算力套餐 HOT 让算力触手可及
  • 天翼云AI产品特惠 NEW 人脸识别+文字识别焕新,新用户免费试用
  • 中小企业服务商合作专区 国家云助力中小企业腾飞,高额上云补贴重磅上线
  • 出海产品促销专区 NEW 爆款云主机低至2折,高性价比,不限新老速来抢购!
  • 天翼云电脑专场 HOT 移动办公新选择,爆款4核8G畅享1年3.5折起,快来抢购!
  • 天翼云奖励推广计划 加入成为云推官,推荐新用户注册下单得现金奖励
免费活动
  • 免费试用中心 HOT 多款云产品免费试用,快来开启云上之旅
  • 天翼云用户体验官 NEW 您的洞察,重塑科技边界

息壤智算

领先开放的智算服务平台,提供算力、平台、数据、模型、应用“五位一体”智算服务体系,构建全流程的AI基础设施能力
智算云(DeepSeek专区)
AI Store
  • 算力市场
  • 模型市场
  • 应用市场
  • MCP市场
算力互联调度平台
  • 裸金属
  • 定制裸金属
训推服务
  • 模型开发
  • 训练任务
  • 服务部署
模型推理服务
  • 模型广场
  • 体验中心
  • 服务接入
应用托管
  • 应用实例
科研助手
  • 科研智能体
  • 科研服务
  • 开发机
  • 并行计算
大模型
  • DeepSeek-V3.1
  • DeepSeek-R1-0528
  • DeepSeek-V3-0324
  • Qwen3-235B-A22B
  • Qwen3-32B
智算一体机
  • 智算一体机
模型适配专家服务
  • 模型适配专家服务
算力服务商
  • 入驻算力服务商

应用商城

天翼云精选行业优秀合作伙伴及千余款商品,提供一站式云上应用服务
进入甄选商城进入云市场进入AI Store创新解决方案智云上海应用生态专区
AI应用
  • 泛微合同管理解决方案
  • 泛微数智大脑Xiaoe.AI解决方案
  • MaxKB知识库解决方案
  • 天翼AI文创
AI服务
  • 昆仑AI训推服务解决方案
  • 国信模型服务解决方案
企业应用
  • 翼电子签约解决方案
  • 翼协同解决方案
  • 翼电签-契约锁解决方案
  • 翼视频云归档解决方案
教育应用
  • 翼电子教室
  • 潜在AI教育解决方案
建站工具
  • SSL证书
  • 翼定制建站解决方案
  • 翼多端小程序解决方案
办公协同
  • 天翼云企业云盘
  • 安全邮箱
灾备迁移
  • 云管家2.0
资源管理
  • 全栈混合云敏捷版(软件)
  • 全栈混合云敏捷版(一体机)

定价

协助您快速了解云产品计费模式、价格详情,轻松预估上云成本
价格计算器
  • 动态测算产品价格
定价策略
  • 快速了解计费模式

合作伙伴

天翼云携手合作伙伴,共创云上生态,合作共赢
天翼云生态合作中心
  • 天翼云生态合作中心
天翼云渠道合作伙伴
  • 天翼云代理渠道合作伙伴
天翼云服务合作伙伴
  • 天翼云集成商交付能力认证
天翼云应用合作伙伴
  • 天翼云云市场合作伙伴
  • 天翼云甄选商城合作伙伴
天翼云技术合作伙伴
  • 天翼云OpenAPI中心
天翼云培训认证
  • 天翼云学堂
  • 天翼云市场商学院
天翼云合作计划
  • 云汇计划
天翼信创云专区
  • 信创云专区
  • 适配互认证

开发者

开发者相关功能入口汇聚
技术社区
  • 专栏文章
  • 互动问答
  • 技术视频
资源与工具
  • OpenAPI中心
培训与认证
  • 天翼云学堂
  • 天翼云认证
魔乐社区
  • 魔乐社区

支持与服务

为您提供全方位支持与服务,全流程技术保障,助您轻松上云,安全无忧
文档与工具
  • 文档中心
  • 新手上云
  • 自助服务
  • OpenAPI中心
定价
  • 价格计算器
  • 定价策略
基础服务
  • 售前咨询
  • 在线支持
  • 在线支持
  • 工单服务
  • 服务保障
  • 会员中心
增值服务
  • 红心服务
  • 首保服务
  • 客户支持计划
  • 专家技术服务
  • 备案管家
我要反馈
  • 建议与反馈
  • 用户体验官
信息公告
  • 客户公告

了解天翼云

天翼云秉承央企使命,致力于成为数字经济主力军,投身科技强国伟大事业,为用户提供安全、普惠云服务
品牌介绍
  • 关于天翼云
  • 智算云
  • 天翼云4.0
  • 新闻资讯
  • 天翼云APP
基础设施
  • 全球基础设施
  • 信任中心
最佳实践
  • 精选案例
  • 超级探访
  • 云杂志
  • 分析师和白皮书
  • 天翼云·创新直播间
市场活动
  • 2025智能云生态大会
  • 2024智算云生态大会
  • 2023云生态大会
  • 2022云生态大会
  • 天翼云中国行
天翼云
  • 活动
  • 息壤智算
  • 产品
  • 解决方案
  • 应用商城
  • 定价
  • 合作伙伴
  • 开发者
  • 支持与服务
  • 了解天翼云
      • 文档
      • 控制中心
      • 备案
      • 管理中心
      文档中心

      资源编排ROS

      资源编排ROS

      • 资源编排ROS

      无数据

        • 产品动态
        • 产品介绍
        • 产品定义
        • 功能特性
        • 产品优势
        • 应用场景
        • 基本概念
        • 与其它服务关系
        • 使用限制
        • 计费说明
        • 计费说明
        • 快速入门
        • 创建一台包年包月云主机
        • 用户指南
        • 创建模板
        • 更新模板
        • 查询模板
        • 模板对比
        • 资源栈状态说明
        • 创建资源栈
        • 更新资源栈
        • 查询资源栈
        • 删除资源栈
        • 查询执行计划
        • 部署资源栈/执行计划
        • 模板参考
        • 概述
        • 版本与支持资源
        • 语法指南
        • 基本语法
        • 常见函数
        • 样式约定
        • 表达式
        • 配置指南
        • Provider
        • Resource
        • Data Source
        • Variable
        • Meta-arguments
        • 模板约束与限制
        • 核心约束与限制
        • 重要警告
        • 模板示例
        • 创建一台包年包月云主机
        • 配置弹性负载均衡
        • 创建MySOL数据库
        • 常见问题
        • 基础概念类
        • 使用问题类
        • 最佳实践
        • 创建一个高可用架构
        • API参考
        • API使用说明
        • 视频专区
        • 文档下载
        • 相关协议
        • 资源编排ROS产品服务协议
          无相关产品

          本页目录

          帮助中心资源编排ROS模板参考模板示例配置弹性负载均衡
          配置弹性负载均衡
          更新时间 2025-12-18 13:57:18
          • 新浪微博
          • 微信
            扫码分享
          • 复制链接
          最近更新时间: 2025-12-18 13:57:18
          分享文章
          • 新浪微博
          • 微信
            扫码分享
          • 复制链接
          本文将为您展示创建一个弹性负载均衡的模板示例。
          terraform {
            required_providers {
              ctyun = {
                source  = "ctyun-it/ctyun"
                version = "1.2.0"
              }
            }
          }
           
          # 支持配置资源池、可用区和企业项目,若不配置资源池,则会使用页面选定的资源池
          # ak/sk无需配置,会自动获取当前账号的ak/sk 
          provider "ctyun" {
            region_id = "bb9fdb42056f11eda1610242ac110002"
            az_name = "cn-huadong1-jsnj1A-public-ctcloud"
          }
           
          # 创建vpc
          resource "ctyun_vpc" "vpc_test" {
            name        = "tf-vpc-ha"
            cidr        = "192.168.0.0/16"
            description = "terraform测试使用"
          }
           
          # 创建子网
          resource "ctyun_subnet" "subnet_test" {
            vpc_id      = ctyun_vpc.vpc_test.id
            name        = "tf-vpc-ha"
            cidr        = "192.168.1.0/24"
            description = "terraform测试使用"
            dns = [
              "114.114.114.114",
              "8.8.8.8"
            ]
          }
           
          # 创建弹性IP
          resource "ctyun_eip" "eip_test" {
            name                = "tf-eip-ha"
            bandwidth           = 1
            cycle_type          = "on_demand"
            demand_billing_type = "bandwidth"
          }
           
          # 查询可用区
          data "ctyun_zones" "test" {
           
          }
           
          locals {
            az1 = data.ctyun_zones.test.zones[0]
            az2 = data.ctyun_zones.test.zones[1]
          }
           
          # az1
          data "ctyun_images" "image_test" {
            az_name    = local.az1
            name       = "CentOS Linux 8.4"
            visibility = "public"
            page_no    = 1
            page_size  = 10
          }
           
          data "ctyun_ecs_flavors" "ecs_flavor_test" {
            az_name = local.az1
            cpu     = 2
            ram     = 4
            arch    = "x86"
            series  = "C"
            type    = "CPU_C7"
          }
           
          resource "ctyun_ecs" "ecs_test" {
            instance_name    = "tf-ecs-ha-1"
            display_name     = "tf-ecs-ha-1"
            flavor_id        = data.ctyun_ecs_flavors.ecs_flavor_test.flavors[0].id
            image_id         = data.ctyun_images.image_test.images[0].id
            system_disk_type = "sata"
            system_disk_size = 40
            vpc_id           = ctyun_vpc.vpc_test.id
            password         = var.password
            az_name          = local.az1
            cycle_type       = "on_demand"
            subnet_id        = ctyun_subnet.subnet_test.id
          }
           
          # az2
          data "ctyun_images" "image_test2" {
            az_name    = local.az2
            name       = "CentOS Linux 8.4"
            visibility = "public"
            page_no    = 1
            page_size  = 10
          }
           
          data "ctyun_ecs_flavors" "ecs_flavor_test2" {
            az_name = local.az2
            cpu     = 2
            ram     = 4
            arch    = "x86"
            series  = "C"
            type    = "CPU_C7"
          }
           
          resource "ctyun_ecs" "ecs_test2" {
            instance_name    = "tf-ecs-ha-2"
            display_name     = "tf-ecs-ha-2"
            flavor_id        = data.ctyun_ecs_flavors.ecs_flavor_test2.flavors[0].id
            image_id         = data.ctyun_images.image_test2.images[0].id
            system_disk_type = "sata"
            system_disk_size = 40
            vpc_id           = ctyun_vpc.vpc_test.id
            password         = var.password
            az_name          = local.az2
            cycle_type       = "on_demand"
            subnet_id        = ctyun_subnet.subnet_test.id
          }
           
          # 创建弹性负载均衡
          resource "ctyun_elb_loadbalancer" "test" {
            az_name       = local.az1
            subnet_id     = ctyun_subnet.subnet_test.id
            name          = "tf-elb-ha"
            sla_name      = "elb.s2.small"
            resource_type = "external"
            vpc_id        = ctyun_vpc.vpc_test.id
            eip_id        = ctyun_eip.eip_test.id
            cycle_type    = "on_demand"
          }
           
          # 创建监听器
          resource "ctyun_elb_listener" "elb_listener_test" {
            loadbalancer_id     = ctyun_elb_loadbalancer.test.id
            name                = "tf-elb-listener-ha"
            protocol            = "TCP"
            protocol_port       = 456
            default_action_type = "forward"
            target_groups = [{ target_group_id = ctyun_elb_target_group.target_group_test.id }]
          }
           
          # 创建后端主机组
          resource "ctyun_elb_target_group" "target_group_test" {
            name      = "tf-target-ha"
            vpc_id    = ctyun_vpc.vpc_test.id
            algorithm = "wrr"
          }
           
          resource "ctyun_elb_target" "target" {
            target_group_id = ctyun_elb_target_group.target_group_test.id
            instance_type = "VM"
            instance_id = ctyun_ecs.ecs_test.id
            protocol_port = 8000
          }
           
          resource "ctyun_elb_target" "target2" {
            target_group_id = ctyun_elb_target_group.target_group_test.id
            instance_type = "VM"
            instance_id = ctyun_ecs.ecs_test2.id
            protocol_port = 8000
          }
           
          # 需要输入密码
          variable "password" {
            type      = string
            sensitive = true
          }
           
          output "eid_address" {
            value = ctyun_eip.eip_test.address
          }
          # 支持配置资源池、可用区和企业项目,若不配置资源池,则会使用页面选定的资源池
          # ak/sk无需配置,会自动获取当前账号的ak/sk 
          provider "ctyun" {
            region_id = "bb9fdb42056f11eda1610242ac110002"
            az_name = "cn-huadong1-jsnj1A-public-ctcloud"
          }
           
          # 创建vpc
          resource "ctyun_vpc" "vpc_test" {
            name        = "tf-vpc-ha"
            cidr        = "192.168.0.0/16"
            description = "terraform测试使用"
          }
           
          # 创建子网
          resource "ctyun_subnet" "subnet_test" {
            vpc_id      = ctyun_vpc.vpc_test.id
            name        = "tf-vpc-ha"
            cidr        = "192.168.1.0/24"
            description = "terraform测试使用"
            dns = [
              "114.114.114.114",
              "8.8.8.8"
            ]
          }
           
          # 创建弹性IP
          resource "ctyun_eip" "eip_test" {
            name                = "tf-eip-ha"
            bandwidth           = 1
            cycle_type          = "on_demand"
            demand_billing_type = "bandwidth"
          }
           
          # 查询可用区
          data "ctyun_zones" "test" {
           
          }
           
          locals {
            az1 = data.ctyun_zones.test.zones[0]
            az2 = data.ctyun_zones.test.zones[1]
          }
           
          # az1
          data "ctyun_images" "image_test" {
            az_name    = local.az1
            name       = "CentOS Linux 8.4"
            visibility = "public"
            page_no    = 1
            page_size  = 10
          }
           
          data "ctyun_ecs_flavors" "ecs_flavor_test" {
            az_name = local.az1
            cpu     = 2
            ram     = 4
            arch    = "x86"
            series  = "C"
            type    = "CPU_C7"
          }
           
          resource "ctyun_ecs" "ecs_test" {
            instance_name    = "tf-ecs-ha-1"
            display_name     = "tf-ecs-ha-1"
            flavor_id        = data.ctyun_ecs_flavors.ecs_flavor_test.flavors[0].id
            image_id         = data.ctyun_images.image_test.images[0].id
            system_disk_type = "sata"
            system_disk_size = 40
            vpc_id           = ctyun_vpc.vpc_test.id
            password         = var.password
            az_name          = local.az1
            cycle_type       = "on_demand"
            subnet_id        = ctyun_subnet.subnet_test.id
          }
           
          # az2
          data "ctyun_images" "image_test2" {
            az_name    = local.az2
            name       = "CentOS Linux 8.4"
            visibility = "public"
            page_no    = 1
            page_size  = 10
          }
           
          data "ctyun_ecs_flavors" "ecs_flavor_test2" {
            az_name = local.az2
            cpu     = 2
            ram     = 4
            arch    = "x86"
            series  = "C"
            type    = "CPU_C7"
          }
           
          resource "ctyun_ecs" "ecs_test2" {
            instance_name    = "tf-ecs-ha-2"
            display_name     = "tf-ecs-ha-2"
            flavor_id        = data.ctyun_ecs_flavors.ecs_flavor_test2.flavors[0].id
            image_id         = data.ctyun_images.image_test2.images[0].id
            system_disk_type = "sata"
            system_disk_size = 40
            vpc_id           = ctyun_vpc.vpc_test.id
            password         = var.password
            az_name          = local.az2
            cycle_type       = "on_demand"
            subnet_id        = ctyun_subnet.subnet_test.id
          }
           
          # 创建弹性负载均衡
          resource "ctyun_elb_loadbalancer" "test" {
            az_name       = local.az1
            subnet_id     = ctyun_subnet.subnet_test.id
            name          = "tf-elb-ha"
            sla_name      = "elb.s2.small"
            resource_type = "external"
            vpc_id        = ctyun_vpc.vpc_test.id
            eip_id        = ctyun_eip.eip_test.id
            cycle_type    = "on_demand"
          }
           
          # 创建监听器
          resource "ctyun_elb_listener" "elb_listener_test" {
            loadbalancer_id     = ctyun_elb_loadbalancer.test.id
            name                = "tf-elb-listener-ha"
            protocol            = "TCP"
            protocol_port       = 456
            default_action_type = "forward"
            target_groups = [{ target_group_id = ctyun_elb_target_group.target_group_test.id }]
          }
           
          # 创建后端主机组
          resource "ctyun_elb_target_group" "target_group_test" {
            name      = "tf-target-ha"
            vpc_id    = ctyun_vpc.vpc_test.id
            algorithm = "wrr"
          }
           
          resource "ctyun_elb_target" "target" {
            target_group_id = ctyun_elb_target_group.target_group_test.id
            instance_type = "VM"
            instance_id = ctyun_ecs.ecs_test.id
            protocol_port = 8000
          }
           
          resource "ctyun_elb_target" "target2" {
            target_group_id = ctyun_elb_target_group.target_group_test.id
            instance_type = "VM"
            instance_id = ctyun_ecs.ecs_test2.id
            protocol_port = 8000
          }
           
           
          # 需要输入密码
          variable "password" {
            type      = string
            sensitive = true
          }
           
          output "eid_address" {
            value = ctyun_eip.eip_test.address
          }
          # 支持配置资源池、可用区和企业项目,若不配置资源池,则会使用页面选定的资源池
          # ak/sk无需配置,会自动获取当前账号的ak/sk 
          provider "ctyun" {
            region_id = "bb9fdb42056f11eda1610242ac110002"
            az_name = "cn-huadong1-jsnj1A-public-ctcloud"
          }
           
          # 创建vpc
          resource "ctyun_vpc" "vpc_test" {
            name        = "tf-vpc-ha"
            cidr        = "192.168.0.0/16"
            description = "terraform测试使用"
          }
           
          # 创建子网
          resource "ctyun_subnet" "subnet_test" {
            vpc_id      = ctyun_vpc.vpc_test.id
            name        = "tf-vpc-ha"
            cidr        = "192.168.1.0/24"
            description = "terraform测试使用"
            dns = [
              "114.114.114.114",
              "8.8.8.8"
            ]
          }
           
          # 创建弹性IP
          resource "ctyun_eip" "eip_test" {
            name                = "tf-eip-ha"
            bandwidth           = 1
            cycle_type          = "on_demand"
            demand_billing_type = "bandwidth"
          }
           
          # 查询可用区
          data "ctyun_zones" "test" {
           
          }
           
          locals {
            az1 = data.ctyun_zones.test.zones[0]
            az2 = data.ctyun_zones.test.zones[1]
          }
           
          # az1
          data "ctyun_images" "image_test" {
            az_name    = local.az1
            name       = "CentOS Linux 8.4"
            visibility = "public"
            page_no    = 1
            page_size  = 10
          }
           
          data "ctyun_ecs_flavors" "ecs_flavor_test" {
            az_name = local.az1
            cpu     = 2
            ram     = 4
            arch    = "x86"
            series  = "C"
            type    = "CPU_C7"
          }
           
          resource "ctyun_ecs" "ecs_test" {
            instance_name    = "tf-ecs-ha-1"
            display_name     = "tf-ecs-ha-1"
            flavor_id        = data.ctyun_ecs_flavors.ecs_flavor_test.flavors[0].id
            image_id         = data.ctyun_images.image_test.images[0].id
            system_disk_type = "sata"
            system_disk_size = 40
            vpc_id           = ctyun_vpc.vpc_test.id
            password         = var.password
            az_name          = local.az1
            cycle_type       = "on_demand"
            subnet_id        = ctyun_subnet.subnet_test.id
          }
           
          # az2
          data "ctyun_images" "image_test2" {
            az_name    = local.az2
            name       = "CentOS Linux 8.4"
            visibility = "public"
            page_no    = 1
            page_size  = 10
          }
           
          data "ctyun_ecs_flavors" "ecs_flavor_test2" {
            az_name = local.az2
            cpu     = 2
            ram     = 4
            arch    = "x86"
            series  = "C"
            type    = "CPU_C7"
          }
           
          resource "ctyun_ecs" "ecs_test2" {
            instance_name    = "tf-ecs-ha-2"
            display_name     = "tf-ecs-ha-2"
            flavor_id        = data.ctyun_ecs_flavors.ecs_flavor_test2.flavors[0].id
            image_id         = data.ctyun_images.image_test2.images[0].id
            system_disk_type = "sata"
            system_disk_size = 40
            vpc_id           = ctyun_vpc.vpc_test.id
            password         = var.password
            az_name          = local.az2
            cycle_type       = "on_demand"
            subnet_id        = ctyun_subnet.subnet_test.id
          }
           
          # 创建弹性负载均衡
          resource "ctyun_elb_loadbalancer" "test" {
            az_name       = local.az1
            subnet_id     = ctyun_subnet.subnet_test.id
            name          = "tf-elb-ha"
            sla_name      = "elb.s2.small"
            resource_type = "external"
            vpc_id        = ctyun_vpc.vpc_test.id
            eip_id        = ctyun_eip.eip_test.id
            cycle_type    = "on_demand"
          }
           
          # 创建监听器
          resource "ctyun_elb_listener" "elb_listener_test" {
            loadbalancer_id     = ctyun_elb_loadbalancer.test.id
            name                = "tf-elb-listener-ha"
            protocol            = "TCP"
            protocol_port       = 456
            default_action_type = "forward"
            target_groups = [{ target_group_id = ctyun_elb_target_group.target_group_test.id }]
          }
           
          # 创建后端主机组
          resource "ctyun_elb_target_group" "target_group_test" {
            name      = "tf-target-ha"
            vpc_id    = ctyun_vpc.vpc_test.id
            algorithm = "wrr"
          }
           
          resource "ctyun_elb_target" "target" {
            target_group_id = ctyun_elb_target_group.target_group_test.id
            instance_type = "VM"
            instance_id = ctyun_ecs.ecs_test.id
            protocol_port = 8000
          }
           
          resource "ctyun_elb_target" "target2" {
            target_group_id = ctyun_elb_target_group.target_group_test.id
            instance_type = "VM"
            instance_id = ctyun_ecs.ecs_test2.id
            protocol_port = 8000
          }
           
           
          # 需要输入密码
          variable "password" {
            type      = string
            sensitive = true
          }
           
          output "eid_address" {
            value = ctyun_eip.eip_test.address
          }
          文档反馈

          建议您登录后反馈,可在建议与反馈里查看问题处理进度

          鼠标选中文档,精准反馈问题

          选中存在疑惑的内容,即可快速反馈问题,我们会跟进处理

          知道了

          上一篇 :  创建一台包年包月云主机
          下一篇 :  创建MySOL数据库
          搜索 关闭
          ©2025 天翼云科技有限公司版权所有 增值电信业务经营许可证A2.B1.B2-20090001
          公司地址:北京市东城区青龙胡同甲1号、3号2幢2层205-32室
          备案 京公网安备11010802043424号 京ICP备 2021034386号
          ©2025天翼云科技有限公司版权所有
          京ICP备 2021034386号
          备案 京公网安备11010802043424号
          增值电信业务经营许可证A2.B1.B2-20090001
          用户协议 隐私政策 法律声明