全部产品
Search
文档中心

资源编排:ALIYUN::ECS::Activation

更新时间:Sep 01, 2023

ALIYUN::ECS::Activation类型用于创建一个激活码。

说明

该激活码用于将非阿里云服务器注册为阿里云托管实例。

语法

{
  "Type": "ALIYUN::ECS::Activation",
  "Properties": {
    "InstanceName": String,
    "InstanceCount": Integer,
    "Description": String,
    "TimeToLiveInHours": Integer,
    "IpAddressRange": String,
    "Tags": List
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

InstanceName

String

默认的实例名称前缀。

支持2~50个字符,且必须以字母开头,不能以特殊字符及数字开头, 只可包含特殊字符中的半角句号(.)、下划线(_)、短划线(-)和半角冒号(:),不可以使用http://https://开头。

使用该接口创建的激活码注册的实例,将使用该名称作为前辍,生成有序的实例名。您也可以在注册托管实例时,指定新的实例名称以覆盖此默认值。

注册托管实例时,如果指定了InstanceName的值,则会生成名称<InstanceName>-001,其中编号001数字的位数取决于InstanceCount数值的位数。如果未指定InstanceName的值,则会使用主机的主机名(Hostname)作为实例的名称。

InstanceCount

Integer

激活码用于注册托管实例的使用次数上限。

取值范围为1~1000。

默认值为10。

Description

String

激活码对应的描述。

支持1~100个字符。

TimeToLiveInHours

Integer

激活码的有效使用时间。

过期后将不能用于注册新的实例。单位:小时。取值范围为1~876576,即1小时~100年。

默认值为4小时。

IpAddressRange

String

允许使用该激活码的主机IP。

取值为对应的IPv4地址、IPv6地址或CIDR地址段。

Tags

List

标签列表。

标签数量范围为1~20。更多信息,请参见Tags属性

Tags语法

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

Tags属性

属性名称

类型

必须

允许更新

描述

约束

Value

String

托管实例激活码的标签值。

该值可以为空字符串。

Key

String

托管实例激活码的标签键。

一旦传入该值,则不允许为空字符串

返回值

Fn::GetAtt

  • DeregisteredCount:已注销的实例数。 

  • ActivationId:激活码ID。

  • RegisteredCount:已注册实例的数量。

  • ActivationCode:激活码的代码。

示例

  • YAML格式

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      Description:
        Description:
          en: The description of the activation code. It must be 1 to 100 characters in
            length.
        MaxLength: 100
        MinLength: 1
        Type: String
      InstanceCount:
        Description:
          en: 'The maximum number of times that you can use the activation code to register
            managed instances. Valid values: 1 to 1000.Default value: 10.'
        MaxValue: 1000
        MinValue: 1
        Type: Number
      InstanceName:
        Description:
          en: 'The default instance name prefix. The instance name prefix must be 2 to
            50 characters in length. It must start with a letter and cannot start with
            http:// or https://. It can contain letters, digits, periods (.), underscores
            (_), hyphens (-), and colons (:). If you use the activation code that is created
            by calling this operation (CreateActivation) to register managed instances,
            the instances are assigned sequential names that are prefixed by the value
            of this parameter. You can also specify a new instance name to replace the
            assigned sequential name when you register a managed instance.If you specify
            InstanceName when you register a managed instance, an instance name in theformat
            of - is generated. The number of digits in the 
            value isdetermined by that in the InstanceCount value. Example: 001. If you
            do not specify InstanceName, the hostname (Hostname) is used as the instance
            name.'
        Type: String
      IpAddressRange:
        Description:
          en: The IP addresses of hosts that are allowed to use the activation code. The
            value can be IPv4 addresses, IPv6 addresses, or CIDR blocks.
        Type: String
      RegionId:
        Description:
          en: Region ID of instance. Default is current region.
        Type: String
      Tags:
        AssociationProperty: List[Parameter]
        AssociationPropertyMetadata:
          Parameter:
            AssociationPropertyMetadata:
              Parameters:
                Key:
                  Type: String
                Value:
                  Type: String
            Type: Json
        Description:
          en: Tags to attach to instance. Max support 20 tags to add during create instance.
            Each tag with two properties Key and Value, and Key is required.
        MaxLength: 20
        Type: Json
      TimeToLiveInHours:
        Description:
          en: 'The validity period of the activation code. The activation code can no
            longer be used to register instances after the period ends. Unit: hours. Valid
            values: 1 to 876576, which represents a range of time from 1 hour to 100 years.Default
            value: 4.'
        MaxValue: 876576
        MinValue: 1
        Type: Number
    Resources:
      Activation:
        Properties:
          Description:
            Ref: Description
          InstanceCount:
            Ref: InstanceCount
          InstanceName:
            Ref: InstanceName
          IpAddressRange:
            Ref: IpAddressRange
          RegionId:
            Ref: RegionId
          Tags:
            Ref: Tags
          TimeToLiveInHours:
            Ref: TimeToLiveInHours
        Type: ALIYUN::ECS::Activation
    Outputs:
      ActivationCode:
        Description: Activation code.
        Value:
          Fn::GetAtt:
          - Activation
          - ActivationCode
      ActivationId:
        Description: Activation code ID.
        Value:
          Fn::GetAtt:
          - Activation
          - ActivationId
      DeregisteredCount:
        Description: The number of instances that have been logged out.
        Value:
          Fn::GetAtt:
          - Activation
          - DeregisteredCount
      RegisteredCount:
        Description: The number of registered instances.
        Value:
          Fn::GetAtt:
          - Activation
          - RegisteredCount
                            
  • JSON格式

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "InstanceName": {
          "Type": "String",
          "Description": {
            "en": "The default instance name prefix. The instance name prefix must be 2 to 50 characters in length. It must start with a letter and cannot start with http:// or https://. It can contain letters, digits, periods (.), underscores (_), hyphens (-), and colons (:). If you use the activation code that is created by calling this operation (CreateActivation) to register managed instances, the instances are assigned sequential names that are prefixed by the value of this parameter. You can also specify a new instance name to replace the assigned sequential name when you register a managed instance.If you specify InstanceName when you register a managed instance, an instance name in theformat of - is generated. The number of digits in the  value isdetermined by that in the InstanceCount value. Example: 001. If you do not specify InstanceName, the hostname (Hostname) is used as the instance name."
          }
        },
        "InstanceCount": {
          "Type": "Number",
          "Description": {
            "en": "The maximum number of times that you can use the activation code to register managed instances. Valid values: 1 to 1000.Default value: 10."
          },
          "MinValue": 1,
          "MaxValue": 1000
        },
        "Description": {
          "Type": "String",
          "Description": {
            "en": "The description of the activation code. It must be 1 to 100 characters in length."
          },
          "MinLength": 1,
          "MaxLength": 100
        },
        "TimeToLiveInHours": {
          "Type": "Number",
          "Description": {
            "en": "The validity period of the activation code. The activation code can no longer be used to register instances after the period ends. Unit: hours. Valid values: 1 to 876576, which represents a range of time from 1 hour to 100 years.Default value: 4."
          },
          "MinValue": 1,
          "MaxValue": 876576
        },
        "RegionId": {
          "Type": "String",
          "Description": {
            "en": "Region ID of instance. Default is current region."
          }
        },
        "IpAddressRange": {
          "Type": "String",
          "Description": {
            "en": "The IP addresses of hosts that are allowed to use the activation code. The value can be IPv4 addresses, IPv6 addresses, or CIDR blocks."
          }
        },
        "Tags": {
          "AssociationPropertyMetadata": {
            "Parameter": {
              "AssociationPropertyMetadata": {
                "Parameters": {
                  "Value": {
                    "Type": "String"
                  },
                  "Key": {
                    "Type": "String"
                  }
                }
              },
              "Type": "Json"
            }
          },
          "AssociationProperty": "List[Parameter]",
          "Type": "Json",
          "Description": {
            "en": "Tags to attach to instance. Max support 20 tags to add during create instance. Each tag with two properties Key and Value, and Key is required."
          },
          "MaxLength": 20
        }
      },
      "Resources": {
        "Activation": {
          "Type": "ALIYUN::ECS::Activation",
          "Properties": {
            "InstanceName": {
              "Ref": "InstanceName"
            },
            "InstanceCount": {
              "Ref": "InstanceCount"
            },
            "Description": {
              "Ref": "Description"
            },
            "TimeToLiveInHours": {
              "Ref": "TimeToLiveInHours"
            },
            "RegionId": {
              "Ref": "RegionId"
            },
            "IpAddressRange": {
              "Ref": "IpAddressRange"
            },
            "Tags": {
              "Ref": "Tags"
            }
          }
        }
      },
      "Outputs": {
        "DeregisteredCount": {
          "Description": "The number of instances that have been logged out.",
          "Value": {
            "Fn::GetAtt": [
              "Activation",
              "DeregisteredCount"
            ]
          }
        },
        "ActivationId": {
          "Description": "Activation code ID.",
          "Value": {
            "Fn::GetAtt": [
              "Activation",
              "ActivationId"
            ]
          }
        },
        "RegisteredCount": {
          "Description": "The number of registered instances.",
          "Value": {
            "Fn::GetAtt": [
              "Activation",
              "RegisteredCount"
            ]
          }
        },
        "ActivationCode": {
          "Description": "Activation code.",
          "Value": {
            "Fn::GetAtt": [
              "Activation",
              "ActivationCode"
            ]
          }
        }
      }
    }