Description
The ACS::ExecuteAPI action can be used to call an API operation of a cloud service such as Elastic Compute Service (ECS). If the API operation is called asynchronously, you can use the ACS::WaitFor action to wait for the specified resource to enter the expected state.
Syntax
Note
The Tasks.Properties.API attribute specifies the API operation to be called, so you do not need to specify the API operation again in the Tasks.Properties.Parameters attribute.
RPC API operations
Tasks:
- Name: executeAPITaskExample
Action: ACS::ExecuteAPI
Properties:
Service: ECS # Required. The Alibaba Cloud Resource Name (ARN) of the cloud service in Resource Access Management (RAM). The name is not case-sensitive, such as ECS, RDS, or FC.
API: DescribeInstances # Required. The name of an API operation of the cloud service. The name is not case-sensitive, such as DescribeInstances.
AutoPaging: false # Optional. Specifies whether to automatically go through pages to obtain all results for API operations that return results on different pages. Default value: true.
Parameters: # The parameters that are required for calling the API operation. For more information, see the relevant documentation.
Parameter1: Value1
Parameter2: Value2
Outputs:
OutputParameter1:
ValueSelector: 'jq selector' # The jQuery selector for selecting the data to return. The jQuery selector extracts information from the JSON data returned by the API operation. For more information about the jQuery syntax, visit https://stedolan.github.io/jq/.
Type: String/Boolean/List(Array)/Number/Object
{
"Tasks": [
{
"Name": "executeAPITaskExample",
"Action": "ACS::ExecuteAPI",
"Properties": {
"Service": "ECS",
"API": "DescribeInstances",
"AutoPaging": false,
"Parameters": {
"Parameter1": "Value1",
"Parameter2": "Value2"
}
},
"Outputs": {
"OutputParameter1": {
"ValueSelector": "jq selector",
"Type": "String/Boolean/List(Array)/Number/Object"
}
}
}
]
}
ROA API operations
Tasks:
- Name: executeAPITaskExample2
Action: ACS::ExecuteAPI
Properties:
Service: OSS # Required. The ARN of the cloud service in RAM. The name is not case-sensitive, such as OSS, ECS, RDS, or FC.
API: PutBucket # Required. The name of an API operation of the cloud service. The name is not case-sensitive, such as PutBucket.
Method: PUT # Required. The HTTP request method of the API operation.
URI: '' # The Uniform Resource Identifier (URI) that is used by the API operation.
Headers: # Optional. The request headers of the API operation. Specify this attribute in the following format:
requestHeader1: 'requestHeader1Value'
Parameters: # Optional. The common parameters of the API operation.
commonParameter1: 'commonParameter1Value'
commonParameter2: 'commonParameter2Value'
# Optional. The request body of the API operation. Specify this attribute in the XML format.
Body: |
<?xml version="1.0" encoding="UTF-8"?> <supKey1> <parameter1> Value1
</parameter1> <parameter2> Value2 </parameter2> </supKey1>
{
"Tasks": [
{
"Name": "executeAPITaskExample2",
"Action": "ACS::ExecuteAPI",
"Properties": {
"Service": "OSS",
"API": "PutBucket",
"Method": "PUT",
"URI": "",
"Headers": {
"requestHeader1": "requestHeader1Value"
},
"Parameters": {
"commonParameter1": "commonParameter1Value",
"commonParameter2": "commonParameter2Value"
},
"Body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <supKey1> <parameter1> Value1\n</parameter1> <parameter2> Value2 </parameter2> </supKey1>\n"
}
}
]
}
Examples
Call the DescribeInstances operation of ECS in the RPC style
FormatVersion: OOS-2019-06-01
Description: Views the ECS instances by specifying instance status.
Parameters:
status:
Description: The ECS instances status for query instances.
Type: String
Tasks:
- Name: describeInstances
Action: ACS::ExecuteAPI
Description: Views the ECS instances by specifying instance status.
Properties:
Service: ECS
API: DescribeInstances
Parameters:
Status: '{{ status }}'
Outputs:
instanceIds:
Type: List
ValueSelector: Instances.Instance[].InstanceId
Outputs:
instanceIds:
Type: List
Value: '{{ describeInstances.instanceIds }}'
{
"FormatVersion": "OOS-2019-06-01",
"Description": "Views the ECS instances by specifying instance status.",
"Parameters": {
"status": {
"Description": "The ECS instances status for query instances.",
"Type": "String"
}
},
"Tasks": [
{
"Name": "describeInstances",
"Action": "ACS::ExecuteAPI",
"Description": "Views the ECS instances by specifying instance status.",
"Properties": {
"Service": "ECS",
"API": "DescribeInstances",
"Parameters": {
"Status": "{{ status }}"
}
},
"Outputs": {
"instanceIds": {
"Type": "List",
"ValueSelector": "Instances.Instance[].InstanceId"
}
}
}
],
"Outputs": {
"instanceIds": {
"Type": "List",
"Value": "{{ describeInstances.instanceIds }}"
}
}
}
Call the PutBucket operation of Object Storage Service (OSS) in the ROA style
FormatVersion: OOS-2019-06-01
Description:
en: Create multiple buckets in different region at the same time.
Parameters:
Regions:
Description:
en: The region id..
Type: List
BucketName:
Description:
en: The bucket name.
Type: String
DataRedundancyType:
Description:
en: Specifies the data disaster tolerance type of the bucket.
Type: String
AllowedValues:
- LRS
- ZRS
StorageClass:
Description:
en: Specify the bucket storage type.
Type: String
AllowedValues:
- Standard
- IA
- Archive
XOssAcl:
Description:
en: Specify bucket access rights.
Type: String
AllowedValues:
- public-read-write
- public-read
- private
RateControl:
Description:
en: Concurrency ratio of task execution.
Type: Json
AssociationProperty: RateControl
OOSAssumeRole:
Description: The RAM role to be assumed by OOS.
Type: String
Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: PutBucket
Action: 'ACS::ExecuteAPI'
Description:
en: Create buckets in different regions.
Properties:
Service: OSS
API: PutBucket
Method: PUT
URI: ''
Headers:
x-oss-acl: '{{ XOssAcl }}'
Parameters:
BucketName: '{{ BucketName }}-{{ACS::TaskLoopItem}}'
RegionId: '{{ACS::TaskLoopItem}}'
Body: |
<?xml version="1.0" encoding="UTF-8"?>
<CreateBucketConfiguration>
<StorageClass>{{ StorageClass }}</StorageClass>
<DataRedundancyType>{{ DataRedundancyType }}</DataRedundancyType>
</CreateBucketConfiguration>
Loop:
Items: '{{ Regions }}'
RateControl: '{{ RateControl }}'
Outputs:
imageIds:
AggregateType: 'Fn::ListJoin'
AggregateField: imageIds
Outputs:
imageIds:
Type: String
ValueSelector: .
{
"FormatVersion": "OOS-2019-06-01",
"Description": {
"en": "Create multiple buckets in different region at the same time.",
},
"Parameters": {
"Regions": {
"Description": {
"en": "The region id..",
},
"Type": "List"
},
"BucketName": {
"Description": {
"en": "The bucket name.",
},
"Type": "String"
},
"DataRedundancyType": {
"Description": {
"en": "Specifies the data disaster tolerance type of the bucket.",
},
"Type": "String",
"AllowedValues": [
"LRS",
"ZRS"
]
},
"StorageClass": {
"Description": {
"en": "Specify the bucket storage type.",
},
"Type": "String",
"AllowedValues": [
"Standard",
"IA",
"Archive"
]
},
"XOssAcl": {
"Description": {
"en": "Specify bucket access rights.",
},
"Type": "String",
"AllowedValues": [
"public-read-write",
"public-read",
"private"
]
},
"RateControl": {
"Description": {
"en": "Concurrency ratio of task execution.",
},
"Type": "Json",
"AssociationProperty": "RateControl"
},
"OOSAssumeRole": {
"Description": "The RAM role to be assumed by OOS.",
"Type": "String",
"Default": "OOSServiceRole"
}
},
"RamRole": "{{ OOSAssumeRole }}",
"Tasks": [
{
"Name": "PutBucket",
"Action": "ACS::ExecuteAPI",
"Description": {
"en": "Create buckets in different regions.",
},
"Properties": {
"Service": "OSS",
"API": "PutBucket",
"Method": "PUT",
"URI": "",
"Headers": {
"x-oss-acl": "{{ XOssAcl }}"
},
"Parameters": {
"BucketName": "{{ BucketName }}-{{ACS::TaskLoopItem}}",
"RegionId": "{{ACS::TaskLoopItem}}"
},
"Body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<CreateBucketConfiguration>\n <StorageClass>{{ StorageClass }}</StorageClass>\n <DataRedundancyType>{{ DataRedundancyType }}</DataRedundancyType>\n</CreateBucketConfiguration>\n"
},
"Loop": {
"Items": "{{ Regions }}",
"RateControl": "{{ RateControl }}",
"Outputs": {
"imageIds": {
"AggregateType": "Fn::ListJoin",
"AggregateField": "imageIds"
}
}
},
"Outputs": {
"imageIds": {
"Type": "String",
"ValueSelector": "."
}
}
}
]
}
Call the PutLogs operation of Simple Log Service in the ROA style
FormatVersion: OOS-2019-06-01
Description:
en: Perform a single ExecuteApi operation.
name-en: ACS-OOS-ExampleExecuteECSDescribeRegions
categories:
- ops
Parameters:
regionId:
Type: String
AssociationProperty: RegionId
Description: The ID of the region.
projectName:
Type: String
Description: The name of the project.
logstoreName:
Type: String
Description: The name of the Logstore.
Contents:
Type: String
Description: The content of the logs.
AssociationProperty: Json
Default:
- log1: value1
- log2: value2
Tags:
Type: String
Description: The tags that are added to the logs.
AssociationProperty: Json
Default: []
Tasks:
- Name: SlsPutLogs
Action: ACS::ExecuteApi
Description: Ships logs to Simple Log Service.
Properties:
Service: log
API: PutLogs
URI: /logstores/{{ logstoreName }}/shards/lb
Method: POST
Parameters:
RegionId: '{{ regionId }}'
projectName: '{{ projectName }}'
Logs:
Contents: '{{ Contents }}'
Tags: '{{ Tags }}'
{
"FormatVersion": "OOS-2019-06-01",
"Description": {
"en": "Perform a single ExecuteApi operation.",
"name-en": "ACS-OOS-ExampleExecuteECSDescribeRegions",
"categories": [
"ops"
]
},
"Parameters": {
"regionId": {
"Type": "String",
"AssociationProperty": "RegionId",
"Description": "The ID of the region"
},
"projectName": {
"Type": "String",
"Description": "The name of the project"
},
"logstoreName": {
"Type": "String",
"Description": "The name of the Logstore"
},
"Contents": {
"Type": "String",
"Description": "The content of the logs",
"AssociationProperty": "Json",
"Default": [
{
"log1": "value1"
},
{
"log2": "value2"
}
]
},
"Tags": {
"Type": "String",
"Description": "The tags that are added to the logs",
"AssociationProperty": "Json",
"Default": []
}
},
"Tasks": [
{
"Name": "SlsPutLogs",
"Action": "ACS::ExecuteApi",
"Description": "Ships logs to Simple Log Service",
"Properties": {
"Service": "log",
"API": "PutLogs",
"URI": "/logstores/{{ logstoreName }}/shards/lb",
"Method": "POST",
"Parameters": {
"RegionId": "{{ regionId }}",
"projectName": "{{ projectName }}",
"Logs": {
"Contents": "{{ Contents }}"
},
"Tags": "{{ Tags }}"
}
}
}
]
}