すべてのプロダクト
Search
ドキュメントセンター

Resource Orchestration Service:ALIYUN::REDIS::Instance

最終更新日:Feb 07, 2026

ALIYUN::REDIS::Instance タイプは、Redis インスタンスを作成します。

構文

 {
  "Type": "ALIYUN::REDIS::Instance",
  "Properties": {
    "VpcId": String,
    "EvictionPolicy": String,
    "BackupPolicy": Map,
    "ZoneId": String,
    "InstanceClass": String,
    "InstanceMaintainTime": Map,
    "Tags": List,
    "VpcPasswordFree": Boolean,
    "VSwitchId": String,
    "SecurityGroupId": String,
    "EngineVersion": String,
    "SSLEnabled": String,
    "Password": String,
    "InstanceName": String,
    "DeletionForce": Boolean,
    "Connections": Map,
    "ChargeType": String,
    "Period": Integer,
    "AutoRenewDuration": Integer,
    "ProductType": String,
    "SubscriptionDeletionForce": Boolean,
    "SecondaryZoneId": String,
    "ResourceGroupId": String,
    "PeriodUnit": String,
    "TairConfig": Map,
    "ShardCount": Integer,
    "NodeType": String,
    "DeletionProtection": Boolean,
    "ReadOnlyCount": Integer
  }
}

プロパティ

プロパティ名

タイプ

必須

更新可能

説明

制約事項

EngineVersion

String

いいえ

はい

データベースエンジンのバージョンです。

有効値:

  • 2.8

    説明

    廃止されました。別のバージョンを選択してください。

  • 4.0

  • 5.0

InstanceClass

String

いいえ

はい

インスタンスタイプです。

詳細については、「インスタンスタイプナビゲーションとよくある質問」をご参照ください。

InstanceMaintainTime

Map

いいえ

はい

インスタンスのメンテナンスウィンドウです。

なし

Tags

List

いいえ

はい

タグです。

各インスタンスには最大 20 個のタグを設定できます。

詳細については、「Tags プロパティ」をご参照ください。

VpcPasswordFree

Boolean

いいえ

いいえ

VPC 内のインスタンスへのパスワード不要アクセスを有効または無効にします。

有効値:

  • true:有効化

  • false(デフォルト):無効化

VpcId

String

いいえ

いいえ

VPC ID です。

なし

EvictionPolicy

String

いいえ

いいえ

データの立ち退きポリシーです。

有効値:

  • noeviction:キーを削除しません。書き込み操作時にエラーを返します。

  • allkeys-lru:最近使用されていないキーを最初に削除します。

  • volatile-lru:有効期限が設定されているキーの中から、最近使用されていないものを削除します。

  • allkeys-random:ランダムにキーを削除します。

  • volatile-random:有効期限が設定されているキーの中からランダムに削除します。

  • volatile-ttl:有効期限が設定されているキーの中から、生存時間(TTL)が最も短いものを削除します。

ZoneId

String

いいえ

いいえ

ゾーン ID です。

VPC 内にインスタンスを作成する場合は、このパラメーターが必須です。

マルチゾーンインスタンスを作成する場合、サポートされているマルチゾーン ID を取得するには、DescribeZones - サポートされているゾーンの照会 API 操作を呼び出してください。

VSwitchId

String

いいえ

いいえ

VPC 内の vSwitch ID です。

なし

SecurityGroupId

String

いいえ

はい

セキュリティグループ ID です。

最大 10 個の ID を設定できます。ID はカンマ(,)で区切ります。

Password

String

いいえ

はい

パスワードです。

パスワードは 8~30 文字で、大文字、小文字、数字を含む必要があります。

SSLEnabled

String

いいえ

はい

SSL のステータスです。

有効値:

  • Disable:SSL を無効化

  • この機能は有効になっています。

  • Update:証明書を更新

InstanceName

String

いいえ

はい

インスタンス名です。

インスタンス名は 2~128 文字で、先頭は英字または漢字である必要があります。英字、数字、漢字、アンダースコア(_)、ハイフン(-)、ピリオド(.)を含めることができます。

DeletionForce

Boolean

いいえ

はい

復旧時にインスタンスを削除します。

有効値:

  • true:復旧時にインスタンスを削除

  • false(デフォルト):復旧時にインスタンスを削除しない

SubscriptionDeletionForce

Boolean

いいえ

いいえ

このオプションはサブスクリプションインスタンスにのみ適用されます。サブスクリプションインスタンスの場合、このオプションが true の場合、削除前に従量課金インスタンスに変換されます。false の場合、システムは強制削除を行いません。この操作には追加料金が発生しますので、慎重に選択してください。

なし

Connections

Map

いいえ

はい

接続エンドポイントです。

詳細については、「Connections プロパティ」をご参照ください。

BackupPolicy

Map

いいえ

はい

バックアップポリシーです。

詳細については、「BackupPolicy プロパティ」をご参照ください。

ChargeType

String

いいえ

はい

インスタンスの課金方法です。

有効値:

  • PostPaid(デフォルト):従量課金

  • PrePaid:サブスクリプション

Period

Integer

いいえ

はい

課金サイクルです。

有効値:1~9、12、24、36、60。

単位:月。

AutoRenewDuration

Integer

いいえ

はい

自動更新期間です。

有効値:1~12。

単位:月。

インスタンスの有効期限が近づくと、このパラメーターで指定された期間分自動的に更新されます。

説明

このパラメーターは ChargeType が PrePaid に設定されている場合に有効です。

ProductType

String

いいえ

いいえ

プロダクトタイプです。

有効値:

  • Local:Redis オープンソースエディションインスタンス(クラシック)またはメモリ最適化(クラシック)

  • Tair_rdb:メモリ最適化(クラウドネイティブ)

  • Tair_scm:永続メモリ

  • Tair_essd:ディスクベース

  • OnECS:Redis オープンソースエディションインスタンス(クラウドネイティブ)

説明

ProductType プロパティを設定すると、パラメーターの照会が高速化されます。

SecondaryZoneId

String

いいえ

はい

セカンダリゾーン ID です。

DescribeZones - サポートされているゾーンの照会 操作を呼び出すことができます。

説明

このパラメーターにより、プライマリおよびセカンダリのデータノードが異なるゾーンに分散され、ゾーン間ディザスタリカバリが可能になり、データセンターレベルの障害にも耐えることができます。

ResourceGroupId

String

いいえ

はい

リソースグループ ID です。

なし

PeriodUnit

String

いいえ

はい

期間の単位です。

有効値:

  • Year:年

  • Month:月

TairConfig

Map

いいえ

いいえ

Tair 構成です。

詳細については、「TairConfig プロパティ」をご参照ください。

ReadOnlyCount

Integer

いいえ

いいえ

プライマリゾーン内の読み取り専用ノードの数です。

説明

ReadOnlyCount パラメーターは、読み書き分離が有効になっているクラウドネイティブインスタンスにのみ適用されます。インスタンスがクラスタアーキテクチャを使用している場合、このパラメーターは単一シャードのプライマリおよびセカンダリゾーンにおける読み取り専用ノードの数を示します。

ShardCount

Integer

いいえ

いいえ

シャード数です。

このパラメーターは、ディスクベースのクラスタアーキテクチャインスタンスにのみ適用されます。このパラメーターを使用してシャード数をカスタマイズできます。

NodeType

String

いいえ

いいえ

ノードタイプです。

有効値:

  • MASTER_SLAVE:高可用性(HA)(二重レプリカ)

  • STAND_ALONE:単一レプリカ

  • double:二重レプリカ

  • single:単一レプリカ

説明

クラウドネイティブインスタンスの場合は、MASTER_SLAVE または STAND_ALONE を選択してください。クラシックインスタンスの場合は、double または single を選択してください。

DeletionProtection

Boolean

いいえ

はい

リリース保護が有効かどうかを示します。

有効値:

  • true:有効

  • false:無効

BackupPolicy 構文

"BackupPolicy": {
  "PreferredBackupPeriod": "String",
  "PreferredBackupTime": "String",
  "EnableBackupLog": "Integer"
}

BackupPolicy プロパティ

プロパティ名

タイプ

必須

更新可能

説明

制約事項

PreferredBackupPeriod

String

はい

はい

バックアップサイクルです。

有効値:

  • Monday:月曜日

  • Tuesday:火曜日

  • Wednesday:水曜日

  • 木曜日。

  • Friday:金曜日

  • Saturday:土曜日

  • Sunday:日曜日

PreferredBackupTime

String

はい

はい

バックアップ時間です。

形式:HH:mmZ-HH:mmZ

EnableBackupLog

Integer

いいえ

はい

増分バックアップを有効または無効にします。

有効値:

  • 1:有効化

  • 0(デフォルト):無効化

InstanceMaintainTime 構文

"InstanceMaintainTime": {
  "MaintainStartTime": "String",
  "MaintainEndTime": "String"
}

InstanceMaintainTime プロパティ

プロパティ名

タイプ

必須

更新可能

説明

制約事項

MaintainStartTime

String

いいえ

いいえ

メンテナンスウィンドウの開始時刻です。

形式:HH:mmZ(UTC)。たとえば、01:00(UTC + 08:00)に開始する場合、このパラメーターを17:00Zに設定します。

MaintainEndTime

String

いいえ

いいえ

メンテナンスウィンドウの終了時刻です。

形式:HH:mmZ(UTC)。たとえば、02:00(UTC + 08:00)に終了する場合、このパラメーターを18:00Zに設定します。

説明

開始時刻と終了時刻の間隔は 1 時間である必要があります。たとえば、MaintainStartTime が17:00Zの場合、MaintainEndTime は18:00Zになります。

Tags 構文

"Tags": [
  {
    "Key": String,
    "Value": String
  }
]  

Tags プロパティ

プロパティ名

タイプ

必須

更新可能

説明

制約事項

Key

String

はい

いいえ

タグキーです。

タグキーは、同一アカウントおよびリージョン内で一意である必要があります。

Value

String

いいえ

いいえ

タグ値です。

なし

Connections 構文

"Connections": {
  "VpcPrivateConnection": "Map",
  "ClassicInnerConnection": "Map",
  "DirectConnection": "Map",
  "PublicConnection": "Map"
}

Connections プロパティ

プロパティ名

タイプ

必須

更新可能

説明

制約事項

VpcPrivateConnection

Map

いいえ

はい

VPC のプライベートネットワークアドレス。

詳細については、「VpcPrivateConnection プロパティ」をご参照ください。

ClassicInnerConnection

Map

いいえ

はい

クラシック内部ネットワークエンドポイントです。

詳細については、「ClassicInnerConnection プロパティ」をご参照ください。

DirectConnection

Map

いいえ

はい

ダイレクト接続エンドポイントです。これはクラスターインスタンスです。必要に応じてダイレクト接続エンドポイントをリクエストしてください。

詳細については、「DirectConnection プロパティ」をご参照ください。

PublicConnection

Map

いいえ

はい

パブリックアドレス。

詳細については、「PublicConnection プロパティ」をご参照ください。

VpcPrivateConnection 構文

"VpcPrivateConnection": {
  "ConnectionPort": Integer,
  "ConnectionString": String
}

VpcPrivateConnection プロパティ

プロパティ名

タイプ

必須

更新可能

説明

制約事項

ConnectionPort

Integer

はい

はい

インスタンスの ApsaraDB サービスポートです。

有効値:1024~65535。

ConnectionString

String

はい

はい

パブリックエンドポイントのプレフィックスです。

プレフィックスは 8~64 文字で、先頭は小文字であり、小文字と数字のみを含める必要があります。

PublicConnection 構文

"PublicConnection": {
  "ConnectionPort": Integer,
  "ConnectionString": String
}

PublicConnection プロパティ

プロパティ名

タイプ

必須

更新可能

説明

制約事項

ConnectionPort

Integer

はい

はい

インスタンスの ApsaraDB サービスポートです。

有効値:1024~65535。

ConnectionString

String

はい

はい

パブリックエンドポイントのプレフィックスです。

プレフィックスは 8~64 文字で、先頭は小文字であり、小文字と数字のみを含める必要があります。

DirectConnection 構文

"DirectConnection": {
  "ConnectionPort": Integer,
  "ConnectionString": String
}

DirectConnection プロパティ

プロパティ名

タイプ

必須

更新可能

説明

制約事項

ConnectionPort

Integer

はい

はい

インスタンスの ApsaraDB サービスポートです。

有効値:1024~65535。

ConnectionString

String

はい

はい

パブリックエンドポイントのプレフィックスです。

プレフィックスは 8~64 文字で、先頭は小文字であり、小文字と数字のみを含める必要があります。

ClassicInnerConnection 構文

"ClassicInnerConnection": {
  "ConnectionPort": Integer,
  "ConnectionString": String
}

ClassicInnerConnection プロパティ

プロパティ名

タイプ

必須

更新可能

説明

制約事項

ConnectionPort

Integer

はい

はい

インスタンスの ApsaraDB サービスポートです。

有効値:1024~65535。

ConnectionString

String

はい

はい

パブリックエンドポイントのプレフィックスです。

プレフィックスは 8~64 文字で、先頭は小文字であり、小文字と数字のみを含める必要があります。

TairConfig 構文

"TairConfig": {
  "Storage": "Integer",
  "StorageType": "String",
  "ShardCount": "Integer"
}

TairConfig プロパティ

プロパティ名

タイプ

必須

更新可能

説明

制約事項

Storage

Integer

いいえ

いいえ

クラウドディスクのストレージ容量です。

ストレージ容量はインスタンスの仕様によって異なります。詳細については、「ディスクベースのインスタンス仕様」をご参照ください。

StorageType

String

いいえ

いいえ

ストレージクラスです。

有効値:

  • essd_pl0

  • essd_pl1

  • essd_pl2

  • essd_pl3

ShardCount

Integer

いいえ

いいえ

インスタンス内のデータノード数です。

有効値:

  • 1:デフォルト値。これは、作成されたインスタンスが標準アーキテクチャを使用し、データノードが 1 つだけであることを示します。

  • 232:この範囲の値を指定して、指定されたデータノード数を持つクラスタアーキテクチャインスタンスを作成します。

戻り値

Fn::GetAtt

  • InstanceId:インスタンス ID。

  • OrderId:インスタンス注文 ID。

  • ConnectionDomain:インスタンスのプライベート接続エンドポイント。

  • Port:Redis サービスポート。

  • InstanceName:インスタンス名。

  • InstanceClass:インスタンスタイプ。

  • VpcId:VPC ID。

  • Capacity:インスタンスのストレージ容量。

  • InstanceType:インスタンスのデータベースエンジンバージョン。

  • ChargeType:インスタンスの課金方法。

  • PackageType:プランタイプ。

  • Connections:インスタンスがサポートする最大接続数。

  • ArchitectureType:アーキテクチャタイプ。

  • NodeType:ノードタイプ。

  • HasRenewChangeOrder:Alibaba Cloud アカウントに保留中の更新またはスケールアウト注文があるかどうかを示します。

  • ResourceGroupId:リソースグループ ID。

  • QPS:クエリ/秒(QPS)。これは現在のインスタンスタイプの理論値です。

  • ZoneId:インスタンスが属するゾーン ID。

  • Bandwidth:インスタンスの帯域幅。単位:Mbps。

  • EngineVersion:エンジンバージョン。

  • NetworkType:ネットワークタイプ。

  • VSwitchId:vSwitch ID。

  • PrivateIp:インスタンスのプライベート IP アドレス。

  • PublicConnectionString:インスタンスのパブリック接続文字列。

  • VpcPrivateConnectionPort:VPC プライベート接続ポート。

  • ClassicInnerConnectionString:インスタンスのクラシック内部接続文字列。

  • VpcPrivateConnectionString:インスタンスの VPC プライベート接続文字列。

  • PublicConnectionPort:インスタンスのパブリック接続ポート。

  • DirectConnectionString:インスタンスのダイレクト接続文字列。

  • DirectConnectionPort:インスタンスのダイレクト接続ポート。

  • ClassicInnerConnectionPort:インスタンスのクラシック内部接続ポート。

シナリオ 1: Redis インスタンスを作成します。

クイック作成

ROSTemplateFormatVersion: '2015-09-01'
Description: {}
Parameters:
  VpcId:
    Type: String
    AssociationProperty: ALIYUN::ECS::VPC::VpcId
  ZoneId:
    Type: String
    Description:
      zh-cn: 创建实例前,请确认可用区是否支持Redis资源的规格。
      en: Before creating an instance, confirm the Availability Zone supports Redis resource specifications.
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
    Label:
      en: Zone ID
      zh-cn: 可用区
  VSwitchId:
    Type: String
    AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
    AssociationPropertyMetadata:
      VpcId: ${VpcId}
      ZoneId: ${ZoneId}
Resources:
  RedisInstance:
    Type: ALIYUN::REDIS::Instance
    Properties:
      VpcId:
        Ref: VpcId
      VSwitchId:
        Ref: VSwitchId
      InstanceClass: redis.master.small.default
      EvictionPolicy: noeviction
      ZoneId:
        Ref: ZoneId
      InstanceName: DefaultRedis
      Password: Admin@123!
Outputs:
  InstanceId:
    Value:
      Fn::GetAtt:
        - RedisInstance
        - InstanceId                     
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
  },
  "Parameters": {
    "VpcId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::VPC::VpcId"
    },
    "ZoneId": {
      "Type": "String",
      "Description": {
        "zh-cn": "创建实例前,请确认可用区是否支持Redis资源的规格。",
        "en": "Before creating an instance, confirm the Availability Zone supports Redis resource specifications."
      },
      "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId",
      "Label": {
        "en": "Zone ID",
        "zh-cn": "可用区"
      }
    },
    "VSwitchId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
      "AssociationPropertyMetadata": {
        "VpcId": "${VpcId}",
        "ZoneId": "${ZoneId}"
      }
    }
  },
  "Resources": {
    "RedisInstance": {
      "Type": "ALIYUN::REDIS::Instance",
      "Properties": {
        "VpcId": {
          "Ref": "VpcId"
        },
        "VSwitchId": {
          "Ref": "VSwitchId"
        },
        "InstanceClass": "redis.master.small.default",
        "EvictionPolicy": "noeviction",
        "ZoneId": {
          "Ref": "ZoneId"
        },
        "InstanceName": "DefaultRedis",
        "Password": "Admin@123!"
      }
    }
  },
  "Outputs": {
    "InstanceId": {
      "Value": {
        "Fn::GetAtt": [
          "RedisInstance",
          "InstanceId"
        ]
      }
    }
  }
}

シナリオ 2: Redis インスタンスを作成し、IP ホワイトリストを追加します。

クイック作成

ROSTemplateFormatVersion: '2015-09-01'
Description: {}
Parameters:
  VpcId:
    Type: String
    AssociationProperty: ALIYUN::ECS::VPC::VpcId
  ZoneId:
    Type: String
    Description:
      zh-cn: 创建实例前,请确认可用区是否支持Redis资源的规格。
      en: Before creating an instance, confirm the Availability Zone supports Redis resource specifications.
    AssociationProperty: ALIYUN::ECS::Instance:ZoneId
    Label:
      en: Zone ID
      zh-cn: 可用区
  VSwitchId:
    Type: String
    AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
    AssociationPropertyMetadata:
      VpcId: ${VpcId}
      ZoneId: ${ZoneId}
Resources:
  RedisInstance:
    Type: ALIYUN::REDIS::Instance
    Properties:
      VpcId:
        Ref: VpcId
      VSwitchId:
        Ref: VSwitchId
      InstanceClass: redis.master.small.default
      EvictionPolicy: noeviction
      ZoneId:
        Ref: ZoneId
      InstanceName: DefaultRedis
      Password: Admin@123!
  REDISWhitelist:
    Type: ALIYUN::REDIS::Whitelist
    Properties:
      InstanceId:
        Ref: RedisInstance
      SecurityIps: 192.168.0.0/16
Outputs:
  InstanceId:
    Value:
      Fn::GetAtt:
        - RedisInstance
        - InstanceId                     
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {},
  "Parameters": {
    "VpcId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::VPC::VpcId"
    },
    "ZoneId": {
      "Type": "String",
      "Description": {
        "zh-cn": "创建实例前,请确认可用区是否支持Redis资源的规格。",
        "en": "Before creating an instance, confirm the Availability Zone supports Redis resource specifications."
      },
      "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId",
      "Label": {
        "en": "Zone ID",
        "zh-cn": "可用区"
      }
    },
    "VSwitchId": {
      "Type": "String",
      "AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId",
      "AssociationPropertyMetadata": {
        "VpcId": "${VpcId}",
        "ZoneId": "${ZoneId}"
      }
    }
  },
  "Resources": {
    "RedisInstance": {
      "Type": "ALIYUN::REDIS::Instance",
      "Properties": {
        "VpcId": {
          "Ref": "VpcId"
        },
        "VSwitchId": {
          "Ref": "VSwitchId"
        },
        "InstanceClass": "redis.master.small.default",
        "EvictionPolicy": "noeviction",
        "ZoneId": {
          "Ref": "ZoneId"
        },
        "InstanceName": "DefaultRedis",
        "Password": "Admin@123!"
      }
    },
    "REDISWhitelist": {
      "Type": "ALIYUN::REDIS::Whitelist",
      "Properties": {
        "InstanceId": {
          "Ref": "RedisInstance"
        },
        "SecurityIps": "192.168.0.0/16"
      }
    }
  },
  "Outputs": {
    "InstanceId": {
      "Value": {
        "Fn::GetAtt": [
          "RedisInstance",
          "InstanceId"
        ]
      }
    }
  }
}

シナリオ 3: DTS を使用して MySQL と Redis 間でキャッシュを同期します。

クイック作成

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: 该模板通过DTS实现MySQL与Redis的缓存同步,包括VPC、ECS、RDS、Redis实例创建及安全配置,同时设置消费组确保数据一致性。
  en: This template synchronizes MySQL and Redis caches using DTS. It creates and configures security for VPC, ECS, RDS, and Redis instances. It also establishes consumer groups to ensure data consistency.
Parameters:
  ZoneId:
    Type: String
    Label:
      en: VSwitch Availability Zone
      zh-cn: 交换机可用区
    AssociationProperty: ALIYUN::ECS::Instance::ZoneId
  RDSDBUser:
    Type: String
    Label:
      en: RDS DB Username
      zh-cn: RDS数据库账号
    Description:
      en: Username of database.
      zh-cn: RDS数据库账号。
    ConstraintDescription:
      en: Must contain 2 to 16 lowercase letters and underscores. It must start with a letter and end with an alphanumeric character.
      zh-cn: 由 2 到 16 个小写字母组成,下划线。必须以字母开头,以字母数字字符结尾。
    Default: demouser123
    MinLength: 2
    MaxLength: 16
  DbName:
    Type: String
    Label:
      en: RDS DB Name
      zh-cn: RDS数据库名称
    ConstraintDescription:
      en: Must contain 2 to 16 lowercase letters and underscores. It must start with a letter and end with an alphanumeric character.
      zh-cn: 由 2 到 16 个小写字母组成,下划线。必须以字母开头,以字母数字字符结尾。
    Default: demodb
    Required: true
    MinLength: 2
    MaxLength: 16
  RDSDBPassword:
    Type: String
    Label:
      en: RDS DB Password
      zh-cn: RDS数据库密码
    Description:
      en: The RDS database password must be 8 to 32 characters long. It must contain letters, numbers, and underscores (_). It must also include three different character types.
      zh-cn: RDS数据库密码,由字母、数字、下划线(_)组成,长度为8~32个字符,必须包含3种不同类型的字符。
    ConstraintDescription:
      en: Must be 8 to 32 characters long. It must contain letters, numbers, and underscores (_).
      zh-cn: 由字母、数字、下划线(_)组成,长度为8~32个字符。
    AssociationProperty: ALIYUN::RDS::Instance::AccountPassword
    MinLength: 8
    MaxLength: 32
    NoEcho: true
  DBInstanceClass:
    Type: String
    Label:
      en: Instance Class
      zh-cn: 实例规格
    AssociationProperty: ALIYUN::RDS::Instance::InstanceType
    AssociationPropertyMetadata:
      ZoneId: ${ZoneId}
      EngineVersion: "8.0"
      Engine: MySQL
      Category: HighAvailability
      DBInstanceStorageType: cloud_essd
      CommodityCode: bards
    Default: mysql.x4.medium.2c
  DtsJobName:
    Type: String
    Label:
      en: Dts Job Name
      zh-cn: 同步任务名称
    Description:
      en: Set a name that reflects its business purpose for easy identification. Uniqueness is not required.
      zh-cn: 建议配置具有业务意义的名称(无唯一性要求),便于后续识别。
    Default: mysql2redis_dts
  RedisInstanceClass:
    Type: String
    Label:
      en: Tair Specifications
      zh-cn: Tair 规格
    Description:
      en: <font color='blue'>Before selecting a model, confirm if the model is in stock in the current availability zone. To save testing costs, use a 2 GB memory model, such as tair.rdb.2g.</font> For more information, see <a href='https://www.alibabacloud.com/help/zh/redis/product-overview/enhanced-performance' target='_blank'><font color='red'>Specification inquiry</font></a>.
      zh-cn: <font color='blue'>选择机型前请先确认当前可用区下该机型是否有库存,为节省测试成本,推荐使用2GB的规格,例如: tair.rdb.2g</font>,<a href='https://www.alibabacloud.com/help/zh/redis/product-overview/enhanced-performance' target='_blank'><font color='red'>规格查询</font></a>。
    AssociationProperty: ALIYUN::REDIS::Instance::InstanceClass
    AssociationPropertyMetadata:
      Engine: Redis
      ProductType: Tair_rdb
      InstanceChargeType: PostPaid
      ZoneId: ${ZoneId1}
      OrderType: BUY
    Default: tair.rdb.2g
  RedisPassword:
    Type: String
    Label:
      en: Instance Password
      zh-cn: 实例密码
    Description:
      en: Must be 8 to 32 characters long. It can contain uppercase and lowercase letters, numbers, and special symbols: ! @ # $ % ^ & * ( ) _ + - =
      zh-cn: 长度8-32个字符,可包含大小字母、数字及特殊符号(包含: !@#$%^&*()_+-=)
    ConstraintDescription:
      en: Must be 8 to 32 characters long. It can contain uppercase and lowercase letters, numbers, and special symbols: ! @ # $ % ^ & * ( ) _ + - =
      zh-cn: 8-32个字符,可包含大小字母、数字及特殊符号(包含: !@#$%^&*()_+-=)
    MinLength: '8'
    MaxLength: '32'
    NoEcho: true
Resources:
  Vpc:
    Type: ALIYUN::ECS::VPC
    Properties:
      CidrBlock: 192.168.0.0/16
  VSwitch:
    Type: ALIYUN::ECS::VSwitch
    Properties:
      ZoneId:
        Ref: ZoneId
      VpcId:
        Ref: Vpc
      VSwitchName:
        Fn::Join:
          - '-'
          - - VSwitch
            - StackId
            - Ref: ALIYUN::StackId
      CidrBlock: 192.168.0.0/24
  RdsDBInstance:
    Type: ALIYUN::RDS::DBInstance
    Properties:
      ZoneId:
        Ref: ZoneId
      VpcId:
        Ref: Vpc
      VSwitchId:
        Ref: VSwitch
      DBInstanceClass:
        Ref: DBInstanceClass
      DBInstanceStorage: 100
      Engine: MySQL
      EngineVersion: "8.0"
      MasterUserPassword:
        Ref: RDSDBPassword
      MasterUserType: Super
      MasterUsername:
        Ref: RDSDBUser
      DBMappings:
        - CharacterSetName: utf8mb4
          DBName:
            Ref: DbName
      Category: HighAvailability
      DBInstanceStorageType: cloud_essd
      SecurityIPList: 192.168.0.0/16
      SlaveZoneIds:
        - Ref: ZoneId
  RedisInstance:
    Type: ALIYUN::REDIS::Instance
    Properties:
      ZoneId:
        Ref: ZoneId
      VpcId:
        Ref: Vpc
      VSwitchId:
        Ref: VSwitch
      InstanceClass:
        Ref: RedisInstanceClass
      InstanceName: rds_mysql2redis_redis
      EvictionPolicy: noeviction
      EngineVersion: '6.0'
      Password:
        Ref: RedisPassword
  Whitelist:
    Type: ALIYUN::REDIS::Whitelist
    Properties:
      InstanceId:
        Ref: RedisInstance
      SecurityIps: 192.168.0.0/16
  MigrationJob:
    Type: ALIYUN::DTS::SynchronizationJob2
    Properties:
      DtsJobName:
        Ref: DtsJobName
      SourceEndpoint:
        InstanceType: RDS
        InstanceID:
          Ref: RdsDBInstance
        EngineName: MYSQL
        Region:
          Ref: ALIYUN::Region
        UserName:
          Ref: RDSDBUser
        Password:
          Ref: RDSDBPassword
      DestinationEndpoint:
        InstanceType: Redis
        InstanceID:
          Ref: RedisInstance
        EngineName: Redis
        Region:
          Ref: ALIYUN::Region
        Password:
          Ref: RedisPassword
      StructureInitialization: false
      DelayNotice: true
      ErrorNotice: true
      DelayRuleTime: 60
      DataInitialization: true
      DataSynchronization: true
      DbList:
        Fn::GetJsonValue:
          - DbList
          - Fn::Sub: '{ "DbList": { "${DbName}": {   "name": "0",   "all": true,   "customAttachedColumn": {     "__DTS_TP_TO_REDIS_KEY__": {       "name": "__DTS_TP_TO_REDIS_KEY__",       "syntacticType": "ADD",       "value": "__DB__+''.''+__TB__+''.''+pk_str_with_name_value(''.'',''.'')",       "type": "STRING",       "length": ""     },     "__DTS_TP_TO_REDIS_VALUE__": {       "name": "__DTS_TP_TO_REDIS_VALUE__",       "syntacticType": "ADD",       "value": "tp2redis_json_value()",       "type": "STRING",       "length": ""     }   } }}}'
  DtsInstance:
    Type: ALIYUN::DTS::Instance
    Properties:
      JobId:
        Fn::GetAtt:
          - MigrationJob
          - DtsJobId
      InstanceClass: small
      PayType: PostPaid
      AutoStart: true
      Type: SYNC
      SourceRegion:
        Ref: ALIYUN::Region
      DestinationRegion:
        Ref: ALIYUN::Region
      SourceEndpointEngineName: MySQL
      DestinationEndpointEngineName: Redis
Outputs:
  RdsInstanceAddress:
    Description:
      en: RDS Instance Address.
      zh-cn: RDS实例地址。
    Value:
      'Fn::Sub':
        - 'https://rds.console.alibabacloud.com/detail/${InstanceID}/basicInfo?region=${Region}'
        - InstanceID:
            Ref: RdsDBInstance
          Region:
            Ref: ALIYUN::Region
  TairInstanceAddress:
    Description:
      en: Tair Instance Address.
      zh-cn: Tair实例地址。
    Value:
      'Fn::Sub':
        - 'https://kvstore.console.alibabacloud.com/Redis/instance/${Region}/${InstanceID}'
        - InstanceID:
            Ref: RedisInstance
          Region:
            Ref: ALIYUN::Region
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - ZoneId
        Label:
          default:
            en: Infrastructure Configuration (Required)
            zh-cn: 基础资源配置(必填)
      - Parameters:
          - DBInstanceClass
          - DbName
          - RDSDBUser
          - RDSDBPassword
        Label:
          default: RDS
      - Parameters:
          - RedisInstanceClass
          - RedisPassword
        Label:
          default: Tair
      - Parameters:
          - DtsJobName
        Label:
          default: DTS
    TemplateTags:
      - acs:technical-solution:database:real-time synchronization of RDS and Redis to build cache consistency-tech_solu_21
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "该模板通过DTS实现MySQL与Redis的缓存同步,包括VPC、ECS、RDS、Redis实例创建及安全配置,同时设置消费组确保数据一致性。",
    "en": "This template synchronizes MySQL and Redis caches using DTS. It creates and configures security for VPC, ECS, RDS, and Redis instances. It also establishes consumer groups to ensure data consistency."
  },
  "Parameters": {
    "ZoneId": {
      "Type": "String",
      "Label": {
        "en": "VSwitch Availability Zone",
        "zh-cn": "交换机可用区"
      },
      "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId"
    },
    "RDSDBUser": {
      "Type": "String",
      "Label": {
        "en": "RDS DB Username",
        "zh-cn": "RDS数据库账号"
      },
      "Description": {
        "en": "Username of database.",
        "zh-cn": "RDS数据库账号。"
      },
      "ConstraintDescription": {
        "en": "Must contain 2 to 16 lowercase letters and underscores. It must start with a letter and end with an alphanumeric character.",
        "zh-cn": "由 2 到 16 个小写字母组成,下划线。必须以字母开头,以字母数字字符结尾。"
      },
      "Default": "demouser123",
      "MinLength": 2,
      "MaxLength": 16
    },
    "DbName": {
      "Type": "String",
      "Label": {
        "en": "RDS DB Name",
        "zh-cn": "RDS数据库名称"
      },
      "ConstraintDescription": {
        "en": "Must contain 2 to 16 lowercase letters and underscores. It must start with a letter and end with an alphanumeric character.",
        "zh-cn": "由 2 到 16 个小文字とアンダースコアで構成され、先頭は英字、末尾は英数字である必要があります。"
      },
      "Default": "demodb",
      "Required": true,
      "MinLength": 2,
      "MaxLength": 16
    },
    "RDSDBPassword": {
      "Type": "String",
      "Label": {
        "en": "RDS DB Password",
        "zh-cn": "RDS数据库密码"
      },
      "Description": {
        "en": "The RDS database password must be 8 to 32 characters long. It must contain letters, numbers, and underscores (_). It must also include three different character types.",
        "zh-cn": "RDSデータベースパスワードは、英字、数字、アンダースコア(_)で構成され、8~32 文字で、3 種類の異なる文字タイプを含む必要があります。"
      },
      "ConstraintDescription": {
        "en": "Must be 8 to 32 characters long. It must contain letters, numbers, and underscores (_).",
        "zh-cn": "英字、数字、アンダースコア(_)で構成され、8~32 文字である必要があります。"
      },
      "AssociationProperty": "ALIYUN::RDS::Instance::AccountPassword",
      "MinLength": 8,
      "MaxLength": 32,
      "NoEcho": true
    },
    "DBInstanceClass": {
      "Type": "String",
      "Label": {
        "en": "Instance Class",
        "zh-cn": "实例规格"
      },
      "AssociationProperty": "ALIYUN::RDS::Instance::InstanceType",
      "AssociationPropertyMetadata": {
        "ZoneId": "${ZoneId}",
        "EngineVersion": "8.0",
        "Engine": "MySQL",
        "Category": "HighAvailability",
        "DBInstanceStorageType": "cloud_essd",
        "CommodityCode": "bards"
      },
      "Default": "mysql.x4.medium.2c"
    },
    "DtsJobName": {
      "Type": "String",
      "Label": {
        "en": "Dts Job Name",
        "zh-cn": "同步任务名称"
      },
      "Description": {
        "en": "Set a name that reflects its business purpose for easy identification. Uniqueness is not required.",
        "zh-cn": "後続の識別を容易にするため、業務目的を反映した名前を設定することを推奨します(一意である必要はありません)。"
      },
      "Default": "mysql2redis_dts"
    },
    "RedisInstanceClass": {
      "Type": "String",
      "Label": {
        "en": "Tair Specifications",
        "zh-cn": "Tair 规格"
      },
      "Description": {
        "en": "<font color='blue'>Before selecting a model, confirm if the model is in stock in the current availability zone. To save testing costs, use a 2 GB memory model, such as tair.rdb.2g.</font> For more information, see <a href='https://www.alibabacloud.com/help/zh/redis/product-overview/enhanced-performance' target='_blank'><font color='red'>Specification inquiry</font></a>.",
        "zh-cn": "<font color='blue'>機種を選択する前に、現在のゾーンで在庫があるか確認してください。テストコストを節約するために、tair.rdb.2g などの 2 GB メモリモデルの使用を推奨します。</font> 詳細については、「<a href='https://www.alibabacloud.com/help/zh/redis/product-overview/enhanced-performance' target='_blank'><font color='red'>仕様の照会</font></a>」をご参照ください。"
      },
      "AssociationProperty": "ALIYUN::REDIS::Instance::InstanceClass",
      "AssociationPropertyMetadata": {
        "Engine": "Redis",
        "ProductType": "Tair_rdb",
        "InstanceChargeType": "PostPaid",
        "ZoneId": "${ZoneId1}",
        "OrderType": "BUY"
      },
      "Default": "tair.rdb.2g"
    },
    "RedisPassword": {
      "Type": "String",
      "Label": {
        "en": "Instance Password",
        "zh-cn": "实例密码"
      },
      "Description": {
        "en": "Must be 8 to 32 characters long. It can contain uppercase and lowercase letters, numbers, and special symbols: ! @ # $ % ^ & * ( ) _ + - =",
        "zh-cn": "8~32 文字で、大文字、小文字、数字、特殊記号(!@#$%^&*()_+-= を含む)を含めることができます。"
      },
      "ConstraintDescription": {
        "en": "Must be 8 to 32 characters long. It can contain uppercase and lowercase letters, numbers, and special symbols: ! @ # $ % ^ & * ( ) _ + - =",
        "zh-cn": "8~32 文字で、大文字、小文字、数字、特殊記号(!@#$%^&*()_+-= を含む)を含めることができます。"
      },
      "MinLength": "8",
      "MaxLength": "32",
      "NoEcho": true
    }
  },
  "Resources": {
    "Vpc": {
      "Type": "ALIYUN::ECS::VPC",
      "Properties": {
        "CidrBlock": "192.168.0.0/16"
      }
    },
    "VSwitch": {
      "Type": "ALIYUN::ECS::VSwitch",
      "Properties": {
        "ZoneId": {
          "Ref": "ZoneId"
        },
        "VpcId": {
          "Ref": "Vpc"
        },
        "VSwitchName": {
          "Fn::Join": [
            "-",
            [
              "VSwitch",
              "StackId",
              {
                "Ref": "ALIYUN::StackId"
              }
            ]
          ]
        },
        "CidrBlock": "192.168.0.0/24"
      }
    },
    "RdsDBInstance": {
      "Type": "ALIYUN::RDS::DBInstance",
      "Properties": {
        "ZoneId": {
          "Ref": "ZoneId"
        },
        "VpcId": {
          "Ref": "Vpc"
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "DBInstanceClass": {
          "Ref": "DBInstanceClass"
        },
        "DBInstanceStorage": 100,
        "Engine": "MySQL",
        "EngineVersion": "8.0",
        "MasterUserPassword": {
          "Ref": "RDSDBPassword"
        },
        "MasterUserType": "Super",
        "MasterUsername": {
          "Ref": "RDSDBUser"
        },
        "DBMappings": [
          {
            "CharacterSetName": "utf8mb4",
            "DBName": {
              "Ref": "DbName"
            }
          }
        ],
        "Category": "HighAvailability",
        "DBInstanceStorageType": "cloud_essd",
        "SecurityIPList": "192.168.0.0/16",
        "SlaveZoneIds": [
          {
            "Ref": "ZoneId"
          }
        ]
      }
    },
    "RedisInstance": {
      "Type": "ALIYUN::REDIS::Instance",
      "Properties": {
        "ZoneId": {
          "Ref": "ZoneId"
        },
        "VpcId": {
          "Ref": "Vpc"
        },
        "VSwitchId": {
          "Ref": "VSwitch"
        },
        "InstanceClass": {
          "Ref": "RedisInstanceClass"
        },
        "InstanceName": "rds_mysql2redis_redis",
        "EvictionPolicy": "noeviction",
        "EngineVersion": "6.0",
        "Password": {
          "Ref": "RedisPassword"
        }
      }
    },
    "Whitelist": {
      "Type": "ALIYUN::REDIS::Whitelist",
      "Properties": {
        "InstanceId": {
          "Ref": "RedisInstance"
        },
        "SecurityIps": "192.168.0.0/16"
      }
    },
    "MigrationJob": {
      "Type": "ALIYUN::DTS::SynchronizationJob2",
      "Properties": {
        "DtsJobName": {
          "Ref": "DtsJobName"
        },
        "SourceEndpoint": {
          "InstanceType": "RDS",
          "InstanceID": {
            "Ref": "RdsDBInstance"
          },
          "EngineName": "MYSQL",
          "Region": {
            "Ref": "ALIYUN::Region"
          },
          "UserName": {
            "Ref": "RDSDBUser"
          },
          "Password": {
            "Ref": "RDSDBPassword"
          }
        },
        "DestinationEndpoint": {
          "InstanceType": "Redis",
          "InstanceID": {
            "Ref": "RedisInstance"
          },
          "EngineName": "Redis",
          "Region": {
            "Ref": "ALIYUN::Region"
          },
          "Password": {
            "Ref": "RedisPassword"
          }
        },
        "StructureInitialization": false,
        "DelayNotice": true,
        "ErrorNotice": true,
        "DelayRuleTime": 60,
        "DataInitialization": true,
        "DataSynchronization": true,
        "DbList": {
          "Fn::GetJsonValue": [
            "DbList",
            {
              "Fn::Sub": "{ \"DbList\": { \"${DbName}\": {   \"name\": \"0\",   \"all\": true,   \"customAttachedColumn\": {     \"__DTS_TP_TO_REDIS_KEY__\": {       \"name\": \"__DTS_TP_TO_REDIS_KEY__\",       \"syntacticType\": \"ADD\",       \"value\": \"__DB__+'.'+__TB__+'.'+pk_str_with_name_value('.','.')\",       \"type\": \"STRING\",       \"length\": \"\"     },     \"__DTS_TP_TO_REDIS_VALUE__\": {       \"name\": \"__DTS_TP_TO_REDIS_VALUE__\",       \"syntacticType\": \"ADD\",       \"value\": \"tp2redis_json_value()\",       \"type\": \"STRING\",       \"length\": \"\"     }   } }}}"
            }
          ]
        }
      }
    },
    "DtsInstance": {
      "Type": "ALIYUN::DTS::Instance",
      "Properties": {
        "JobId": {
          "Fn::GetAtt": [
            "MigrationJob",
            "DtsJobId"
          ]
        },
        "InstanceClass": "small",
        "PayType": "PostPaid",
        "AutoStart": true,
        "Type": "SYNC",
        "SourceRegion": {
          "Ref": "ALIYUN::Region"
        },
        "DestinationRegion": {
          "Ref": "ALIYUN::Region"
        },
        "SourceEndpointEngineName": "MySQL",
        "DestinationEndpointEngineName": "Redis"
      }
    }
  },
  "Outputs": {
    "RdsInstanceAddress": {
      "Description": {
        "en": "RDS Instance Address.",
        "zh-cn": "RDS实例地址。"
      },
      "Value": {
        "Fn::Sub": [
          "https://rds.console.alibabacloud.com/detail/${InstanceID}/basicInfo?region=${Region}",
          {
            "InstanceID": {
              "Ref": "RdsDBInstance"
            },
            "Region": {
              "Ref": "ALIYUN::Region"
            }
          }
        ]
      }
    },
    "TairInstanceAddress": {
      "Description": {
        "en": "Tair Instance Address.",
        "zh-cn": "Tair实例地址。"
      },
      "Value": {
        "Fn::Sub": [
          "https://kvstore.console.alibabacloud.com/Redis/instance/${Region}/${InstanceID}",
          {
            "InstanceID": {
              "Ref": "RedisInstance"
            },
            "Region": {
              "Ref": "ALIYUN::Region"
            }
          }
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "ZoneId"
          ],
          "Label": {
            "default": {
              "en": "Infrastructure Configuration (Required)",
              "zh-cn": "基础资源配置(必填)"
            }
          }
        },
        {
          "Parameters": [
            "DBInstanceClass",
            "DbName",
            "RDSDBUser",
            "RDSDBPassword"
          ],
          "Label": {
            "default": "RDS"
          }
        },
        {
          "Parameters": [
            "RedisInstanceClass",
            "RedisPassword"
          ],
          "Label": {
            "default": "Tair"
          }
        },
        {
          "Parameters": [
            "DtsJobName"
          ],
          "Label": {
            "default": "DTS"
          }
        }
      ],
      "TemplateTags": [
        "acs:technical-solution:database:real-time synchronization of RDS and Redis to build cache consistency-tech_solu_21"
      ]
    }
  }
}

その他の例については、「このリソースを含む公開テンプレート」をご参照ください。