All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::ROS::Sleep

Last Updated:Jun 11, 2026

ALIYUN::ROS::Sleep menunda operasi pembuatan, penghapusan, pembaruan, dan rollback resource.

Sintaksis

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

Properti

Nama Properti Tipe Wajib Boleh diperbarui Deskripsi Batasan
DeleteDuration Number Tidak Ya Durasi tunggu sebelum penghapusan resource. Nilai valid: 0 hingga 1800.

Unit: detik.

UpdateRollbackDuration Number Tidak Ya Durasi tunggu sebelum rollback selama pembaruan. Hanya berlaku saat stack melakukan rollback dan Triggers berubah.

Nilai valid: 0 hingga 1800.

Unit: detik.
UpdateDuration Number Tidak Ya Durasi tunggu sebelum pembaruan resource. Hanya berlaku saat stack diperbarui dan Triggers berubah.

Nilai valid: 0 hingga 1800.

Unit: detik.
CreateDuration Number Tidak Tidak Durasi tunggu sebelum pembuatan resource. Nilai valid: 0 hingga 1800.

Unit: detik.

Triggers Map Tidak Ya Memicu perilaku tunggu saat pembaruan dan rollback. UpdateDuration dan UpdateRollbackDuration hanya berlaku saat parameter ini berubah.

Nilai kembalian

Fn::GetAtt

Tidak ada.

Contoh

Contoh ini mendefinisikan resource berikut:

  • Sebuah virtual private cloud (VPC)
  • Sebuah vSwitch
  • Sebuah security group
  • Sebuah penundaan kustom (Sleep)
  • Dua instans ECS (CenterServer dan OtherServer)

Contoh ini membuat instans ECS dalam sebuah VPC:

  • CenterServer menginstal Nginx dan mengirim kunci publiknya ke OtherServer untuk SSH tanpa kata sandi. OtherServer kemudian mengakses layanan Nginx di CenterServer.
  • CreateDuration diatur ke 60 detik agar CenterServer selesai melakukan deployment sebelum OtherServer mencoba mengaksesnya.
    Catatan Pembuatan instans selesai sebelum instalasi aplikasi rampung. Penundaan ini mengakomodasi jeda startup tersebut.
  • YAML format

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      ZoneId:
        Type: String
        Label: Availability Zone
        AssociationProperty: ALIYUN::ECS::Instance::ZoneId
        Description: ID zona ketersediaan untuk vSwitch,
      CreateDuration:
        Type: Number
        Description: Jumlah detik untuk menunggu sebelum pembuatan resource.
        MinValue: 0
        MaxValue: 1800
        Default: 60
      InstanceType:
        Type: String
        AssociationProperty: ALIYUN::ECS::Instance::InstanceType
        Label:
          en: Instance Type
          zh-cn: Instance Type
        Description: Isi spesifikasi yang dapat digunakan di bawah zona ketersediaan 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: Password login server, panjang 8-30 karakter, harus mengandung tiga jenis karakter (huruf kapital, huruf kecil, angka).
        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\"}" '
                    - 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
                - |
                  chmod 600 /root/.ssh/authorized_keys
                - 'curl '
                - Fn::Select:
                    - '0'
                    - Fn::GetAtt:
                        - CenterServer
                        - PrivateIps
                - |
                  :80
  • JSON format

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "ZoneId": {
          "Type": "String",
          "Label": "Availability Zone",
          "AssociationProperty": "ALIYUN::ECS::Instance::ZoneId",
          "Description": "ID zona ketersediaan untuk vSwitch."
        },
        "CreateDuration": {
          "Type": "Number",
          "Description": "Jumlah detik untuk menunggu sebelum pembuatan resource.",
          "MinValue": 0,
          "MaxValue": 1800,
          "Default": 60
        },
        "InstanceType": {
          "Type": "String",
          "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
          "Label": {
            "en": "Instance Type",
            "zh-cn": "Instance Type"
          },
          "Description": "Tipe instans. Tipe instans harus tersedia di zona ketersediaan vSwitch yang ditentukan.",
          "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": "Password login untuk instans. Password harus terdiri dari 8 hingga 30 karakter dan mengandung huruf kapital, huruf kecil, serta angka.",
          "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\\\"}\" ",
                      "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",
                  "chmod 600 /root/.ssh/authorized_keys\n",
                  "curl ",
                  {
                    "Fn::Select": [
                      "0",
                      {
                        "Fn::GetAtt": [
                          "CenterServer",
                          "PrivateIps"
                        ]
                      }
                    ]
                  },
                  ":80\n"
                ]
              ]
            }
          }
        }
      }
    }