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

Resource Orchestration Service:ALIYUN::ROS::Sleep

最終更新日:Jan 16, 2025

ALIYUN::ROS::Sleep は、その他のリソースの作成、削除、更新、およびロールバックを遅延させるために使用されます。

構文

{
  "Type": "ALIYUN::ROS::Sleep",
  "Properties": {
    "DeleteDuration": Number,
    "UpdateRollbackDuration": Number,
    "UpdateDuration": Number,
    "CreateDuration": Number,
    "Triggers": Map
  }
}

プロパティ

プロパティタイプ必須編集可能説明制約
DeleteDurationNumberいいえはいリソースが削除されるまで待機する時間。有効な値: 0 ~ 1800。

単位:秒。

UpdateRollbackDurationNumberいいえはいリソースの更新がロールバックされるまで待機する時間。このプロパティは、スタックがロールバック中で、Triggers プロパティの値が変更された場合にのみ有効になります。

有効な値: 0 ~ 1800。

単位:秒。
UpdateDurationNumberいいえはいリソースが更新されるまで待機する時間。このプロパティは、スタックが更新中で、Triggers プロパティの値が変更された場合にのみ有効になります。

有効な値: 0 ~ 1800。

単位:秒。
CreateDurationNumberいいえいいえリソースが作成されるまで待機する時間。有効な値: 0 ~ 1800。

単位:秒。

TriggersMapいいえはいリソースの更新の待機とリソースの更新のロールバックの待機をトリガーするトリガー。UpdateDuration または UpdateRollbackDuration プロパティは、スタックが更新またはロールバック中で、Triggers プロパティの値が変更された場合にのみ有効になります。

レスポンスパラメータ

Fn::GetAtt

該当なし

この例では、次のリソースが定義されています。

  • VPC:仮想プライベートクラウド ( VPC )
  • VSwitch: vSwitch
  • SecurityGroup:セキュリティグループ
  • Sleep:カスタム遅延時間
  • CenterServer および OtherServer: 2 つの弾性計算サービス ( ECS ) インスタンス

次のコンテンツでは、VPC に作成される 2 つの ECS インスタンスについて説明します。

  • CenterServer インスタンスにはカスタムスクリプトが含まれています。CenterServer インスタンス上の公開鍵を OtherServer インスタンスに送信するために、NGINX サービスをデプロイする必要があります。これにより、CenterServer インスタンスはパスワードなしで OtherServer インスタンスに接続できます。OtherServer インスタンスは、OtherServer インスタンス上のスクリプトに基づいて CenterServer インスタンス上のサービスにアクセスできます。
  • CenterServer インスタンスにはカスタムスクリプトが含まれています。CenterServer インスタンス上の公開鍵を OtherServer インスタンスに送信するために、NGINX サービスをデプロイする必要があります。これにより、CenterServer インスタンスはパスワードなしで OtherServer インスタンスに接続できます。OtherServer インスタンスは、OtherServer インスタンス上のスクリプトに基づいて CenterServer インスタンス上のサービスにアクセスできます。
    説明 CenterServer インスタンスの作成後、CenterServer インスタンスにアプリケーションがインストールされて起動されるまで時間がかかるため、待機時間を指定する必要があります。
  • YAML 形式

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      ZoneId:
        Type: String
        Label: Availability Zone
        AssociationProperty: ALIYUN::ECS::Instance::ZoneId
        Description: VSwitch available Zone Id,  // 利用可能な VSwitch のゾーン ID
      CreateDuration:
        Type: Number
        Description: The number of seconds to wait before resource creation. // リソース作成前に待機する秒数。
        MinValue: 0
        MaxValue: 1800
        Default: 60
      InstanceType:
        Type: String
        AssociationProperty: ALIYUN::ECS::Instance::InstanceType
        Label:
          en: Instance Type
        Description: Fill in specifications that can be used under the VSwitch availability zone. // VSwitch アベイラビリティーゾーンで使用できる仕様を入力します。
        AssociationPropertyMetadata:
          ZoneId: ${ZoneId}
      SystemDiskCategory:
        Type: String
        AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
        AssociationPropertyMetadata:
          ZoneId: ${ZoneId}
          InstanceType: ${InstanceType}
        Label: System Disk Category
      InstancePassword:
        NoEcho: true
        Type: String
        Description: Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers. // サーバーログインパスワード。長さは 8 ~ 30 文字で、大文字、小文字、数字の 3 つを含める必要があります。
        Label: Instance Password
        MinLength: 8
        MaxLength: 30
    Resources:
      VPC:
        Type: ALIYUN::ECS::VPC
        Properties:
          CidrBlock: 10.0.0.0/16
      VSwitch:
        Type: ALIYUN::ECS::VSwitch
        Properties:
          VpcId:
            Ref: VPC
          ZoneId:
            Ref: ZoneId
          CidrBlock: 10.0.1.0/24
      SecurityGroup:
        Type: ALIYUN::ECS::SecurityGroup
        Properties:
          VpcId:
            Ref: VPC
          SecurityGroupIngress:
            - Priority: 1
              PortRange: 80/80
              NicType: intranet
              SourceCidrIp: 0.0.0.0/0
              IpProtocol: tcp
            - Priority: 1
              PortRange: 22/22
              NicType: intranet
              SourceCidrIp: 100.104.0.0/16
              IpProtocol: tcp
      WaitConditionHandle:
        Type: ALIYUN::ROS::WaitConditionHandle
      CenterServer:
        Type: ALIYUN::ECS::InstanceGroup
        Properties:
          InstanceName: ControlServer
          ImageId: centos_7.9
          VpcId:
            Ref: VPC
          SecurityGroupId:
            Ref: SecurityGroup
          VSwitchId:
            Ref: VSwitch
          InstanceType:
            Ref: InstanceType
          Password:
            Ref: InstancePassword
          MaxAmount: 1
          AllocatePublicIP: false
          SystemDiskSize: '40'
          InstanceChargeType: PostPaid
          SystemDiskCategory:
            Ref: SystemDiskCategory
          UserData:
            Fn::Replace:
              - ros-notify:
                  Fn::GetAtt:
                    - WaitConditionHandle
                    - CurlCli
              - Fn::Join:
                  - |+
    
                  - - '#!/bin/sh'
                    - ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
                    - cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
                    - chmod 0600 ~/.ssh/authorized_keys
                    - pub_key=`cat /root/.ssh/id_rsa.pub`
                    - 'ros-notify -d "{\"status\" : \"SUCCESS\",\"id\" : \"ssh_pub_key\", \"data\" : \"$pub_key\"}" ' // ros-notify で公開鍵を送信
                    - yum install -y nginx
                    - mkdir -p /data/nginx
                    - echo "Hello World! This is service client ecs." > /data/nginx/index.html
                    - 'echo ''server {'' >> /etc/nginx/conf.d/server.conf '
                    - 'echo ''listen 80;'' >> /etc/nginx/conf.d/server.conf '
                    - 'echo ''server_name _;'' >> /etc/nginx/conf.d/server.conf '
                    - 'echo ''index index.html;'' >> /etc/nginx/conf.d/server.conf '
                    - 'echo ''root /data/nginx;'' >> /etc/nginx/conf.d/server.conf '
                    - 'echo ''}'' >> /etc/nginx/conf.d/server.conf '
                    - systemctl stop nginx
                    - systemctl start nginx
                    - systemctl enable nginx
      WaitCondition:
        Type: ALIYUN::ROS::WaitCondition
        Properties:
          Count: 1
          Handle:
            Ref: WaitConditionHandle
          Timeout: 1800
      Sleep:
        Type: ALIYUN::ROS::Sleep
        DependsOn: WaitCondition
        Properties:
          CreateDuration:
            Ref: CreateDuration
      OtherServer:
        Type: ALIYUN::ECS::InstanceGroup
        DependsOn: Sleep
        Properties:
          InstanceName: OtherServer
          ImageId: centos_7.9
          VpcId:
            Ref: VPC
          SecurityGroupId:
            Ref: SecurityGroup
          VSwitchId:
            Ref: VSwitch
          InstanceType:
            Ref: InstanceType
          Password:
            Ref: InstancePassword
          MaxAmount: 1
          AllocatePublicIP: false
          SystemDiskSize: 40
          InstanceChargeType: PostPaid
          SystemDiskCategory:
            Ref: SystemDiskCategory
          UserData:
            Fn::Join:
              - ''
              - - |
                  #!/bin/sh
                - ssh_pub_key='
                - Fn::GetAtt:
                    - WaitCondition
                    - Data
                - |
                  '
                - |
                  yum install -y jq
                - |
                  pub_key=`echo "$ssh_pub_key" | jq '.ssh_pub_key' | xargs echo `
                - |
                  echo "$pub_key" > /root/.ssh/authorized_keys // 公開鍵を authorized_keys に追加
                - |
                  chmod 600 /root/.ssh/authorized_keys
                - 'curl '
                - Fn::Select:
                    - '0'
                    - Fn::GetAtt:
                        - CenterServer
                        - PrivateIps
                - |
                  :80
  • JSON 形式

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "ZoneId": {
          "Type": "String",
          "Label": "Availability Zone",
          "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
          "Description": "VSwitch available Zone Id," // 利用可能な VSwitch のゾーン ID
        },
        "CreateDuration": {
          "Type": "Number",
          "Description": "The number of seconds to wait before resource creation.", // リソース作成前に待機する秒数
          "MinValue": 0,
          "MaxValue": 1800,
          "Default": 60
        },
        "InstanceType": {
          "Type": "String",
          "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
          "Label": {
            "en": "Instance Type"
          },
          "Description": "Fill in specifications that can be used under the VSwitch availability zone.", // VSwitch アベイラビリティーゾーンで使用できる仕様を入力します。
          "AssociationPropertyMetadata": {
            "ZoneId": "${ZoneId}"
          }
        },
        "SystemDiskCategory": {
          "Type": "String",
          "AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
          "AssociationPropertyMetadata": {
            "ZoneId": "${ZoneId}",
            "InstanceType": "${InstanceType}"
          },
          "Label": "System Disk Category"
        },
        "InstancePassword": {
          "NoEcho": true,
          "Type": "String",
          "Description": "Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers.", // サーバーログインパスワード、長さは 8 ~ 30 文字、大文字、小文字、数字の 3 つを含める必要があります。
          "Label": "Instance Password",
          "MinLength": 8,
          "MaxLength": 30
        }
      },
      "Resources": {
        "VPC": {
          "Type": "ALIYUN::ECS::VPC",
          "Properties": {
            "CidrBlock": "10.0.0.0/16"
          }
        },
        "VSwitch": {
          "Type": "ALIYUN::ECS::VSwitch",
          "Properties": {
            "VpcId": {
              "Ref": "VPC"
            },
            "ZoneId": {
              "Ref": "ZoneId"
            },
            "CidrBlock": "10.0.1.0/24"
          }
        },
        "SecurityGroup": {
          "Type": "ALIYUN::ECS::SecurityGroup",
          "Properties": {
            "VpcId": {
              "Ref": "VPC"
            },
            "SecurityGroupIngress": [
              {
                "Priority": 1,
                "PortRange": "80/80",
                "NicType": "intranet",
                "SourceCidrIp": "0.0.0.0/0",
                "IpProtocol": "tcp"
              },
              {
                "Priority": 1,
                "PortRange": "22/22",
                "NicType": "intranet",
                "SourceCidrIp": "100.104.0.0/16",
                "IpProtocol": "tcp"
              }
            ]
          }
        },
        "WaitConditionHandle": {
          "Type": "ALIYUN::ROS::WaitConditionHandle"
        },
        "CenterServer": {
          "Type": "ALIYUN::ECS::InstanceGroup",
          "Properties": {
            "InstanceName": "ControlServer",
            "ImageId": "centos_7.9",
            "VpcId": {
              "Ref": "VPC"
            },
            "SecurityGroupId": {
              "Ref": "SecurityGroup"
            },
            "VSwitchId": {
              "Ref": "VSwitch"
            },
            "InstanceType": {
              "Ref": "InstanceType"
            },
            "Password": {
              "Ref": "InstancePassword"
            },
            "MaxAmount": 1,
            "AllocatePublicIP": false,
            "SystemDiskSize": "40",
            "InstanceChargeType": "PostPaid",
            "SystemDiskCategory": {
              "Ref": "SystemDiskCategory"
            },
            "UserData": {
              "Fn::Replace": [
                {
                  "ros-notify": {
                    "Fn::GetAtt": [
                      "WaitConditionHandle",
                      "CurlCli"
                    ]
                  }
                },
                {
                  "Fn::Join": [
                    "\n",
                    [
                      "#!/bin/sh",
                      "ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa",
                      "cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys",
                      "chmod 0600 ~/.ssh/authorized_keys",
                      "pub_key=`cat /root/.ssh/id_rsa.pub`",
                      "ros-notify -d \"{\\\"status\\\" : \\\"SUCCESS\\\",\\\"id\\\" : \\\"ssh_pub_key\\\", \\\"data\\\" : \\\"$pub_key\\\"}\" ", // ros-notify で公開鍵を送信
                      "yum install -y nginx",
                      "mkdir -p /data/nginx",
                      "echo \"Hello World! This is service client ecs.\" > /data/nginx/index.html",
                      "echo 'server {' >> /etc/nginx/conf.d/server.conf ",
                      "echo 'listen 80;' >> /etc/nginx/conf.d/server.conf ",
                      "echo 'server_name _;' >> /etc/nginx/conf.d/server.conf ",
                      "echo 'index index.html;' >> /etc/nginx/conf.d/server.conf ",
                      "echo 'root /data/nginx;' >> /etc/nginx/conf.d/server.conf ",
                      "echo '}' >> /etc/nginx/conf.d/server.conf ",
                      "systemctl stop nginx",
                      "systemctl start nginx",
                      "systemctl enable nginx"
                    ]
                  ]
                }
              ]
            }
          }
        },
        "WaitCondition": {
          "Type": "ALIYUN::ROS::WaitCondition",
          "Properties": {
            "Count": 1,
            "Handle": {
              "Ref": "WaitConditionHandle"
            },
            "Timeout": 1800
          }
        },
        "Sleep": {
          "Type": "ALIYUN::ROS::Sleep",
          "DependsOn": "WaitCondition",
          "Properties": {
            "CreateDuration": {
              "Ref": "CreateDuration"
            }
          }
        },
        "OtherServer": {
          "Type": "ALIYUN::ECS::InstanceGroup",
          "DependsOn": "Sleep",
          "Properties": {
            "InstanceName": "OtherServer",
            "ImageId": "centos_7.9",
            "VpcId": {
              "Ref": "VPC"
            },
            "SecurityGroupId": {
              "Ref": "SecurityGroup"
            },
            "VSwitchId": {
              "Ref": "VSwitch"
            },
            "InstanceType": {
              "Ref": "InstanceType"
            },
            "Password": {
              "Ref": "InstancePassword"
            },
            "MaxAmount": 1,
            "AllocatePublicIP": false,
            "SystemDiskSize": 40,
            "InstanceChargeType": "PostPaid",
            "SystemDiskCategory": {
              "Ref": "SystemDiskCategory"
            },
            "UserData": {
              "Fn::Join": [
                "",
                [
                  "#!/bin/sh\n",
                  "ssh_pub_key='",
                  {
                    "Fn::GetAtt": [
                      "WaitCondition",
                      "Data"
                    ]
                  },
                  "'\n",
                  "yum install -y jq\n",
                  "pub_key=`echo \"$ssh_pub_key\" | jq '.ssh_pub_key' | xargs echo `\n",
                  "echo \"$pub_key\" > /root/.ssh/authorized_keys\n", // 公開鍵を authorized_keys に追加
                  "chmod 600 /root/.ssh/authorized_keys\n",
                  "curl ",
                  {
                    "Fn::Select": [
                      "0",
                      {
                        "Fn::GetAtt": [
                          "CenterServer",
                          "PrivateIps"
                        ]
                      }
                    ]
                  },
                  ":80\n"
                ]
              ]
            }
          }
        }
      }
    }