Template name
ACS-ECS-BulkyDownloadFile
Template description
Downloads files in bulk to multiple Alibaba Cloud Elastic Compute Service (ECS) instances. This template is suitable for scenarios that require distributing files across multiple instances, such as application deployments and data synchronization. During configuration, you must provide several required parameters. The `regionId` parameter specifies the region of the target ECS instances. The `targets` parameter defines the specific ECS instances for the operation. The `sourceType` parameter specifies the file source, such as local, Object Storage Service (OSS), or HTTPS. The `sourcePath` parameter specifies the file location. After the template runs, it returns the results of the download operation so you can verify the download status.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
targets | Target instance | Json | Yes | ||
sourcePath | Select File | String | Yes | ||
regionId | The region ID. | String | No | {{ ACS::RegionId }} | |
sourceType | The type of the file. | String | No | local | |
destinationDir | The directory in which the file is stored. | String | No | /root | |
timeout | The timeout period in seconds. | Number | No | 600 | |
fileOwner | The file owner. | String | No | "" | |
fileGroup | The file group to which the file belongs. | String | No | "" | |
fileMode | The permissions on the file. | String | No | "" | |
overwrite | Specifies whether to overwrite existing files. | Boolean | No | True | |
rateControl | Task execution concurrency | Json | No | {'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10} | |
OOSAssumeRole | The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS). | String | No | "" |
Output parameters
Parameter | Description | Type |
commandOutput | String |
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:GetApplicationGroup"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
For more information, see ACS-ECS-BulkyDownloadFile.yml at GitHub.
Template content
Precautions:
To download files over HTTPS, the ECS instance must have public network access enabled.
To download files from OSS, a RAM role must be configured for the ECS instance. For more information, see this document.
Note
To download files using HTTPS, the ECS instance must have public network access.
To download files using OSS, the ECS instance must have a RAM role configured. For more information, see the referenced document.
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
Status: Running
sourceType:
Type: String
Description:
en: The size of a local file to be uploaded cannot exceed 500 MB.
zh-cn: The size of a local file to be uploaded cannot exceed 500 MB.
Label:
en: Source type
zh-cn: Source type
AllowedValues:
- local
- oss
- https
Default: local
AssociationPropertyMetadata:
LocaleKey: DownloadFileType
RegionId: ${regionId}
sourcePath:
Type: String
Label:
en: Source path
zh-cn: Select file
AssociationProperty: ALIYUN::OOS::File::FileUrl
AssociationPropertyMetadata:
FileType: ${sourceType}
RegionId: ${regionId}
destinationDir:
Label:
en: Destination directory
zh-cn: Destination directory
Description:
en: <li class="Li">The full path to save the file on the target instance. For example, /root for Linux or E:// for Windows.
zh-cn:
The full path to save the file on the target instance. For example, /root for Linux or E:// for Windows.
Type: String
Default: /root
timeout:
Label:
en: Timeout (s)
zh-cn: Timeout (s)
Type: Number
Default: 600
fileOwner:
Label:
en: File owner
zh-cn: File owner
Type: String
Default: ''
fileGroup:
Label:
en: File group
zh-cn: File group
Type: String
Default: ''
fileMode:
Label:
en: File mode
zh-cn: File mode
Type: String
Default: ''
overwrite:
Label:
en: Overwrite existing file
zh-cn: Overwrite existing file
Type: Boolean
Default: true
rateControl:
Label:
en: Concurrency rate for task execution
zh-cn: Concurrency rate for task execution
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: RAM role for OOS to assume
zh-cn: RAM role for OOS to assume
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
Description:
en: Gets the specified ECS instances
zh-cn: Gets the specified ECS instances
Action: 'ACS::SelectTargets'
Properties:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: '{{ regionId }}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: 'Instances.Instance[].InstanceId'
- Name: downloadFileToInstances
Action: 'ACS::ECS::DownloadFile'
Description:
en: Downloads a file to the specified ECS instances
zh-cn: Downloads a file to the specified ECS instances
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
sourceType: '{{ sourceType }}'
sourcePath: '{{ sourcePath }}'
destinationDir: '{{ destinationDir }}'
timeout: '{{ timeout }}'
fileOwner: '{{ fileOwner }}'
fileGroup: '{{ fileGroup }}'
fileMode: '{{ fileMode }}'
overwrite: '{{ overwrite }}'
Loop:
Items: '{{ getInstance.instanceIds }}'
RateControl: '{{ rateControl }}'
Outputs:
commandOutputs:
AggregateType: 'Fn::ListJoin'
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: commandOutput
Outputs:
commandOutput:
Type: String
Value: '{{ downloadFileToInstances.commandOutputs }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- sourceType
- sourcePath
- destinationDir
Label:
default:
zh-cn: Configure parameters
en: Configure parameters
- Parameters:
- regionId
- targets
Label:
default:
zh-cn: Select instances
en: Select instances
- Parameters:
- timeout
- fileOwner
- fileGroup
- fileMode
- overwrite
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: Advanced options
en: Advanced options
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
Status: Running
sourceType:
Type: String
Description:
en: The size of a local file cannot exceed 500 MB.
Label:
en: Source type
AllowedValues:
- local
- oss
- https
Default: local
AssociationPropertyMetadata:
LocaleKey: DownloadFileType
RegionId: ${regionId}
sourcePath:
Type: String
Label:
en: Source path
AssociationProperty: ALIYUN::OOS::File::FileUrl
AssociationPropertyMetadata:
FileType: ${sourceType}
RegionId: ${regionId}
destinationDir:
Label:
en: Destination directory
Description:
en:
Type: String
Default: /root
timeout:
Label:
en: Timeout (s)
Type: Number
Default: 600
fileOwner:
Label:
en: File owner
Type: String
Default: ''
fileGroup:
Label:
en: File group
Type: String
Default: ''
fileMode:
Label:
en: File mode
Type: String
Default: ''
overwrite:
Label:
en: Overwrite existing file
Type: Boolean
Default: true
rateControl:
Label:
en: Rate control
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOS assume role
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
Description:
en: Gets the specified ECS instances.
Action: 'ACS::SelectTargets'
Properties:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: '{{ regionId }}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: 'Instances.Instance[].InstanceId'
- Name: downloadFileToInstances
Action: 'ACS::ECS::DownloadFile'
Description:
en: Downloads the file to the specified instances.
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
sourceType: '{{ sourceType }}'
sourcePath: '{{ sourcePath }}'
destinationDir: '{{ destinationDir }}'
timeout: '{{ timeout }}'
fileOwner: '{{ fileOwner }}'
fileGroup: '{{ fileGroup }}'
fileMode: '{{ fileMode }}'
overwrite: '{{ overwrite }}'
Loop:
Items: '{{ getInstance.instanceIds }}'
RateControl: '{{ rateControl }}'
Outputs:
commandOutputs:
AggregateType: 'Fn::ListJoin'
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: commandOutput
Outputs:
commandOutput:
Type: String
Value: '{{ downloadFileToInstances.commandOutputs }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- sourceType
- sourcePath
- destinationDir
Label:
default:
en: Configure parameters
- Parameters:
- regionId
- targets
Label:
default:
en: Select instances
- Parameters:
- timeout
- fileOwner
- fileGroup
- fileMode
- overwrite
- rateControl
- OOSAssumeRole
Label:
default:
en: Advanced options
FormatVersion: OOS-2019-06-01
Description:
en: 'Bulky upload files to multiple Alibaba Cloud ECS instances, applicable to scenarios that require distributing files across multiple instances, such as application deployment and data synchronization. During configuration, users need to provide the following required parameter information: Region ID (regionId), which specifies the region of the target ECS instances where the files will be uploaded, Target Instances (targets), which defines the specific ECS instances to be operated on, Source Type (sourceType), which specifies the source method of the file (e.g., local, OSS, or HTTPS), and Source Path (sourcePath), which is the exact location of the file. Upon execution, the template provides the results of the file upload operation, enabling users to verify the status of the file uploads.'
name-en: Upload File
categories:
- instance_manage
- application_manage
- computenest
- tag_operate_resource
Parameters:
regionId:
Type: String
Label:
en: RegionId
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targets:
Type: Json
Label:
en: TargetInstance
Description:
en: <p class="p">Notes:</p> <ul class="ul"> <li class="li"><font color='red'>To download files over HTTPS, the ECS instance must have public network access.</font></li><li class="li"><font color='red'>To download files from OSS, the ECS instance must have a RAM role attached. For more information, see <a href="https://www.alibabacloud.com/help/en/operation-orchestration-service/latest/download-multiple-objects-to-an-instance#vOk3w">the related documentation</a>.</font></li></ul>
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
Status: Running
sourceType:
Type: String
Description:
en: The size of a file uploaded from a local machine cannot exceed 500 MB.
Label:
en: SourceType
AllowedValues:
- local
- oss
- https
Default: local
AssociationPropertyMetadata:
LocaleKey: DownloadFileType
RegionId: ${regionId}
sourcePath:
Type: String
Label:
en: SourcePath
AssociationProperty: ALIYUN::OOS::File::FileUrl
AssociationPropertyMetadata:
FileType: ${sourceType}
RegionId: ${regionId}
destinationDir:
Label:
en: DestinationDir
Description:
en: The full path on the target instance where the file is saved. Examples: /root for Linux, E:// for Windows.
Type: String
Default: /root
timeout:
Label:
en: Timeout (s)
Type: Number
Default: 600
fileOwner:
Label:
en: FileOwner
Type: String
Default: ''
fileGroup:
Label:
en: FileGroup
Type: String
Default: ''
fileMode:
Label:
en: FileMode
Type: String
Default: ''
overwrite:
Label:
en: Overwrite
Type: Boolean
Default: true
rateControl:
Label:
en: RateControl
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
Description:
en: Retrieves the specified ECS instances.
Action: 'ACS::SelectTargets'
Properties:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: '{{ regionId }}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: 'Instances.Instance[].InstanceId'
- Name: downloadFileToInstances
Action: 'ACS::ECS::DownloadFile'
Description:
en: Downloads the file to the specified ECS instances.
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
sourceType: '{{ sourceType }}'
sourcePath: '{{ sourcePath }}'
destinationDir: '{{ destinationDir }}'
timeout: '{{ timeout }}'
fileOwner: '{{ fileOwner }}'
fileGroup: '{{ fileGroup }}'
fileMode: '{{ fileMode }}'
overwrite: '{{ overwrite }}'
Loop:
Items: '{{ getInstance.instanceIds }}'
RateControl: '{{ rateControl }}'
Outputs:
commandOutputs:
AggregateType: 'Fn::ListJoin'
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: commandOutput
Outputs:
commandOutput:
Type: String
Value: '{{ downloadFileToInstances.commandOutputs }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- sourceType
- sourcePath
- destinationDir
Label:
default:
en: Configure Parameters
- Parameters:
- regionId
- targets
Label:
default:
en: Select Instances
- Parameters:
- timeout
- fileOwner
- fileGroup
- fileMode
- overwrite
- rateControl
- OOSAssumeRole
Label:
default:
en: Control Options