ACS-ECS-BulkyDownloadOSSFileAndRunCommand

更新时间:
复制 MD 格式

模板名称

ACS-ECS-BulkyDownloadOSSFileAndRunCommand 批量下载OSS文件到多个ECS实例并执行云助手命令

立即执行

模板描述

批量下载OSS文件到多个ECS实例并执行云助手命令

模板类型

自动化

所有者

Alibaba Cloud

输入参数

参数名称

描述

类型

是否必填

默认值

约束

targets

目标实例

Json

是

bucketName

OSS Bucket名称

String

是

objectName

OSS对象名称

String

是

destinationDir

实例中文件复制的目标目录

String

是

regionId

地域ID

String

否

{{ ACS::RegionId }}

OSSRegion

OSS所在地域

String

否

{{ ACS::RegionId }}

URLExpirationTime

下载链接的过期时间

Number

否

6000

whetherSaveToFile

是否将内容下载到特定文件

Boolean

否

True

commandContent

在ECS实例中执行的云助手命令

String

否

echo hello

timeout

ECS实例中执行命令的超时时间

Number

否

600

rateControl

速率控制

Json

否

{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10}

OOSAssumeRole

OOS扮演的RAM角色

String

否

""

输出参数

无

执行此模板需要的权限策略

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeInstances",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oos:GetApplicationGroup"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oss:GetObject"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

详情

ACS-ECS-BulkyDownloadOSSFileAndRunCommand详情

模板内容

FormatVersion: OOS-2019-06-01
Description:
  en: Bulky downLoad OSS file to instances and run command
  zh-cn: 批量下载OSS文件到多个ECS实例并执行云助手命令
  name-en: ACS-ECS-BulkyDownloadOSSFileAndRunCommand
  name-zh-cn: 批量下载OSS文件到多个ECS实例并执行云助手命令
  categories:
    - instance_manage
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: 地域ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  targets:
    Label:
      en: TargetInstance
      zh-cn: 目标实例
    Type: Json
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
  OSSRegion:
    Label:
      en: OSSRegion
      zh-cn: OSS所在地域
    Type: String
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  bucketName:
    Label:
      en: BucketName
      zh-cn: OSS Bucket名称
    Type: String
  objectName:
    Label:
      en: ObjectName
      zh-cn: OSS对象名称
    Type: String
  URLExpirationTime:
    Label:
      en: DownloadURLExpirationTime
      zh-cn: 下载链接的过期时间
    Type: Number
    Default: 6000
  destinationDir:
    Label:
      en: DestinationDir
      zh-cn: 实例中文件复制的目标目录
    Type: String
  whetherSaveToFile:
    Label:
      en: whetherSaveToFile
      zh-cn: 是否将内容下载到特定文件
    Type: Boolean
    Default: true
  commandContent:
    Label:
      en: CommandContent
      zh-cn: 在ECS实例中执行的云助手命令
    Type: String
    AssociationProperty: Code
    Default: echo hello
  timeout:
    Label:
      en: Timeout
      zh-cn: ECS实例中执行命令的超时时间
    Type: Number
    Default: 600
  rateControl:
    Label:
      en: RateControl
      zh-cn: 速率控制
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Views the ECS instances
      zh-cn: 获取ECS实例
    Action: 'ACS::SelectTargets'
    Properties:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: '{{ regionId }}'
      Filters:
        - '{{ targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: 'Instances.Instance[].InstanceId'
  - Name: downloadOSSFileAndRunCommand
    Action: ACS::ECS::DownloadOSSFileAndRunCommand
    Description:
      en: Download OSS file to the ECS instances and run command
      zh-cn: 下载OSS文件到实例并执行命令
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      bucketName: '{{ bucketName }}'
      objectName: '{{ objectName }}'
      URLExpirationTime: '{{ URLExpirationTime }}'
      OSSRegion: '{{ OSSRegion }}'
      destinationDir: '{{ destinationDir }}'
      whetherSaveToFile: '{{ whetherSaveToFile }}'
      commandContent: '{{ commandContent }}'
      timeout: '{{ timeout }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            zh-cn: 选择实例
            en: Select Instances
      - Parameters:
          - OSSRegion
          - bucketName
          - objectName
          - URLExpirationTime
          - whetherSaveToFile
          - destinationDir
        Label:
          default:
            zh-cn: 配置下载文件参数
            en: Configure Download File Parameters
      - Parameters:
          - commandContent
          - timeout
        Label:
          default:
            zh-cn: 配置执行命令参数
            en: Configure Run Command Parameters
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 高级选项
            en: Control Options