Todos os produtos
Search
Central de documentação

CloudOps Orchestration Service:ACS-ECS-UpdateImage

Última atualização: Jun 28, 2026

Nome do modelo

ACS-ECS-UpdateImage

Executar agora

Descrição do modelo

Cria uma imagem do Elastic Compute Service (ECS) mediante a execução de comandos que atualizam uma imagem existente. Ideal para atualizações em lote, como instalação de aplicativos e alterações na configuração do sistema. Parâmetros obrigatórios: regionId (região das operações de imagem) e sourceImageId (ID da imagem original). Os parâmetros opcionais incluem targetImageName (nome da nova imagem), instanceType (tipo de instância) e updateType (método de atualização). Após a execução, o modelo retorna o ID da nova imagem.

Tipo de modelo

Automatizado

Proprietário

Alibaba Cloud

Parâmetros de entrada

Parâmetro

Descrição

Tipo

Obrigatório

Valor padrão

Limite

sourceImageId

ID da imagem de origem.

String

Sim

instanceType

Tipo da instância ECS.

String

Sim

regionId

ID da região.

String

Não

{{ ACS::RegionId }}

zoneId

Zona de implantação do vSwitch.

String

Não

""

targetImageName

Nome da nova imagem.

String

Não

UpdateImage_from_{{sourceImageId}}on{{ACS::ExecutionId}}

whetherCreateVpc

Indica se deve criar uma Virtual Private Cloud (VPC).

Boolean

Não

False

vpcCidrBlock

Bloco CIDR IPv4 da VPC.

String

Não

192.168.0.0/16

vSwitchCidrBlock

Bloco CIDR do vSwitch.

String

Não

192.168.1.0/24

securityGroupId

ID do grupo de segurança.

String

Não

""

vSwitchId

ID do vSwitch.

String

Não

""

internetMaxBandwidthOut

Largura de banda pública.

Number

Não

0

ramRoleName

Função do Resource Access Management (RAM) atribuída à instância ECS.

String

Não

""

systemDiskCategory

Categoria do disco do sistema.

String

Não

cloud_essd

commandType

Tipo de comando do Cloud Assistant.

String

Não

RunShellScript

tags

Tags da imagem.

Json

Não

[]

commandContent

Comando do Cloud Assistant para execução na instância ECS.

String

Não

echo hello

timeout

Tempo limite.

Number

Não

600

updateType

Método de atualização da imagem.

String

Não

RunCommand

packageName

Nome do pacote de software.

String

Não

""

packageVersion

Versão do pacote de software.

String

Não

""

parameters

Parâmetros do comando.

Json

Não

{}

OOSAssumeRole

Função RAM assumida pelo CloudOps Orchestration Service (OOS).

String

Não

""

Parâmetros de saída

Parâmetro

Descrição

Tipo

imageId

String

Política de permissões necessária para executar o modelo

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:CreateImage",
                "ecs:DeleteInstance",
                "ecs:DescribeCloudAssistantStatus",
                "ecs:DescribeImages",
                "ecs:DescribeInstances",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:InstallCloudAssistant",
                "ecs:RebootInstance",
                "ecs:RunCommand",
                "ecs:RunInstances",
                "ecs:StopInstance"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ros:CreateStack",
                "ros:DeleteStack",
                "ros:GetStack"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oos:GetTemplate",
                "oos:UpdateInstancePackageState"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oss:GetObject"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Referências

Para mais informações, consulte ACS-ECS-UpdateImage.yml no GitHub.

Conteúdo do modelo

FormatVersion: OOS-2019-06-01
Description:
  en:   en: 'Update an existing ECS image by running commands and create a new ECS image. This is applicable to scenarios requiring batch updates and management of ECS images, such as software installation and system configuration changes. During configuration, users need to provide the following required parameters: Region ID (regionId), which specifies the region where the image update and creation operations occur, and Source Image ID (sourceImageId), which identifies the original ECS image that needs updating. Additional parameters that can be modified from their default values include: Target Image Name (targetImageName) for naming the newly created ECS image, Instance Type (instanceType) for the type of instance to install and configure the new image on, and Update Type (updateType), which can be selected to either run commands or install packages. Upon execution, the template will return the ID of the newly created image, facilitating the verification and management of the created ECS image.'
  zh-cn: the description in Chinese
  name-en: Update Image
  name-zh-cn: the description in Chinese
  categories:
    - image_manage
    - application_manage
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: the description in Chinese
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  zoneId:
    Type: String
    Label:
      en: VSwitch Availability Zone
      zh-cn: the description in Chinese
    Default: ''
    AssociationProperty: ALIYUN::ECS::Instance::ZoneId
    AssociationPropertyMetadata:
      RegionId: regionId
  targetImageName:
    Label:
      en: TargetImageName
      zh-cn: the description in Chinese
    Type: String
    Description:
      en: <p class="p">Note:</p> <ul class="ul"> <li class="li">Length is 2~128 English or Chinese characters</li> <li class="li"><font color='red'>must start with big or small letters or Chinese, not http:// and https://. </font></li> <li class="li">Can contain numbers, colons (:), underscores (_), or dashes (-). </li> </ul>
      zh-cn: the description in Chinese  </li> </ul>
    Default: 'UpdateImage_from_{{sourceImageId}}_on_{{ACS::ExecutionId}}'
  sourceImageId:
    Label:
      en: SourceImageId
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Image::ImageId'
    AssociationPropertyMetadata:
      RegionId: regionId
      ImageOwnerAlias:
        - self
  instanceType:
    Label:
      en: InstanceType
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
    AssociationPropertyMetadata:
      RegionId: regionId
      ZoneId: zoneId
  whetherCreateVpc:
    Type: Boolean
    Label:
      en: WhetherCreateVpc
      zh-cn: the description in Chinese
    Default: false
  vpcCidrBlock:
    Type: String
    Label:
      en: VPC CIDR IPv4 Block
      zh-cn: the description in Chinese
    Description:
      zh-cn: the description in Chinese
      en: 'The ip address range of the VPC in the CidrBlock form; <br>You can use the following ip address ranges and their subnets: <br><font color=''green''>[10.0.0.0/8]</font><br><font color=''green''>[172.16.0.0/12]</font><br><font color=''green''>[192.168.0.0/16]</font>'
    Default: 192.168.0.0/16
    AssociationProperty: ALIYUN::VPC::VPC::CidrBlock
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Equals:
            - ${whetherCreateVpc}
            - true
  vSwitchCidrBlock:
    Type: String
    Label:
      en: VSwitch CIDR Block
      zh-cn: the description in Chinese
    Description:
      zh-cn: the description in Chinese
      en: Must belong to the subnet segment of VPC
    Default: 192.168.1.0/24
    AssociationProperty: ALIYUN::VPC::VSwitch::CidrBlock
    AssociationPropertyMetadata:
      VpcCidrBlock: vpcCidrBlock
      Visible:
        Condition:
          Fn::Equals:
            - ${whetherCreateVpc}
            - true
  securityGroupId:
    Label:
      en: SecurityGroupId
      zh-cn: the description in Chinese
    Type: String
    Default: ''
    AssociationProperty: 'ALIYUN::ECS::SecurityGroup::SecurityGroupId'
    AssociationPropertyMetadata:
      RegionId: regionId
      Visible:
        Condition:
          Fn::Equals:
            - ${whetherCreateVpc}
            - false
  vSwitchId:
    Label:
      en: VSwitchId
      zh-cn: the description in Chinese
    Type: String
    Default: ''
    AssociationProperty: 'ALIYUN::VPC::VSwitch::VSwitchId'
    AssociationPropertyMetadata:
      RegionId: regionId
      ZoneId: zoneId
      Filters:
        - SecurityGroupId: securityGroupId
      Visible:
        Condition:
          Fn::Equals:
            - ${whetherCreateVpc}
            - false
  internetMaxBandwidthOut:
    Type: Number
    Label:
      zh-cn: the description in Chinese
      en: Internet Max Bandwidth Out
    Description:
      zh-cn: the description in Chinese
      en: no public ip if zero
    Default: 0
    MinValue: 0
    MaxValue: 100
  ramRoleName:
    Label:
      en: RamRoleName
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: ALIYUN::ECS::RAM::Role
    Default: ''
  systemDiskCategory:
    Label:
      en: SystemDiskCategory
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
    AssociationPropertyMetadata:
      RegionId: regionId
      InstanceType: instanceType
    Default: cloud_essd
  commandType:
    Label:
      en: CommandType
      zh-cn: the description in Chinese
    Type: String
    AssociationPropertyMetadata:
      LocaleKey: PricingCycle
      Visible:
        Condition:
          Fn::Equals:
            - ${updateType}
            - RunCommand
    AllowedValues:
      - RunBatScript
      - RunPowerShellScript
      - RunShellScript
    Default: RunShellScript
  tags:
    Label:
      en: Tags
      zh-cn: the description in Chinese
    Type: Json
    AssociationProperty: Tags
    AssociationPropertyMetadata:
      ShowSystem: false
    Default: []
  commandContent:
    Label:
      en: CommandContent
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: Code
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Equals:
            - ${updateType}
            - RunCommand
    Default: 'echo hello'
  timeout:
    Label:
      en: Timeout
      zh-cn: the description in Chinese
    Type: Number
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Equals:
            - ${updateType}
            - RunCommand
    Default: 600
  updateType:
    Label:
      en: UpdateType
      zh-cn: the description in Chinese
    Type: String
    AllowedValues:
      - RunCommand
      - InstallPackage
    Default: RunCommand
    AssociationPropertyMetadata:
      ValueLabelMapping:
        RunCommand:
          zh-cn: the description in Chinese
          en: RunCommand
        InstallPackage:
          zh-cn: the description in Chinese
          en: InstallPackage
  packageName:
    Label:
      en: packageName
      zh-cn: the description in Chinese
    Type: String
    Default: ''
    AssociationProperty: 'ALIYUN::OOS::Package::PackageName'
    AssociationPropertyMetadata:
      RegionId: regionId
      Visible:
        Condition:
          Fn::Equals:
            - ${updateType}
            - InstallPackage
  packageVersion:
    Label:
      en: packageVersion
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: 'ALIYUN::OOS::Package::PackageVersion'
    AssociationPropertyMetadata:
      TemplateName: ${packageName}
      Visible:
        Condition:
          Fn::Equals:
            - ${updateType}
            - InstallPackage
    Default: ''
  parameters:
    Label:
      en: Parameters
      zh-cn: the description in Chinese
    Type: Json
    Default: {}
    AssociationProperty: TemplateParameter
    AssociationPropertyMetadata:
      TemplateName: packageName
      TemplateVersion: packageVersion
      TemplateType: Package
      Visible:
        Condition:
          Fn::Equals:
            - ${updateType}
            - InstallPackage
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: the description in Chinese
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: checkNewImageName
  Action: ACS::CheckFor
  Description:
    en: Check image name is available
    zh-cn: the description in Chinese
  Properties:
    Service: ECS
    API: DescribeImages
    Parameters:
      RegionId: '{{ regionId }}'
      ImageName: '{{ targetImageName }}'
    DesiredValues:
    - 0
    PropertySelector: TotalCount
- Name: createStack
  Action: 'ACS::ExecuteAPI'
  When:
    Fn::Equals:
      - '{{ whetherCreateVpc }}'
      - true
  Description:
    en: Create a resource stack
    zh-cn: the description in Chinese
  Properties:
    Service: ROS
    API: CreateStack
    Parameters:
      RegionId: '{{ regionId  }}'
      StackName: 'OOS-{{ACS::ExecutionId}}'
      TimeoutInMinutes: 10
      DisableRollback: false
      Parameters:
        - ParameterKey: ZoneId
          ParameterValue: '{{ zoneId }}'
        - ParameterKey: VpcCidrBlock
          ParameterValue: '{{ vpcCidrBlock  }}'
        - ParameterKey: VSwitchCidrBlock
          ParameterValue: '{{ vSwitchCidrBlock  }}'
      TemplateBody: |
        ROSTemplateFormatVersion: '2015-09-01'
        Parameters:
          ZoneId:
            Type: String
          VpcCidrBlock:
            Type: String
          VSwitchCidrBlock:
            Type: String
        Resources:
          EcsVpc:
            Type: ALIYUN::ECS::VPC
            Properties:
              CidrBlock:
                Ref: VpcCidrBlock
              VpcName:
                Ref: ALIYUN::StackName
          EcsVSwitch:
            Type: ALIYUN::ECS::VSwitch
            Properties:
              ZoneId:
                Ref: ZoneId
              VpcId:
                Ref: EcsVpc
              CidrBlock:
                Ref: VSwitchCidrBlock
          EcsSecurityGroup:
            Type: ALIYUN::ECS::SecurityGroup
            Properties:
              VpcId:
                Ref: EcsVpc
        Outputs:
          SecurityGroupId:
            Value:
              Ref: EcsSecurityGroup
          VSwitchId:
            Value:
              Ref: EcsVSwitch
  Outputs:
    StackId:
      Type: String
      ValueSelector: StackId
- Name: untilStackReady
  Action: 'ACS::WaitFor'
  When:
    Fn::Equals:
      - '{{ whetherCreateVpc }}'
      - true
  Description:
    en: Wait for the stack status CREATE_COMPLETE
    zh-cn: the description in Chinese
  OnError: deleteStack
  Properties:
    Service: ROS
    API: GetStack
    Parameters:
      RegionId: '{{ regionId  }}'
      StackId: '{{createStack.StackId}}'
    DesiredValues:
      - CREATE_COMPLETE
    StopRetryValues:
      - CREATE_FAILED
      - CHECK_FAILED
      - ROLLBACK_FAILED
      - ROLLBACK_COMPLETE
      - CREATE_ROLLBACK_COMPLETE
    PropertySelector: Status
  Outputs:
    securityGroupId:
      Type: String
      ValueSelector: 'Outputs[0].OutputValue'
    vSwitchId:
      Type: String
      ValueSelector: 'Outputs[1].OutputValue'
- Name: runInstances
  Action: ACS::ECS::RunInstances
  Description:
    en: Create a ECS instance with source image
    zh-cn: the description in Chinese
  OnError: deleteStack
  Properties:
    regionId: '{{ regionId }}'
    imageId: '{{ sourceImageId }}'
    instanceType: '{{ instanceType }}'
    securityGroupId:
      Fn::If:
        - Fn::Equals:
            - '{{ whetherCreateVpc }}'
            - true
        - '{{ untilStackReady.securityGroupId }}'
        - '{{ securityGroupId }}'
    vSwitchId:
      Fn::If:
        - Fn::Equals:
            - '{{ whetherCreateVpc }}'
            - true
        - '{{ untilStackReady.vSwitchId }}'
        - '{{ vSwitchId }}'
    internetMaxBandwidthOut: '{{ internetMaxBandwidthOut }}'
    ramRoleName: '{{ ramRoleName }}'
    systemDiskCategory: '{{ systemDiskCategory }}'
  Outputs:
    instanceId:
      ValueSelector: instanceIds[0]
      Type: String
- Name: installCloudAssistant
  Action: ACS::ECS::InstallCloudAssistant
  Description:
    en: Install cloud assistant for ECS instance
    zh-cn: the description in Chinese
  OnError: deleteInstance
  Properties:
    regionId: '{{ regionId }}'
    instanceId: '{{ runInstances.instanceId }}'
- Name: runCommand
  Action: ACS::ECS::RunCommand
  When:
    Fn::Equals:
      - '{{ updateType }}'
      - RunCommand
  Description:
    en: Run cloud assistant command on ECS instance
    zh-cn: the description in Chinese
  OnError: deleteInstance
  Properties:
    regionId: '{{ regionId }}'
    commandContent: '{{ commandContent }}'
    commandType: '{{ commandType }}'
    instanceId: '{{ runInstances.instanceId }}'
    timeout: '{{ timeout }}'
- Name: configurePackage
  Action: ACS::ECS::ConfigureOOSPackageWithTemporaryURL
  Description:
    en: Configure Package
    zh-cn: the description in Chinese
  When:
    Fn::Equals:
      - '{{ updateType }}'
      - InstallPackage
  OnError: deleteInstance
  Properties:
    regionId: '{{ regionId }}'
    instanceId: '{{ runInstances.instanceId }}'
    packageName: '{{ packageName }}'
    packageVersion: '{{ packageVersion }}'
    parameters: '{{ parameters }}'
  Outputs:
    commandOutput:
      Type: String
      ValueSelector: .commandOutput
- Name: stopInstance
  Action: ACS::ECS::StopInstance
  Description:
    en: Stops the ECS instance
    zh-cn: the description in Chinese
  Properties:
    regionId: '{{ regionId }}'
    instanceId: '{{ runInstances.instanceId }}'
- Name: createImage
  Action: ACS::ECS::CreateImage
  Description:
    en: Create new image with the specified image name and instance ID
    zh-cn: the description in Chinese
  OnError: deleteInstance
  Properties:
    regionId: '{{ regionId }}'
    imageName: '{{ targetImageName }}'
    instanceId: '{{ runInstances.instanceId }}'
    tags: '{{tags}}'
  Outputs:
    imageId:
      ValueSelector: imageId
      Type: String
- Name: deleteInstance
  Action: ACS::ExecuteAPI
  Description:
    en: Deletes the ECS instance
    zh-cn: the description in Chinese
  Properties:
    Service: ECS
    API: DeleteInstance
    Risk: Normal
    Parameters:
      RegionId: '{{ regionId }}'
      InstanceId: '{{ runInstances.instanceId }}'
      Force: true
- Name: deleteStack
  Action: 'ACS::ExecuteApi'
  When:
    Fn::Equals:
      - '{{ whetherCreateVpc }}'
      - true
  Description:
    en: Delete the stack
    zh-cn: the description in Chinese
  Properties:
    Service: ROS
    API: DeleteStack
    Parameters:
      RegionId: '{{ regionId  }}'
      StackId: '{{ createStack.StackId }}'
Outputs:
  imageId:
    Type: String
    Value: '{{ createImage.imageId }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - regionId
          - sourceImageId
        Label:
          default:
            zh-cn: the description in Chinese
            en: Select Origin Image
      - Parameters:
          - targetImageName
          - tags
        Label:
          default:
            zh-cn: the description in Chinese
            en: Image Configure
      - Parameters:
          - zoneId
          - instanceType
          - whetherCreateVpc
          - vpcCidrBlock
          - vSwitchCidrBlock
          - securityGroupId
          - vSwitchId
          - internetMaxBandwidthOut
          - systemDiskCategory
          - ramRoleName
        Label:
          default:
            zh-cn: the description in Chinese
            en: ECS Instance Configure
      - Parameters:
          - updateType
          - packageName
          - packageVersion
          - parameters
          - commandType
          - commandContent
          - timeout
        Label:
          default:
            zh-cn: the description in Chinese
            en: Update Image Configuration
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Control Options